Bug 485979 - Expose Yolo Resizing Parameter to Improve Face Detection Accuracy
Summary: Expose Yolo Resizing Parameter to Improve Face Detection Accuracy
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Faces-Detection (show other bugs)
Version: 8.3.0
Platform: Microsoft Windows Microsoft Windows
: NOR wishlist
Target Milestone: ---
Assignee: Michael Miller
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-04-22 19:51 UTC by Ben
Modified: 2024-10-07 22:38 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 8.5.0
Sentry Crash Report:


Attachments
image for which face detection does not work (364.48 KB, image/jpeg)
2024-04-22 20:44 UTC, Ben
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ben 2024-04-22 19:51:11 UTC
SUMMARY

Face detection in large images can be improved by increasing the re-sizing parameter in the detection pipeline. To strike a balance between accuracy and performance, the parameter shouldn't be fixed. I propose exposing it to the user for manual adjustment.


STEPS TO REPRODUCE
1. Load a large image (many pixels) into digikam
2. Use the facial detection feature

OBSERVED RESULT

Not all faces are found

EXPECTED RESULT

All faces are found

SOFTWARE/OS VERSIONS
Windows: Windows 11 Pro
KDE Frameworks: 5.248.0
Qt: 6.6.1

ADDITIONAL INFORMATION

Image re-scaling is an important part of the face detection pipeline because it improves the computation speed. Currently, the final image size after resizing is hard-coded in the source code (e.g. https://invent.kde.org/graphics/digikam/-/blob/master/core/libs/facesengine/detection/opencv-dnn/dnnfacedetectoryolo.cpp#L42 for the Yolo model). This is problematic, because if an image is very big initially (many pixels), redical rescaling to the given size can make face detection impossible. By making this parameter adjustable by the user, we could improve the detection accuracy in such cases greatly.
Comment 1 Maik Qualmann 2024-04-22 20:02:19 UTC
What they picked out in the source code is not the scaled image size that is used. There are fixed values for the face model data. Upload a image in which not all faces are detected, if not publicly, then to my private email.
At the moment I can't imagine that not all faces will be detectedf they have YoloV3 activated.

Maik
Comment 2 Ben 2024-04-22 20:44:26 UTC
Created attachment 168818 [details]
image for which face detection does not work
Comment 3 Ben 2024-04-22 20:50:32 UTC
Hi Maik,

thanks for your quick answer. Please find my comments below.

(In reply to Maik Qualmann from comment #1)
> What they picked out in the source code is not the scaled image size that is used. 
Then what what sizes *are* used?

> There are fixed values for the face model data. 
I'm sorry but I don't understand what you mean.

> Upload a image in which not all faces are detected, if not publicly, then to my private email.
See attachment above.

> At the moment I can't imagine that not all faces will be detectedf they have YoloV3 activated.
It is good that you have confidence in your code! Nevertheless, I am a bit confused by your open distrust in my bug report. Clearly, I am not the first one to ask for improvements to the face detection algorithm (e.g. https://bugs.kde.org/show_bug.cgi?id=485029 and https://bugs.kde.org/show_bug.cgi?id=433716). So what causes your mistrust?
Comment 4 Maik Qualmann 2024-04-22 20:55:04 UTC
If I remove the white frame, all faces are recognized. I think that a image with such a frame is a bit out of scope.

Maik
Comment 5 Ben 2024-04-22 20:58:34 UTC
reply to Maik Qualmann from comment #4)
> If I remove the white frame, all faces are recognized. I think that a image with such a frame is a bit out of scope.
I disagree. Imagine a mountain or a monument instead of the white frame. That is exactly the kind of image I have in my gallery that cause and for which the algorithm does not work because of the fixed scaling.

Either way, I would appreciate if you told me the actual sizes that are used by digikam to rescale the pictures.
Comment 6 Bug Janitor Service 2024-05-07 03:45:58 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 7 Ben 2024-05-07 12:50:37 UTC
Prevent this from being closed. I believe I have provided the needed info.
Comment 8 caulier.gilles 2024-10-07 20:32:51 UTC
Michael,

One point reported by end-user, this time about Yolo3 model.

What's about YuNet and this proposal? It's compatible? It's already exists in your implementation? It's not necessary? 

Best
Gilles
Comment 9 Michael Miller 2024-10-07 22:09:01 UTC
This is already included in new YuNet implementation and YuNet UI.  It is the "face size" setting.  When the use selects "large" or "extra large" faces, the code resizes the original image to around 500x500px depending on the selection.  This makes processing much faster, but the small image size effectively "erases" small faces from the background.  Selecting "extra small" faces reduces the image to around 2000x2000px (or uses the original image size if it's already smaller), which allows the model to find very small faces in the background, but makes detection slower and can introduce false-positives for facial detection.

Cheers,
Mike