Bug 502219 - Right-click, "Recognize faces" does no longer recognize any faces.
Summary: Right-click, "Recognize faces" does no longer recognize any faces.
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Faces-Recognition (other bugs)
Version First Reported In: 8.7.0
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-03-30 22:44 UTC by MarcP
Modified: 2025-04-19 20:12 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 8.7.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description MarcP 2025-03-30 22:44:59 UTC
SUMMARY
I believe I found a regression in the face recognition feature. Right-click, "Recognize Faces" no longer works in current 8.7.0 builds. I'm not sure when it stopped working, but it's been at least a few weeks. Face detection works fine, though. Basically when you scan new pictures for faces, you can see the newly detected faces in the People panel, but there are always 0 recognized faces, even if it's a very familiar face.

However, and I haven't been able to figure out exactly why, from time to time it works and it finally recognizes the faces. Sometimes just waiting a few minutes and trying again seems to work.

I also tried to complete rebuild the training database by going to Tools -> Maintenance -> Detect and Recognize faces -> Rebuild all training data. It takes a few minutes, and when it's done, it seems that face recognition works until the next restart.

I'm happy to provide any logs, screenshots or video recordings that would help you troubleshoot it.


STEPS TO REPRODUCE
1. Select a group of pictures with people.
2. Right click.
3. "Recognize faces"
4. Wait for results

OBSERVED RESULT
The pictures are scanned, but 0 faces are recognized.

EXPECTED RESULT
Familiar faces are recognized and suggested to the respective person in the People panel.


SOFTWARE/OS VERSIONS
Windows:  Windows 10 22H2
Digikam 8.7.0 with build date 28/3/2025 18:01

ADDITIONAL INFORMATION
Comment 1 Maik Qualmann 2025-03-31 16:40:25 UTC
Face recognition is definitely starting; I can see that in the debug log.
Did you perhaps set the accuracy value for face recognition too high?

Maik
Comment 2 MarcP 2025-03-31 16:57:51 UTC
Hi Maik. I believe I'm using the default values for face recognition. Yesterday I tried from a different user profile in Windows and I could not reproduce the issue, so maybe it's linked to my specific digikam configuration or database. I'll do some more testing this evening when I get home and let you know.
Comment 3 Maik Qualmann 2025-03-31 18:27:06 UTC
Git commit 64b3d2c1e306a5507190578c5e79301cae8e8587 by Maik Qualmann.
Committed on 31/03/2025 at 18:26.
Pushed by mqualmann into branch 'master'.

try to fix face recognition in image preview

M  +2    -1    core/app/views/stack/itemiconview_search.cpp
M  +2    -1    core/utilities/maintenance/tools/facesmanagement/facesengine.cpp

https://invent.kde.org/graphics/digikam/-/commit/64b3d2c1e306a5507190578c5e79301cae8e8587
Comment 4 MarcP 2025-03-31 23:20:50 UTC
I installed the latest build (digiKam-8.7.0-20250331T170207-Qt6-Win64.exe), and I confirm the issue still persists.

It's quite strange, I can consistently reproduce the issue but at some point... face recognition starts working again, without me doing anything in particular. It seems to take about 10 minutes. I just keep right-clicking on a couple of detected faces and doing the "Recognize Faces", and I keep getting the "Faces found: 0", but at some point i get a "Faces found: 2". And from that moment on, it works normally until the next time I open Digikam.

