- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi!
I try to predict age and gender from a face image with age-gender-recognition-retail-0013 -model but I can't seem to understand the documentation correctly.
This is my setup:
ageGenderNet = cv2.dnn.readNet("models/age-gender-recognition-retail-0013/FP32/age-gender-recognition-retail-0013.xml",
"models/age-gender-recognition-retail-0013/FP32/age-gender-recognition-retail-0013.bin")
genders = ["female", "male"]
faceBlob = cv2.dnn.blobFromImage(face, 1.0, (227, 227),
(78.4263377603, 87.7689143744, 114.895847746),
swapRB=False)
ageGenderNet.setInput(faceBlob)
aPreds = ageGenderNet.forward()
predict_gender = aPreds[0][1][0][0]
gConfidence = aPreds[0][1][1][0]
gd = genders[int(predict_gender + 0.5)]
predict_age = aPreds[0][0][0][0] * 100
aConfidence = aPreds[0][0][1][0]
The gender is predicted correctly, but the age readings are weird and I think I might be doing something wrong. Looking at a camera for a while I get anything from 1 - 90 for my predicted age. Would appreciate if someone could take a look and tell me if I'm extracting the age prediction and its confidence in a wrong way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi lawHo,
Greetings to you.
For this age-gender-recognition-retail-0013 model, it can output two predictions, gender and age. However, gender prediction is trained via classification (male, female) whereas age prediction is trained via regression (values). Therefore, it is only possible to get the confidence for the gender classification.
You may refer to the following tutorial, OpenCV Age Detection with Deep Learning, which discusses how to perform automatic age detection/prediction using OpenCV, Deep Learning, and Python.
You may refer to the following codes for executing the confidence for gender classification which I modified from the tutorial above (line 58-60).
preds = ageGenderNet.forward('prob')
i = preds[0].argmax()
genderConfidence = preds[0][i][0][0]
print('Confidence =' + str(genderConfidence*100) + ' %')
Regards,
Yu Chern
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It might be helpful to review appropriate Open Model Zoo demo, to see what postprocessing required for the model.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi lawHo,
Greetings to you.
First of all, this age-gender-recognition-retail-0013 model, has its own limitation and specification which you may refer to the link below. This model is able to recognize age of people in [18, 75] years old range, it is not applicable for children since their faces were not in the training set. Besides, the input shape for the input image should be in [62, 62].
Based on your coding, I found that your prediction for gender and age are based on the same output layer which means the prediction for the age is actually same as the prediction for the gender. You have to specify the prediction for age and gender to its respective output layer appropriately.
If you have a look in the link attached above, you will find that there are two different output layers mentioned which are “age_conv3” for age and “prob” for gender.
You may refer to this thread that has discussed the same topic before and the solution (coding) is also can be found in the thread.
Regards,
Yu Chern
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you @Peh_Intel for your answer, it pushed me forward. i'm still wondering how to get the confidence for age and gender recognition, any ideas how to do that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi lawHo,
Greetings to you.
For this age-gender-recognition-retail-0013 model, it can output two predictions, gender and age. However, gender prediction is trained via classification (male, female) whereas age prediction is trained via regression (values). Therefore, it is only possible to get the confidence for the gender classification.
You may refer to the following tutorial, OpenCV Age Detection with Deep Learning, which discusses how to perform automatic age detection/prediction using OpenCV, Deep Learning, and Python.
You may refer to the following codes for executing the confidence for gender classification which I modified from the tutorial above (line 58-60).
preds = ageGenderNet.forward('prob')
i = preds[0].argmax()
genderConfidence = preds[0][i][0][0]
print('Confidence =' + str(genderConfidence*100) + ' %')
Regards,
Yu Chern
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi lawHo,
This thread will no longer be monitored since we have provided a solution. If you need any additional information from Intel, please submit a new question.
Regards,
Yu Chern
![](/skins/images/C4F7392A5C68ACA60290C9576F107044/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page