calling analysis without param bug

This commit is contained in:
Şefik Serangil 2020-02-12 21:01:28 +03:00
parent 539198737a
commit b7ed1897f5
3 changed files with 9 additions and 3 deletions

View File

@ -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']

View File

@ -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",

View File

@ -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:")