arunponnusamy / cvlib

A simple, high level, easy to use, open source Computer Vision library for Python.
http://arunponnusamy.com/cvlib/
MIT License
647 stars 127 forks source link

detect_face finds faces in the background with a greater confidence #8

Closed leonvictor closed 4 years ago

leonvictor commented 5 years ago

Hey, first of all, thanks for the great lib. I've been playing around with face detection on the Mc-Master Pain Shoulder dataset to extract bounding boxes and am facing some issues.

In some cases, detect_faces returns multiple bounding boxes. No big deal, except that it gives a greater confidence to the wrongly detected background parts for no apparent reason.

bm049t2aaaff217

marchepas

Any idea why this could be happening ? Or how I can detect mishaps like this one ? If you have any idea how I can fix this let me know, I'd be glad to contribute.

Thanks

arunponnusamy commented 5 years ago

Hi @leonvictor , detect_face( ) function actually uses resnet10 backbone with ssd object detection method.

  1. resnet10 is not so deep. It's a lightweight network.(That is why, it is able to run on real time input). So, it is not perfect.
  2. The model being used here is actually trained on data where face is at a distance from the camera. If the face is close to the camera, (ie) if the face is occupying larger part of the image, it will struggle to detect / will return multiple detections. I have experienced this myself.

In this case I would suggest to use the frontal face detector in dlib. If execution time is not an issue, you can try the cnn face detector in dlib. Checkout this blog post to learn more.