Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing to detect faces in selfies #183

Open
gillonba opened this issue Sep 17, 2021 · 6 comments
Open

Failing to detect faces in selfies #183

gillonba opened this issue Sep 17, 2021 · 6 comments
Assignees
Labels
good first issue Good for newcomers question Further information is requested

Comments

@gillonba
Copy link

Is there a maximum image size to reliably detect faces? I have an application that has been working quite well, but I recently tried to start processing selfies captured from a phone camera and I can't seem to detect any faces, and I wonder if the face is just too large. I don't recall the exact resolution of the images being captured, but it would definitely be much larger than what I had been using before. Is there a known maximum image size to reliably identify faces? I am using HOG, would CNN work better? I hope that isn't the solution because I am running it on a machine that doesn't support CUDA. Resizing the images would be a much better solution for me I think. I'm really liking this library otherwise!

@takuya-takeuchi takuya-takeuchi self-assigned this Sep 18, 2021
@takuya-takeuchi takuya-takeuchi added the question Further information is requested label Sep 18, 2021
@takuya-takeuchi
Copy link
Owner

takuya-takeuchi commented Sep 18, 2021

@gillonba

Is there a maximum image size to reliably detect faces?

No. Basically it depends on face size on image rather than image size.
So it could be easy to detect large face occupies in image.

HOG could not be depend on image and face size.
HOG is Histograms of Oriented Gradients and it does not resize image when processing unlike CNN.
http://dlib.net/face_detector.py.html

If you want to detect only face except for recognize face, you can use

These libraries depend on NcnnDotNet.
They can detect small faces.

@gillonba
Copy link
Author

Ok. I wondered if there was something specific to phone selfies because I have had pretty good luck otherwise. Ultimately the point of the project is face recognition, so just detection is not good enough. Would it work to look into an improved face detection algorithm? If I remember correctly, I call FaceLocations() followed by FaceEncodings(), so would it maybe work to use some other library to detect the face and still use FaceEncodings() to generate an encoding? Or is it too fragile to work if the bounding rectangle isn't just right?

@takuya-takeuchi
Copy link
Owner

@gillonba

If I remember correctly, I call FaceLocations() followed by FaceEncodings(), so would it maybe work to use some other library to detect the face and still use FaceEncodings() to generate an encoding?

You are correct.
FRDN can accept face location to extract face encoding.
So you can pass face location which be retrieved from other libraries.
But I have not tried yet.

However, we must consider to keep low FAR and FRR.
It is meaningless even though library generate encoding datum from small face.

You can integrate CustomFaceDetector to FRDN.
You implement class from https://github.com/takuya-takeuchi/FaceRecognitionDotNet/blob/master/src/FaceRecognitionDotNet/Extensions/FaceDetector.cs.
It is easy to try other library.

@takuya-takeuchi takuya-takeuchi added the good first issue Good for newcomers label Sep 30, 2021
@gillonba
Copy link
Author

gillonba commented Nov 3, 2021

Thanks for the suggestion. I bit the bullet and got CUDA working and CNN seems to be working quite well, though I'm having trouble with high-resolution images. I guess I need to scale them down myself before passing them in to the locator?

I also tried UltraFace and while the speed is good and I have no problems getting the encodings from the locations it provides, I am getting a ton of false positives. I assume I can play with the ScoreThreshold but at this point it seems to have little advantage for me over CNN. It is really good to know that I can use other libraries though, and I'll keep it in mind in case I ever start playing with mobile. I'll post a test comparing all three methods once I have it refined a bit

Have you looked into Microsoft's ML.Net? It would be great to use a library built for C# and officially supported instead of dealing with a wrapper

@takuya-takeuchi
Copy link
Owner

good!!

I guess I need to scale them down myself before passing them in to the locator?

CNN has convolution layer and we need not to take care of scaling image.
However, small faces in picture will be disappeared when input to cnn.
So we should crop area and pass cropped image to cnn. It may be better result.

UltraFace and while the speed is good and I have no problems getting the encodings from the locations it provides, I am getting a ton of false positives

Small face may not be able to catch important feature when encoding.
But this issue is commonly. It is hard to resolve it.

@gillonba
Copy link
Author

So as promised, here is a test video showing the results from HOG, CNN, and UltraFace. In this case, CNN (with GPU) is the clear winner, being slightly faster than UltraFace and with fewer false positives. Now that the test program is set up, I can easily run it against other video clips if anyone wants to see it run against anything else.

https://rumble.com/vpghpz-alita-trailer-1-with-face-recognition.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants