luxonis / depthai-experiments

Experimental projects we've done with DepthAI.
MIT License
842 stars 370 forks source link

age and gender demo crash on multiple face detection #282

Closed rexn8r closed 2 years ago

rexn8r commented 2 years ago

Hi Erik/Brandon,

After the spatial coordinates change in the master, the demo is working fine with single face but as soon as 2nd face pops in, after couple of frames, the demo crashes. below is the link to check the error;

https://www.infokliks.com/age-gender.png

what could be the problem and how do i fix it?

also on the age prediction, i am getting 7-10 years age difference. is the "age-gender-recognition-retail-0013" model not working well with Asian faces?

thanks rex

VanDavv commented 2 years ago

@rexn8r thanks for reporting the issue, I'll give it a try and resolve (but have some tasks in progress, so will jump on it after these). The issue can be related to the Script node added recently (CC @Erol444), as the error doesn't seem to come from python.

Regarding accuracy - that depends on various factors, including both lightning, face features, face angle and of course too little training / too small dataset. Taking a look at OV docs regarding the validation dataset used with this model there is a note about dataset

~20,000 unique subjects representing diverse ages, genders, and ethnicities.

Tried it now on my end (25 male caucasian, glasses and beard) it always indentified gender correctly but the age varied between 20 and 40:

However, with my friend (32 male caucasian, beard) it detected his age also as 25-26, even though he was looking straight to the camera and there was a correct lighting - so I think the model accuracy is also something to improve. The dataset used for the training is internal though, so maybe there are other age estimation networks that should be used here, didn't dig into it, happy for any suggestions (CC @tersekmatija )

tersekmatija commented 2 years ago

Hey,

Unfortunately I don't know of any good and fast models for age recognition, but if you know one feel free to suggest it. As @VanDavv said, the model is taken from OpenVINO model ZOO and was trained and evaluated on an internal data set, so we cannot do much here either. Is the age you are getting constantly too high, or just occasionally? If it's occasionally you could do some sort of smoothing over time to get a better value.

rexn8r commented 2 years ago

Hi guys,

Any update on this issue? I have tried modified age and gender sample on 2 pcs.

Pc1 (ubuntu 20.04) : When i run main.py, i get following warning;

I replaced the code with age_gender_manip.setWaitForMessage() but it threw "'depthai.node.ImageManip' object has no attribute 'setWaitForMessage'" error

Pc2 (ubuntu 18.04) : When I run main.py, there is no setWaitForMessage() warning but it does crash out on det_in = face_q.tryGet() occasionally

I have followed below installation steps to install DepthAI dependencies on both pcs;

Step 1 : sudo wget -qO- https://docs.luxonis.com/install_dependencies.sh | bash Step 2 : python3 -m pip install depthai Step 3 : git clone https://github.com/luxonis/depthai-python.git Step 4 : cd depthai-python/examples Step 5 : python3 install_requirements.py Step 6: Downloaded Age and gender demo zip file and ran the requirement.txt file to install the dependencies.

are these installation steps correct? How do I distribute depthai with my software?

looking forward to you assistance as we are seriously looking to use oak-d with our solution.

thanks

Erol444 commented 2 years ago

I'll be debugging today. but it might be that the fix is very similar to this PR: https://github.com/luxonis/depthai-experiments/pull/294

Erol444 commented 2 years ago

@rexn8r It doesn't seem to crash for me on latest depthai (2.14.1), but the pipeline isn't designed for multiple faces - we would need to add object tracker to it, to remember the ID of the face.

rexn8r commented 2 years ago

hi erik

thanks for your response. I did check version on my pc and it is also 2.14.1

so the code sample provided in this demo isn't supposed to handle multiple faces at all? it show up multiple faces with age, gender and distance but after couple of minutes, it would crash on following lines;

det_in = face_q.tryGet().

face_cropped_in = face_cropped_q.tryGet() RuntimeError: Communication exception - possible device error/misconfiguration. Original message 'Couldn't read data from stream: 'face_cropped' (X_LINK_ERROR)'

Looks like my initial setup is not correct.

are these steps correct to setup sdk?

Step 1 : sudo wget -qO- https://docs.luxonis.com/install_dependencies.sh | bash Step 2 : python3 -m pip install depthai Step 3 : git clone https://github.com/luxonis/depthai-python.git Step 4 : cd depthai-python/examples Step 5 : python3 install_requirements.py Step 6: Downloaded Age and gender demo zip file and ran the requirement.txt file to install the dependencies.

is it possible to re-install the sdk and start from fresh?

thanks rex

rexn8r commented 2 years ago

Hey,

Unfortunately I don't know of any good and fast models for age recognition, but if you know one feel free to suggest it. As @VanDavv said, the model is taken from OpenVINO model ZOO and was trained and evaluated on an internal data set, so we cannot do much here either. Is the age you are getting constantly too high, or just occasionally? If it's occasionally you could do some sort of smoothing over time to get a better value.

Hi

the age and gender both fluctuate in terms of accuracy. the age is always below 7-10 years than actual. and the gender also sometimes wrong.

Is it possible to convert to convert age net caffemodel and gender net caffemodel into blob and use it with depthai?

I stumbled upon this link;

http://blobconverter.luxonis.com/

I have following files of caffemodels;

age_net.caffemodel age_deploy.prototxt gender_net.caffemodel gender_deploy.prototxt

which i could convert on the above website link.

But in the age_gender depthai demo, single "age-gender-recognition-retail-0013" blob file is used. so how do i merge these 2 and use it with depthai? is this even possible?

thanks rex

Erol444 commented 2 years ago

Hello @rexn8r , yes, it would be possible, you can find model compiling documentation here. You can just use the blobconverter link you posted above and upload both models. I would just convert both models (one by one) and have 2 models running separately - it would be possible to combine both models, but it wouldn't be easy (quite hacky).

rexn8r commented 2 years ago

thanks will check that out.