Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.

Using Age Gender model in python:

Kim__Jin
Beginner
1,616 Views

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/description/age-gender-recognition-retail-0013.md

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
1 Solution
UPetr
Novice
1,616 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

 

View solution in original post

0 Kudos
4 Replies
Shubha_R_Intel
Employee
1,616 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
trump__jenny
Beginner
1,616 Views

Hi Kim, Jin

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

 

0 Kudos
UPetr
Novice
1,616 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
UPetr
Novice
1,617 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
Reply