victordibia / handtracking

Building a Real-time Hand-Detector using Neural Networks (SSD) on Tensorflow
https://medium.com/@victor.dibia/how-to-build-a-real-time-hand-detector-using-neural-networks-ssd-on-tensorflow-d6bac0e4b2ce
MIT License
1.65k stars 458 forks source link

Threading to "improve" visual performance #54

Open alyata opened 5 years ago

alyata commented 5 years ago

Hi, @victordibia Thanks for your work! I've been experimenting with tensorflow object detection models (yours included) and I came by a trick to make the FPS higher. I ran the model inference on a separate thread, but I don't feed every frame into the model. While the child thread is still processing the previous frame, I simply skip model inference and re-use previous bounding box results. I understand that this isn't an actual improvement in model performance, but it helped me render the camera feed in 34 FPS while the actual model was running at 11 FPS. Is there any way I can adapt my code to this project? It's my first time contributing.

victordibia commented 5 years ago

HI @kapzlok2408 , This sounds like an interesting addition - there might be users who dont mind the skipped frames. Perhaps you can send a PR which updates the detect_multi-thread.py and adds an argument flag "reusing previous frames". When the flag is set, your fps hack "is implemented"?

 python detect_multi_threaded.py --reuseframes  0 --source videos/chess.mov

Let me know what you think, and thanks for sharing.

Victor.

alyata commented 5 years ago

Sounds good, I'll try to make the changes.