Bug 507341 - Rebuilding face recognition database is very slow on 8.7.0
Summary: Rebuilding face recognition database is very slow on 8.7.0
Status: REPORTED
Alias: None
Product: digikam
Classification: Applications
Component: Faces-Recognition (other bugs)
Version First Reported In: 8.7.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-07-22 07:26 UTC by pinoaffe
Modified: 2025-12-11 02:14 UTC (History)
2 users (show)

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


Attachments
guix package / build instructions for digikam (11.08 KB, text/x-scheme)
2025-07-22 07:26 UTC, pinoaffe
Details
Log of rebuilding face recognition db after disabling "Enable Background Recognition..." (66.42 KB, text/x-log)
2025-07-22 09:32 UTC, pinoaffe
Details

Note You need to log in before you can comment on or make changes to this bug.
Description pinoaffe 2025-07-22 07:26:05 UTC
Created attachment 183412 [details]
guix package / build instructions for digikam

I recently updated to 8.7.0, and am trying to rebuild my face recognition database, this is painstakingly slow.   Previously, this would take a few hours at most, but after leaving it running overnight it's still at 0%. 

STEPS TO REPRODUCE
I don't know exactly how to reproduce it, but i've attached the Guix build specifications I've used to build it.  If you have a recent gnu guix available running `guix shell -f digikam.scm -- digikam` should build and run digikam, after which one can rebuild the face recognition database via tools/management


OBSERVED RESULT
The progress bar for the face recognition database rebuild is still at 0% after running for 15 hours.
I've manually taken a look at what happens to the recognition database, and it seems like digikam is (very) slowly adding entries to the FaceMatrices table - after running for 15 hours, it has 11k entries, whereas I've tagged 30k faces, so I expect that this would take at least another full day.


EXPECTED RESULT
Face recognition database is rebuilt within a reasonable amount of time

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Running on Guix
KDE Plasma Version: ?
KDE Frameworks Version: 5.116.0
Qt Version: 5.15.15

ADDITIONAL INFORMATION
I'm on a 13th gen intel i5-1340P with 32GB of ram, so I wouldn't expect this to be caused by insufficient system specs.
Comment 1 caulier.gilles 2025-07-22 08:03:18 UTC
In 8.7.0, an option from Setup/Misc/Behavior was enabled by default, where it introduce large time latency: "Enable Background Recognition..."

https://docs.digikam.org/en/setup_application/miscs_settings.html#behavior-settings

Disable this option and try again.

In next 8.8.0, this option is disabled by default. We have also fixed some other problem in the face management. If you want to test, a Linux AppImage bundle is available here:

https://files.kde.org/digikam/

Best regards

Gilles Caulier
Comment 2 Maik Qualmann 2025-07-22 09:07:59 UTC
It's not normal that there's no progress after hours. I suspect a problem with the face database update. What database system are you using? If you're using MySQL, please specify the exact version.

Maik
Comment 3 pinoaffe 2025-07-22 09:10:46 UTC
@Maik I'm using sqlite
Comment 4 Maik Qualmann 2025-07-22 09:14:21 UTC
Then please create a log of the debug output in the terminal when you rebuild the face database as described here for Linux:

https://www.digikam.org/contribute/#linux-host

Maik
Comment 5 pinoaffe 2025-07-22 09:32:59 UTC
Created attachment 183417 [details]
Log of rebuilding face recognition db after disabling "Enable Background Recognition..."
Comment 6 pinoaffe 2025-07-22 09:41:19 UTC
(In reply to Maik Qualmann from comment #4)
> Then please create a log of the debug output in the terminal when you
> rebuild the face database

I've attached a (redacted) log excerpt after disabling "Enable Background Recognition..."  - the log is absolutely swamped with `QPixmap::scaled: Pixmap is a null pixmap` lines, I suspect that that has something to do with missing icons, so it should be unrelated

I suspect that the progress bar is broken, since after 5k lines matching ".... Found FacesEngine identity ....", progress is still at 0%.  With other, shorter running tasks, the progress bar also seems to be "stuck" at 0%.  Based on manual checking and guesswork, it seems like disabling "Enable Background Recognition" has sped the process up by a lot, since the FacesMatrices table has  3k entries after running for a couple of minutes, whereas it previously had 11k entries after running overnight


Perhaps also relevant: My device does not support GPU hardware acceleration, so that may also be slowing things down
Comment 7 Maik Qualmann 2025-07-22 09:50:48 UTC
Thanks, that's the cause and should have been fixed in digiKam-8.7.0 shortly before release:

QObject::connect: Cannot queue arguments of type 'MLPipelinePackageNotify::Ptr'
(Make sure 'MLPipelinePackageNotify::Ptr' is registered using qRegisterMetaType().)

This was the commit: https://invent.kde.org/graphics/digikam/-/commit/2f2a37d6dc8be3af9c2944be25aef11c2504f343

Are you really using digiKam-8.7.0 release? We may need to register the type somewhere else.

Maik
Comment 8 pinoaffe 2025-07-22 10:10:03 UTC
(In reply to Maik Qualmann from comment #7)
> Thanks, that's the cause and should have been fixed in digiKam-8.7.0 shortly
> before release:
> 
> QObject::connect: Cannot queue arguments of type
> 'MLPipelinePackageNotify::Ptr'
> (Make sure 'MLPipelinePackageNotify::Ptr' is registered using
> qRegisterMetaType().)
> 
> This was the commit:
> https://invent.kde.org/graphics/digikam/-/commit/
> 2f2a37d6dc8be3af9c2944be25aef11c2504f343
> 
> Are you really using digiKam-8.7.0 release? We may need to register the type
> somewhere else.

I built it from tag v8.7.0 (aka commit 4a1f7f83f63ee6b2dce51043027481bb2f69860f), which does appear to include the commit 2f2a3, so I don't know what's going on
Comment 9 pinoaffe 2025-07-22 14:21:36 UTC
Now that I disabled "Enable Background Recognition...", the facial recognition database was rebuilt within four hours, which I think is a reasonable time considering the number of faces and the fact that hardware acceleration isn't available.

In other words, there were two things that went "wrong": the aforementioned option which slowed down the database-rebuild, and the progress bar which remains "stuck" at 0%.  I'll try and take a look at what might be causing the latter.

Thanks a lot to the both of you!
Comment 10 caulier.gilles 2025-07-22 15:15:06 UTC
the aforementioned option which slowed down the database-rebuild : This is typically a bug as, when a scanning, the "Enable Background Recognition..." option must do nothing as all the collection are parsed. This option must be active (if turned on) only when user face-tag an image.
Comment 11 Maik Qualmann 2025-07-22 17:03:59 UTC
Git commit 87b1eb23f1ec3f29872bb5ba2833936be33d0beb by Maik Qualmann.
Committed on 22/07/2025 at 17:03.
Pushed by mqualmann into branch 'master'.

initialize AIToolsPipeline first to register the meta types

M  +2    -1    core/app/main/digikamapp.cpp

https://invent.kde.org/graphics/digikam/-/commit/87b1eb23f1ec3f29872bb5ba2833936be33d0beb
Comment 12 caulier.gilles 2025-12-11 02:14:10 UTC
pinoaffe@gmail.com

Any improvements with a recent version of digiKam as the 8.9.0 pre-release available here :

https://files.kde.org/digikam/

Gilles Caulier