I can confirm it doesn't depend on the number of tries, you just need to wait. I opened Windows' Task Manager, and I noticed digikam was using ~9% of my CPU during that time (see https://i.imgur.com/CebNEBI.png), and then once the CPU usage went back to near 0%, face recognition worked again. It looks like digikam is running some background process that takes about 10 minutes on my computer and face recognition doesn't work until it completes that job, but it's not obvious from the interface.

Is there any way to find out what's causing this delay?
Comment 5 Maik Qualmann 2025-04-01 06:01:34 UTC
Hi Marc,

The version you tested not yet contain my changes.

Maik
Comment 6 Maik Qualmann 2025-04-01 06:15:02 UTC
Hi Marc,

Do you use face detection at the digikam start for newly found items?

Maik
Comment 7 Michael Miller 2025-04-01 10:35:13 UTC
(In reply to Maik Qualmann from comment #6)
> Hi Marc,
> 
> Do you use face detection at the digikam start for newly found items?
> 
> Maik

Hi Marc,
How big is your library, and how many faces do you have tagged?

Cheers,
Mike
Comment 8 MarcP 2025-04-01 10:59:24 UTC
Hi Maik. Yes, I have set face detection for newly found items at startup. My library has around 200 000 pictures and I must have 1000-1500 different people, with more than 25000 tagged faces.
Comment 9 Michael Miller 2025-04-01 11:18:07 UTC
(In reply to MarcP from comment #8)
> Hi Maik. Yes, I have set face detection for newly found items at startup. My
> library has around 200 000 pictures and I must have 1000-1500 different
> people, with more than 25000 tagged faces.

Hi Marc,
I have an idea for what the problem might be.  I'll need a few days to put in a fix.

Can you look in the digiKam log for a line that looks like this: "FaceClassifier::loadTrainingData: training completed in"?

Cheers,
Mike
Comment 10 MarcP 2025-04-01 11:34:51 UTC
Sure, I'll try that later today.
Comment 11 Michael Miller 2025-04-01 13:17:50 UTC
(In reply to MarcP from comment #10)
> Sure, I'll try that later today.

Thank you.  There will be a number after "FaceClassifier::loadTrainingData: training completed in" which is the training time in milliseconds.  Please copy the whole line including the number and post it here when you have a chance.

Cheers,
Mike
Comment 12 Maik Qualmann 2025-04-01 18:20:01 UTC
Hi Marc,

If you use the initial face detection scan, it's clear. We keep further face engine processes queued until the first one is finished. I think we can perhaps use two different process item IDs. You're still using your slow network collection, I think?

Maik
Comment 13 Maik Qualmann 2025-04-01 19:01:52 UTC
Git commit 863c1af2f2a64c46cbe7b21a5e5c321d27cb2327 by Maik Qualmann.
Committed on 01/04/2025 at 19:01.
Pushed by mqualmann into branch 'master'.

use different progress ids for face detection and recognition

M  +5    -2    core/app/items/views/digikamitemview.cpp
M  +9    -3    core/app/views/stack/itemiconview_search.cpp
M  +33   -1    core/utilities/maintenance/tools/facesmanagement/facesengine.cpp
M  +4    -0    core/utilities/maintenance/tools/facesmanagement/facesengine.h

https://invent.kde.org/graphics/digikam/-/commit/863c1af2f2a64c46cbe7b21a5e5c321d27cb2327
Comment 14 MarcP 2025-04-01 19:04:01 UTC
No, actually a few months ago I moved everything locally to a NVME drive (I sync everything from my NAS via Nextcloud), so all my setup is purely local now, including the photos and the database. I also got a new CPU, so it's snappier now. The downside is that's a Windows computer :(
Comment 15 Maik Qualmann 2025-04-01 19:14:53 UTC
Yes, I was a bit surprised about the Windows computer. ((:-))

Maik
Comment 16 Michael Miller 2025-04-01 19:15:35 UTC
I'm working in a new branch to add background face processing. I added missing error logic when a second face scan was started so it now shows an error message.  There's a visual indicator now that shows the additional scan didn't run. I'm hoping to have the code merged in a few days.

Looks like Maik had the same idea with the last commit.  I'll merge our changes.

Cheers,
Mike
Comment 17 MarcP 2025-04-02 00:01:58 UTC
Hi,

I capture the logs while I started digikam. I made sure there were no new pictures in the library so the logs doesn't get cluttered.
I found two entries mentioning FaceClassifier::. One at 15 seconds, and another at 351 seconds.

00000359	15.78285313	[56196] digikam.facesengine: FaceClassifier::loadTrainingData: training completed in  361232 ms

00000369	351.98092651	[46368] digikam.facesengine: FaceClassifier::loadTrainingData: training completed in  350176 ms	

After I get the second entry, Digikam's CPU usage goes from 8% to idle, and the face recognition works again.

If you want to check the whole logfile (369 lines), you can find it here: http://158.101.198.126:9011/share/R8q9-AkA

I hope it helps.
Comment 18 Michael Miller 2025-04-02 00:09:30 UTC
(In reply to MarcP from comment #17)
> Hi,
> 
> I capture the logs while I started digikam. I made sure there were no new
> pictures in the library so the logs doesn't get cluttered.
> I found two entries mentioning FaceClassifier::. One at 15 seconds, and
> another at 351 seconds.
> 
> 00000359	15.78285313	[56196] digikam.facesengine:
> FaceClassifier::loadTrainingData: training completed in  361232 ms
> 
> 00000369	351.98092651	[46368] digikam.facesengine:
> FaceClassifier::loadTrainingData: training completed in  350176 ms	
> 
> After I get the second entry, Digikam's CPU usage goes from 8% to idle, and
> the face recognition works again.
> 
> If you want to check the whole logfile (369 lines), you can find it here:
> http://158.101.198.126:9011/share/R8q9-AkA
> 
> I hope it helps.

Hi Marc,
Thank you.  That's very helpful, and confirms a suspicion I had.  Basically, because of the size of your library, and specifically the number of tagged faces, it's taking almost 6 minutes until the face recognition system is trained and can recognize faces.

Fortunately, I'm already working on a fix that should get the face recognition system ready in a few seconds. The fix should be ready this weekend.

Cheers,
Mike
Comment 19 Michael Miller 2025-04-02 19:51:06 UTC
Git commit 816ceeff5dbd963689fa01809a3464c067cec0ab by Michael Miller.
Committed on 02/04/2025 at 19:50.
Pushed by michmill into branch 'master'.

fix delay using face classifier
FIXED-IN: 8.7.0

M  +88   -19   core/libs/facesengine/recognition/faceclassifier.cpp

https://invent.kde.org/graphics/digikam/-/commit/816ceeff5dbd963689fa01809a3464c067cec0ab
Comment 20 Michael Miller 2025-04-03 22:47:20 UTC
Hi Marc,
The fix should be in the build available Saturday.  Please let me know if you have any problems or questions.

Cheers,
Mike
Comment 21 MarcP 2025-04-04 03:32:32 UTC
(In reply to Michael Miller from comment #20)
> Hi Marc,
> The fix should be in the build available Saturday.  Please let me know if
> you have any problems or questions.
> 
> Cheers,
> Mike

Hi Mike,

I just tested with the new build (digiKam-8.7.0-20250403T061347-Qt6-Win64.exe) that was uploaded today to the files.kde.org/digikam site, and I can confirm that several faces were scanned and recognized upon startup with no delay, so this issue appears to have been fixed. If I noticed anything strange in the next few days I'll let you know.

Thank you all of you for your dedication!
Comment 22 Michael Miller 2025-04-04 10:11:28 UTC
> Hi Mike,
> 
> I just tested with the new build
> (digiKam-8.7.0-20250403T061347-Qt6-Win64.exe) that was uploaded today to the
> files.kde.org/digikam site, and I can confirm that several faces were
> scanned and recognized upon startup with no delay, so this issue appears to
> have been fixed. If I noticed anything strange in the next few days I'll let
> you know.
> 
> Thank you all of you for your dedication!

Hi Marc,
That's good news.  Thank you for helping us fix this issue.  We appreciate the time you've spent helping us make digiKam better for everyone.

Cheers,
Mike
Comment 23 MarcP 2025-04-06 00:08:42 UTC
Hey, 

I'm not reopening the ticket because the issue is gone, but I noticed that Digikam scanned my whole picture collection and suggested new faces. Is this a new feature? Not sure if it was done on startup or while I using the program (I opened it, moved away from the computer and came back after a couple hours).
Comment 24 Michael Miller 2025-04-06 00:22:24 UTC
(In reply to MarcP from comment #23)
> Hey, 
> 
> I'm not reopening the ticket because the issue is gone, but I noticed that
> Digikam scanned my whole picture collection and suggested new faces. Is this
> a new feature? Not sure if it was done on startup or while I using the
> program (I opened it, moved away from the computer and came back after a
> couple hours).

Hi Marc,
It depends.  You can have digiKam scan at startup.  The option is in Settings->Miscelaneous->Behaviour->Scan for new item at startup.  If it finds new items it will start a face scan.  Also, we just added a new feature in the past few days that will automatically start a new face scan if you confirm/tag a face.  This can be controlled with Settings->Miscelaneous->Behaviour->Background face recognition scan.  The background face scan runs at the lowest possible priority so it doesn't interfere with using digiKam or other programs.

Cheers,
Mike
Comment 25 MarcP 2025-04-06 00:32:10 UTC
Ohhh, I wasn't fully aware of that new feature, that clear things up. It actually makes a lot of sense (Picasa used to work this way, re-scanning your faces in the background when you confirmed a face). I just wish Bug #444394 was addressed, so that rejected faces wouldn’t keep getting reassigned to the same person automatically.
Comment 26 Michael Miller 2025-04-06 00:39:10 UTC
Hi Marc,
> It actually makes a lot of sense (Picasa used to work this way, re-scanning
> your faces in the background when you confirmed a face). 
Yep, that's why we added it. 

>I just wish Bug
> #444394 was addressed, so that rejected faces wouldn’t keep getting
> reassigned to the same person automatically.
Yeah, #444394 will take quite a bit of work to create a mechanism to save rejections.  Plus, the face matching algorithm doesn't have any way to exclude faces in the rejected list without creating a whole new custom in-memory matching database with those faces excluded. A custom in-memory database would have to be created for each face identity with that face identities exclusions. It's not really feasible at the moment.

I recommed either ignoring the face so it won't be suggested at all, or tagging the face with a new name.  Either way the face won't be suggested again.

Cheers,
Mike
Comment 27 MarcP 2025-04-06 00:49:55 UTC
I see — it would require a major change in how face detection is currently handled. That’s totally fine; I’m just glad the suggestion is on your radar. For now, I’ll stick with marking faces as ignored.

Just one last question: can the background scan still modify faces that are already being suggested to someone, or does it only affect faces that haven’t been suggested yet? Hopefully it is the former, so they are automatically reassigned without me having to reject them first.
Comment 28 Michael Miller 2025-04-06 00:52:03 UTC
Hi Marc,
> Just one last question: can the background scan still modify faces that are
> already being suggested to someone, or does it only affect faces that
> haven’t been suggested yet? Hopefully it is the former, so they are
> automatically reassigned without me having to reject them first.

Yes, it should clear any existing suggestions and apply the new suggestion if the new scan finds a stronger match.

Cheers,
Mike
Comment 29 Michael Miller 2025-04-18 10:55:29 UTC
Git commit 499d41cee5f7422e9951ed9c097d898568f7046d by Michael Miller.
Committed on 18/04/2025 at 10:55.
Pushed by michmill into branch 'master'.

Save rejected face data

Save rejected face tags and exclude the tags from being used during face classification (matching).

This MR does not include code to write the rejected face tags to the item metadata.  That will be a different MR in the next several days.

This MR does not include the ability to clear the reject face data. That will be a different MR in the next several days.
Related: bug 444394, bug 432207, bug 415783, bug 502924

M  +5    -0    core/libs/database/coredb/coredbconstants.cpp
M  +1    -0    core/libs/database/coredb/coredbconstants.h
M  +137  -13   core/libs/database/tags/facetagseditor.cpp
M  +15   -3    core/libs/database/tags/facetagseditor.h
M  +135  -28   core/libs/database/tags/facetagsiface.cpp
M  +52   -6    core/libs/database/tags/facetagsiface.h
M  +29   -28   core/libs/facesengine/recognition/faceclassifier.cpp
M  +17   -11   core/libs/facesengine/recognition/faceclassifier.h
M  +2    -0    core/libs/facesengine/recognition/faceclassifierbase.cpp
M  +2    -0    core/libs/facesengine/recognition/faceclassifierbase.h
M  +35   -36   core/libs/facesengine/recognition/identityprovider.cpp
M  +4    -1    core/libs/facesengine/widgets/facescansettings.cpp
M  +8    -6    core/libs/mlfoundation/mlclassifierfoundation.h
M  +4    -3    core/libs/tags/autoassignment/classifiers/minmax/autotagsclassifierminmax.cpp
M  +10   -8    core/libs/tags/autoassignment/classifiers/minmax/autotagsclassifierminmax.h
M  +9    -5    core/libs/tags/autoassignment/classifiers/multiclassyolo/autotagsclassifiermultiyolo.h
M  +5    -3    core/libs/tags/autoassignment/classifiers/softmax/autotagsclassifiersoftmax.cpp
M  +10   -8    core/libs/tags/autoassignment/classifiers/softmax/autotagsclassifiersoftmax.h
M  +25   -0    core/utilities/facemanagement/database/faceutils.cpp
M  +10   -1    core/utilities/facemanagement/database/faceutils.h
M  +44   -20   core/utilities/facemanagement/pipelines/detectrecognize/facepipelinedetectrecognize.cpp
M  +73   -39   core/utilities/facemanagement/pipelines/edit/facepipelineedit.cpp
M  +7    -0    core/utilities/facemanagement/pipelines/edit/facepipelineedit.h
M  +15   -0    core/utilities/facemanagement/pipelines/facepipelinebase.cpp
M  +1    -0    core/utilities/facemanagement/pipelines/facepipelinepackagebase.h
M  +27   -29   core/utilities/facemanagement/pipelines/recognize/facepipelinerecognize.cpp
M  +1    -0    project/bundles/homebrew/02-build-extralibs.sh
M  +2    -0    project/bundles/homebrew/03-build-digikam.sh
M  +11   -8    project/bundles/homebrew/config.sh

https://invent.kde.org/graphics/digikam/-/commit/499d41cee5f7422e9951ed9c097d898568f7046d
Comment 30 Michael Miller 2025-04-18 12:24:29 UTC
(In reply to MarcP from comment #27)
> I see — it would require a major change in how face detection is currently
> handled. That’s totally fine; I’m just glad the suggestion is on your radar.
> For now, I’ll stick with marking faces as ignored.
> 
> Just one last question: can the background scan still modify faces that are
> already being suggested to someone, or does it only affect faces that
> haven’t been suggested yet? Hopefully it is the former, so they are
> automatically reassigned without me having to reject them first.

Hi Marc,
I thought about the idea of saving rejected faces so they aren't matched again and I came up with a solution.  This should be in the next daily build. I hope you'll try it out.

Cheers,
Mike
Comment 31 MarcP 2025-04-18 12:33:57 UTC
Sure! I'll be happy to test it.
Comment 32 MarcP 2025-04-19 18:13:38 UTC
Hi,

I tested the new build, and it seems to work quite well. Rejections do not get reassigned to the same person, which is perfect. Thanks for implementing this feature, it's really a quality of life improvement to Digikam.

Just one note, though. I noticed that today, after tagging and rejecting some faces, a lot of data was transferred in my daily backup. Does the rejection information gets saved in the image metadata?
Comment 33 Michael Miller 2025-04-19 18:28:34 UTC
(In reply to MarcP from comment #32)
> Hi,
> 
> I tested the new build, and it seems to work quite well. Rejections do not
> get reassigned to the same person, which is perfect. Thanks for implementing
> this feature, it's really a quality of life improvement to Digikam.
> 
> Just one note, though. I noticed that today, after tagging and rejecting
> some faces, a lot of data was transferred in my daily backup. Does the
> rejection information gets saved in the image metadata?

Hi Marc,
I'm glad you like it and you find it useful.

No, rejection information is not saved to image metadata yet.  That will happen next week.  Right now I'm working on a way to clear the saved rejection data in case a user makes a mistake.

Cheers,
Mike
Comment 34 MarcP 2025-04-19 18:40:52 UTC
I see. However, I just did a test, and whenever I reject a faces from an image, the file gets modified, so something must be written into it. I'd personally prefer if rejection information (just like ignored faces) is just stored in the database.
Comment 35 MarcP 2025-04-19 20:12:17 UTC
I left digikam alone while I was having lunch, and a few minutes later I see that it modified around 3000 pictures (about 7GB) during a background face recognition scan. Looks like the background scan itself is modifying pictures in some way. I sync my library against a NAS over internet so it's generating a lot of traffic.