emilianavt / OpenSeeFace

Robust realtime face and facial landmark tracking on CPU with Unity integration
BSD 2-Clause "Simplified" License
1.41k stars 151 forks source link

single in get_eye_state #29

Closed kwea123 closed 2 years ago

kwea123 commented 2 years ago

What does the single in get_eye_state mean? https://github.com/emilianavt/OpenSeeFace/blob/c5ff6a8fe1c4bb11223d7bdbd53b395a6501395f/tracker.py#L925

I guess it's for detecting multiple people's eyes? Anyway, when num_crops == 1 (ie only 1 person), I think this argument needs to be set to true here: https://github.com/emilianavt/OpenSeeFace/blob/c5ff6a8fe1c4bb11223d7bdbd53b395a6501395f/tracker.py#L1112

Otherwise, it consumes too much cpu! Initially I found this because the built VSeeFace.exe consumes only ~10% cpu, but using this python script with lower fps consumes up to 20% cpu, so I was wondering what makes the difference. After setting single=True inside that code, now the cpu usage is about the same (10%).

emilianavt commented 2 years ago

Thank you for the message!

I guess it's for detecting multiple people's eyes?

It actually uses the model instantiated with single threaded settings, so it was intended to be used when tracking multiple faces. However, I found that onnxruntime has some issues with very high CPU usage when multiple threads are set, so VSeeFace always calls the tracker with --max-threads 1, which has the same effect as setting single=True here for the eye tracking. I should probably update facetracker.py to make this the default setting.

Edit: I changed it to always behave like single=True in 1264cc255cb233627a62ed83607361f8132dfde2.