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?
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
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.
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.argmax()] age = detections * 100