Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
199 Views

Using Age Gender model in python:

Hi, I'm trying to run Age Gender (age-gender-recognition-retail-0013) model in python, and I seem to get only gender results. In out variable, I see only 2 numbers which is the prob. of the person being a male. The document suggests both age / gender as output. Any catch in running it on python?

https://github.com/opencv/open_model_zoo/blob/2018/intel_models/age-gender-recognition-retail-0013/d...

genet = cv2.dnn.readNet('models/age-gender-recognition-retail-0013.xml', 'models/age-gender-recognition-retail-0013.bin')
genet.setPreferableTarget(cv2.dnn.DNN_TARGET_MYRIAD)

def detect_gender(frame):
    blob = cv2.dnn.blobFromImage(frame, size=(62, 62), ddepth=cv2.CV_8U)
    genet.setInput(blob)
    out = genet.forward()
    print(out)
    return out

 

0 Kudos
4 Replies
Highlighted
Employee
199 Views

Jin. It's hard to say what is causing omission of age results. Kindly study the following two C++ samples. Between the two of them you should be able to figure out what's missing in your approach.

\deployment_tools\inference_engine\samples\interactive_face_detection_demo

\deployment_tools\inference_engine\samples\multichannel_face_detection

Sincerely,

Shubha

 

0 Kudos
Highlighted
Beginner
199 Views

Hi Kim, Jin

refer to this link: https://bit.ly/2Isy8UT  will help you to solve your problem

 

0 Kudos
Highlighted
Beginner
199 Views

@trump, jenny - It is not the same thing, 2 different networks are used, one for age, one for gender detection.

I am facing the same issue as Kim. Any help here?

0 Kudos
Highlighted
Beginner
199 Views

I found the solution meanwhile:

GENDERS_LABELS = ['Female', 'Male']
...
blob = cv2.dnn.blobFromImage(face, size=(62, 62), ddepth=cv2.CV_8U)
net.setInput(blob)
detections = net.forwardAndRetrieve(['prob', 'age_conv3'])

gender = GENDERS_LABELS[detections[0][0][0].argmax()]
age = detections[1][0][0][0][0][0] * 100

 

0 Kudos