yu4u / age-gender-estimation

Keras implementation of a CNN network for age and gender estimation
MIT License
1.46k stars 502 forks source link

How to predict just gender #119

Open FranciscoSola opened 4 years ago

FranciscoSola commented 4 years ago

Hi, thanks for the model and the tutorial. I'd like to use it just to predict gender. Of course I could use the model to predict both and then use only the one i care about but i would like not to lose processing time in something i don't need. Is there a way to sort it out? Thanks in advance!

yu4u commented 4 years ago

Actually, no. Current model simultaneously estimates age and gender. Thus, there is little computational overhead that can be reduced.

frankthinker commented 1 year ago

The program now already supports recognizing only gender.

You can try like this:

from deepface import DeepFace

objs = DeepFace.analyze(img_path = "path/to/your/image.jpg", # use the directory of the image you want to recognize
actions = ['gender'] # only gender detection
)
print(objs[0]["dominant_gender"])