Bug 497491 - Feature Request: Option to Rebuild Face Recognition Model from User-Tagged Data
Summary: Feature Request: Option to Rebuild Face Recognition Model from User-Tagged Data
Status: REPORTED
Alias: None
Product: digikam
Classification: Applications
Component: Faces-Workflow (show other bugs)
Version: 8.5.0
Platform: Other Other
: NOR wishlist
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-12-15 09:53 UTC by tab
Modified: 2025-02-02 11:57 UTC (History)
3 users (show)

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


Attachments
Screenshot (41.06 KB, image/png)
2024-12-15 10:12 UTC, tab
Details
Example after Face dedection. (257.94 KB, image/png)
2024-12-15 19:01 UTC, tab
Details
Result after new Training (166.56 KB, image/png)
2024-12-22 10:35 UTC, tab
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tab 2024-12-15 09:53:55 UTC
Dear Digikam Development Team,  

I would like to suggest a feature that could significantly improve the usability and accuracy of the face recognition functionality in Digikam.  

Currently, the face recognition model often misidentifies non-face regions as faces, requiring a lot of manual corrections. This issue persists even with the latest version (8.5.0), which I am using on Linux.  

To address this, I propose adding an option to rebuild the face recognition model from scratch, using user-provided training data. For example, I have over 10,000 images with properly tagged face regions and associated person tags. It would be ideal if I could:  
1. Delete the existing face recognition model.  
2. Re-train a new model based entirely on my tagged dataset.  

This feature would greatly enhance the flexibility of Digikam's face recognition, particularly for users with large collections of accurately tagged data. It could also help to refine the accuracy of the model over time as new data is added.  

Thank you for considering this suggestion. I hope it aligns with the ongoing development goals of Digikam.  

Best regards,
Comment 1 tab 2024-12-15 10:07:21 UTC
I found "Rebuild all training data" but it is not clear for me if it takes care abot alread added names. Will it delete also the names and face regions?
Comment 2 tab 2024-12-15 10:12:22 UTC
Created attachment 176629 [details]
Screenshot

This not realy clear for me.
Comment 4 Maik Qualmann 2024-12-15 17:27:12 UTC
I understand the bug report to mean that it is about the face detection itself, because too many objects are detected as faces that are not. So the user wants to replace the model data and replace it with his face models. I think this is not really possible.

Maik
Comment 5 caulier.gilles 2024-12-15 17:30:00 UTC
Here the Micheal viewpoint will be a plus i think...

