diff --git a/deepface/DeepFace.py b/deepface/DeepFace.py index a328697..ba2e130 100644 --- a/deepface/DeepFace.py +++ b/deepface/DeepFace.py @@ -122,8 +122,6 @@ def analyze(img_path, actions= []): print("Actions to do: ", actions) - img = functions.detectFace(img_path, (224, 224)) - #TO-DO: do this in parallel pbar = tqdm(range(0,len(actions)), desc='Finding actions') @@ -163,6 +161,7 @@ def analyze(img_path, actions= []): resp_obj += emotion_obj elif action == 'age': + img = functions.detectFace(img_path, (224, 224), False) #just emotion model expects grayscale images #print("age prediction") model = Age.loadModel() age_predictions = model.predict(img)[0,:] @@ -171,6 +170,7 @@ def analyze(img_path, actions= []): resp_obj += "\"age\": %s" % (apparent_age) elif action == 'gender': + img = functions.detectFace(img_path, (224, 224), False) #just emotion model expects grayscale images #print("gender prediction") model = Gender.loadModel() @@ -184,6 +184,7 @@ def analyze(img_path, actions= []): resp_obj += "\"gender\": \"%s\"" % (gender) elif action == 'race': + img = functions.detectFace(img_path, (224, 224), False) #just emotion model expects grayscale images model = Race.loadModel() race_predictions = model.predict(img)[0,:] race_labels = ['asian', 'indian', 'black', 'white', 'middle eastern', 'latino hispanic'] diff --git a/setup.py b/setup.py index 4f0c1fb..d7ceb23 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh: setuptools.setup( name="deepface", - version="0.0.2", + version="0.0.3", author="Sefik Ilkin Serengil", author_email="serengil@gmail.com", description="Deep Face Anaylsis Framework for Face Recognition and Demography", diff --git a/tests/unit_tests.py b/tests/unit_tests.py index 9fcb477..6519961 100644 --- a/tests/unit_tests.py +++ b/tests/unit_tests.py @@ -6,6 +6,11 @@ import json print("Facial analysis tests") img = "dataset/img4.jpg" +demography = DeepFace.analyze(img) +print(demography) + +#----------------------------------------- + demography = DeepFace.analyze(img, ['age', 'gender', 'race', 'emotion']) print("Demography:")