Gilles
Comment 6 Michael Miller 2024-12-15 17:45:43 UTC
(In reply to Maik Qualmann from comment #4)
> I understand the bug report to mean that it is about the face detection
> itself, because too many objects are detected as faces that are not. So the
> user wants to replace the model data and replace it with his face models. I
> think this is not really possible.
> 
> Maik

It's not possible in 8.5.0.  In 8.6.0 I removed the check to see if digiKam detected the face.  8.6.0 will honor face tags from any program as long as the tag conforms to EXIF standards and was imported with the metadata.  I still need to fix the metadata import code to include other face tags, but my testing shows it works well.  It's not as good as if digiKam detected the face, but over 90% of externally tagged face regions are able to be recognized.

Cheers,
Mike
Comment 7 tab 2024-12-15 18:54:50 UTC
Dear Mike and Maik,
I’m not sure if my previous request was fully understood, so I’d like to clarify my idea with a more algorithmic approach.  

The current Digikam database contains information about regions with confirmed people in images, independent of EXIF data. My goal is to replace the existing, imprecise face recognition model with a new one, built on a better and more extensive data foundation.  

Here’s my proposed approach:  

1. **Resetting Unconfirmed Data:**  
   All unconfirmed or unknown people are removed from the model. Only confirmed people and their corresponding regions remain in the database.  

2. **Training a New Model:**  
   The face recognition model is retrained from scratch, using only images where people have been 100% confirmed.  
   - **Step-by-Step Process:**  
     a. Iterate through all confirmed people in the database.  
     b. For each person, use all associated images and marked face regions to train the model.  

3. **Result:**  
   A new, improved face recognition model is created, based on the currently confirmed people.  

4. **Next Steps:**  
   As intended in the product, this new model can then be used to detect additional people across the photo collection.  

This feature would enable more precise face recognition, especially for users who have already manually tagged a significant portion of their collection. It also offers an effective way to fix existing inaccuracies by rebuilding the model with personalized and verified data.  

Thank you for considering my suggestion, and for your ongoing work on this excellent tool!
Comment 8 tab 2024-12-15 19:01:55 UTC
Created attachment 176661 [details]
Example after Face dedection.

 In this case I have 105 Confirmed Enteries.
Dedection Face 1 is correct, 2,3,4 are also very well know, but wrong assiged.
Comment 9 Michael Miller 2024-12-15 19:29:37 UTC
(In reply to tab from comment #8)
> Created attachment 176661 [details]
> Example after Face dedection.
> 
>  In this case I have 105 Confirmed Enteries.
> Dedection Face 1 is correct, 2,3,4 are also very well know, but wrong
> assiged.

Ah, I see the problem.  2 things to note.  First, are you using YuNet and SFace in digiKam 8.5.0?  YuNet is the face detection model, and SFace is the face feature extractor. 

The matching algorithm (face classifier) in 8.5.0 has been completely rewritten for 8.6.0. 

With 8.5.0 using YuNet and SFace, results like what you are seeing are typically caused by 2 things.  The most common is an incorrectly confirmed face or two assigned to a person.  The other cause is a very blurry face assigned to a person.  Retraining will fix the blurry face. 

In 8.5.0, only confirmed faces are used to train the recognition model.  Unknown and unconfirmed faces are not used for any training.  The face detector (YuNet) is a pre-trained deep-learning neural network model, so the training is static.  

My apologies, but I'm still not clear on the goal of your idea.  Is it to better detect faces in an image, or to match an unknown detected face to a confirmed face?

Cheers,
Mike
Comment 10 tab 2024-12-16 16:07:43 UTC
Hi Mike,
yes, I’m using YuNet and SFace in digiKam 8.5.0.
I’ve also experimented with the two options under “Extras/Maintenance/Face Detection.”

However, this ultimately results in all face assignments being removed, and I would essentially have to start from scratch with the assignments.
This wouldn’t be necessary if the already confirmed faces were used as a basis for the new training model and the assignments were retained.

Is there anything I can do to assist? Screenshots? Online Conversation? Testing 8.6.0 .
Regards
TAB
Comment 11 Michael Miller 2024-12-17 01:51:50 UTC
(In reply to tab from comment #10)
> Hi Mike,
> yes, I’m using YuNet and SFace in digiKam 8.5.0.
> I’ve also experimented with the two options under “Extras/Maintenance/Face
> Detection.”
> 
> However, this ultimately results in all face assignments being removed, and
> I would essentially have to start from scratch with the assignments.
> This wouldn’t be necessary if the already confirmed faces were used as a
> basis for the new training model and the assignments were retained.
> 
> Is there anything I can do to assist? Screenshots? Online Conversation?
> Testing 8.6.0 .
> Regards
> TAB

Hi TAB,
"Tools->Maintenance->Detect and recognize faces" can rebuild the training data just from confirmed faces.  Select only "Rebuild all training data".  Behind the scenes, this deletes all the training data and training identities.  It then rebuilds the face recognition DB by scanning all the confirmed face thumbnails and re-extracting the face feature vectors.

Is this what you're looking for?

Cheers,
Mike
Comment 12 tab 2024-12-17 11:13:55 UTC
Yes, Mick, that's exactly what I'm looking for: "Rebuild all training data".
I noticed thumbnails of "good" faces on the bottom right during the rebuild process.

I’ve done that and restarted the face detection, but the results are still not improving.
What steps would you suggest next after rebuilding all training data?
Comment 13 Michael Miller 2024-12-18 18:55:32 UTC
(In reply to tab from comment #12)
> Yes, Mick, that's exactly what I'm looking for: "Rebuild all training data".
> I noticed thumbnails of "good" faces on the bottom right during the rebuild
> process.
> 
> I’ve done that and restarted the face detection, but the results are still
> not improving.
> What steps would you suggest next after rebuilding all training data?

Hi TAB,
The first thing I would look for are mis-labeled faces.  Review the confirmed faces that are matching to bad results.  Next, I would look for blurry or pixelated faces and remove the confirmed person tag.

After you've tried those two steps, rebuild training again and see if the results improve.  The face classifier in 8.5.0 (face matcher) is over 95% correct through millions of test comparisons.  

The classifier for 8.6.0 is getting close to 98% accurate.

Cheers,
Mike
Comment 14 tab 2024-12-22 10:34:22 UTC
Michael, thank you very much for your dedication. Unfortunately, I am not achieving the desired results.

Here are the steps I followed in the expectation of creating a new, improved model. Unfortunately, without success. I am happy to wait for version 8.6.0, if this would help me.

My Steps:
Rejected all suggestions for „Unconfirmed“ faces (240 in total).
Removed blurry or pixelated faces.
35,000 faces were marked as „Unknown“. I removed these using „Remove Faces“.
Removed all face regions marked as „Ignored“.
In the end, there were no unconfirmed, unknown, or ignored faces left.
Used the „Rebuild all Training Data“ function under Extra/Tools.
Processed only images from 2024 using „Detect Faces – Scan Again and Merge Results“.
Then ran „Detect Faces“ again.

Unfortunately, the results are still unsatisfactory.

Example of the Results:
 For one face with 3,316 already confirmed equivalent faces, five faces were detected. None of them match.
 For Face 2 in the screenshot, there are 75 confirmed equivalent faces in good quality.
 For Face 4 in the screenshot, there are 114 confirmed equivalent faces in good quality.

See Screenshot.
Comment 15 tab 2024-12-22 10:35:22 UTC
Created attachment 176819 [details]
Result after new Training
Comment 16 Michael Miller 2024-12-23 00:07:50 UTC
(In reply to tab from comment #15)
> Created attachment 176819 [details]
> Result after new Training

Hi TAB,
Thanks for the screenshot.  The face recognition engine accuracy isn't 100%, and sometimes it gets the guess wrong.  Based on the screenshot you shared, these errors, while unfortunate, are not outside the margin of error.  I recommend you tag the incorrectly suggested faces with the proper name.  The face classifier in 8.5.0 is about 95% accurate, which means is will give a wrong guess 5 out of 100 times.   Can you give me more details about your library, and how many faces have been correctly matched?

The classifier in 8.6.0 is over 97% accurate.  Other programs can be more accurate, but they mostly use cloud-based extraction and matching algorithms in order to achieve acceptable performance.  The digiKam developers value your privacy, which is why all processing happens on your computer, and no data is ever shared or sent to a cloud service. 

We will always strive to make digiKam better, and we hope you understand the challenges of trying to keep all processing local to your computer.

Cheers,
Mike
Comment 17 Michael Miller 2025-02-02 11:57:07 UTC
(In reply to Michael Miller from comment #16)
> (In reply to tab from comment #15)
> > Created attachment 176819 [details]
> > Result after new Training
> 
> Hi TAB,
> Thanks for the screenshot.  The face recognition engine accuracy isn't 100%,
> and sometimes it gets the guess wrong.  Based on the screenshot you shared,
> these errors, while unfortunate, are not outside the margin of error.  I
> recommend you tag the incorrectly suggested faces with the proper name.  The
> face classifier in 8.5.0 is about 95% accurate, which means is will give a
> wrong guess 5 out of 100 times.   Can you give me more details about your
> library, and how many faces have been correctly matched?
> 
> The classifier in 8.6.0 is over 97% accurate.  Other programs can be more
> accurate, but they mostly use cloud-based extraction and matching algorithms
> in order to achieve acceptable performance.  The digiKam developers value
> your privacy, which is why all processing happens on your computer, and no
> data is ever shared or sent to a cloud service. 
> 
> We will always strive to make digiKam better, and we hope you understand the
> challenges of trying to keep all processing local to your computer.
> 
> Cheers,
> Mike

Hi TAB,
Can you please try again with the latest daily build?  We've added a face image quality assesment (FIQA) to the "rebuild all training" option in maintenance and when confirming a new face.  FIQA filters out blurry, noisy, and pixelated faces from being used for training, which should help increase recognition accuracy.

Cheers,
Mike