Bug 506432 - At each startup, FaceClassifier::loadTrainingData keeps the CPU at high usage for 10 minutes.
Summary: At each startup, FaceClassifier::loadTrainingData keeps the CPU at high usage...
Status: RESOLVED DUPLICATE of bug 504185
Alias: None
Product: digikam
Classification: Applications
Component: Faces-Engine (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-07-01 11:37 UTC by Theliel
Modified: 2025-12-10 08:44 UTC (History)
5 users (show)

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


Attachments
LOG (41.35 KB, text/plain)
2025-07-01 11:37 UTC, Theliel
Details
Behavior Settings (67.32 KB, image/png)
2025-07-01 12:55 UTC, Theliel
Details
8.9.0 build with the same hight CPU usage | facesengine: FaceClassifier::loadTrainingData (12.51 KB, text/plain)
2025-12-10 01:46 UTC, Theliel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Theliel 2025-07-01 11:37:25 UTC
Created attachment 182830 [details]
LOG

SUMMARY

Digikam spikes CPU usage for about 10 minutes after each startup, possibly due to face detection training.

On the other hand, whether related or not, once the Digikam application is closed, the process remains active, always requiring a manual kill.


STEPS TO REPRODUCE
1. Open Digikam and wait
2. Once the CPU usage has stabilized, the application is closed.
3. 


OBSERVED RESULT

For a few months now, I can't say for sure exactly how long, every time I start Digikam, it maintains a high CPU usage. I don't need to do anything, just open it. The first few minutes were at 13% (8 logical cores), the rest at over 90%.

After several minutes (about 10 minutes), it stabilizes.

The Digikam log (attached in the bug) shows that the culprit is a thread that always runs at every startup. From the message it displays, does it seem like it runs some face training every startup.

12:39:36 [14492] digikam.general: Finish Main Thread
12:39:36 [14492] digikam.general: Finish Main Thread
12:39:36 [14492] digikam.general: Finish Main Thread
12:50:39 [14492] digikam.facesengine: FaceClassifier::loadTrainingData: SVM calcError is: 3.495465
12:50:39 [14492] digikam.facesengine: FaceClassifier::loadTrainingData: training completed in 346167 ms

Just after the thread terminates, CPU usage drops to 0%. The new background face recognition scan option option was disabled just in case that was the culprit.

For approximately the same amount of time, although I cannot guarantee that it coincides in time, nor that it is the same problem, once I close Digikam, the process remains active indefinitely (Without CPU usage, but with the relevant memory consumption), forcing me to "kill" the process manually.

For approximately the same amount of time, although I can't guarantee the exact timing or that it's the same issue, once I close Digikam, the process remains active indefinitely (without CPU usage, but with the appropriate memory consumption), forcing me to "kill" the process manually.

In this case, the only thing the Digikam registry shows (since it is closed):

12:39:36 [14492] digikam.general: Finish Main Thread
12:39:36 [14492] digikam.general: Finish Main Thread
12:39:36 [14492] digikam.general: Finish Main Thread
12:50:39 [14492] digikam.facesengine: FaceClassifier::loadTrainingData: SVM calcError is: 3.495465
12:50:39 [14492] digikam.facesengine: FaceClassifier::loadTrainingData: training completed in 346167 ms
12:54:45 [14492] digikam.mlpipelinefoundation: Total Elapsed: 918924
12:54:45 [14492] digikam.facesengine: IdentityProvider::cancel: sent queue end signal
12:54:45 [14492] digikam.facesengine: IdentityProvider::trainingRemoveConcurrent thread exited
12:54:45 [14492] digikam.facedb: Remove queue destroyed
12:54:45 [14492] digikam.facesengine: FaceClassifier::cancel: cancel complete
12:54:45 [14492] digikam.geoiface: ----
12:54:45 [14492] digikam.mlpipelinefoundation: Total Elapsed: 918940
12:54:45 [14492] digikam.mlpipelinefoundation: Total Elapsed: 918940
12:54:45 [14492] digikam.mlpipelinefoundation: Total Elapsed: 918940
12:54:45 [14492] digikam.general: Cancel Main Thread
12:54:45 [14492] digikam.general: Finish Main Thread
12:54:45 [14492] qt.multimedia.ffmpeg.mediadataholder: Could not open media. FFmpeg error description: "Immediate exit requested"
12:54:45 [14492] digikam.mlpipelinefoundation: Total Elapsed: 919356
12:54:46 [14492] digikam.metaengine: ExifToolProcess::shutDown(): send ExifTool shutdown command...
12:54:46 [14492] digikam.metaengine: ExifTool process finished with code: 0 and status QProcess::NormalExit
12:54:46 [14492] Failed to stop audio engine -2004287487


EXPECTED RESULT

Logic tells us that training shouldn't be done constantly every time the application is launched. This has been happening for several months; it didn't happen before. Likewise, when the application is closed, it should terminate all threads/processes.

SOFTWARE/OS VERSIONS
Windows: W11
Comment 1 caulier.gilles 2025-07-01 11:59:31 UTC
*** Bug 505619 has been marked as a duplicate of this bug. ***
Comment 2 caulier.gilles 2025-07-01 12:02:31 UTC
Take a look at Setup/Misc/Behaviour about the options to run process at startup :

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

Gilles Caulier
Comment 3 Theliel 2025-07-01 12:52:59 UTC
(In reply to caulier.gilles from comment #2)
> Take a look at Setup/Misc/Behaviour about the options to run process at
> startup :
> 
> https://docs.digikam.org/en/setup_application/miscs_settings.html#behavior-
> settings
> 
> Gilles Caulier

Hi Gilles,  

I've already checked, but currently only "Detect faces in newly added images" is selected. I've also verified that disabling it has no impact on the problem.

Scan for new items at startup, background face recognition scan, and Remove obsolete core database are (all of them) disabled.
Comment 4 Theliel 2025-07-01 12:55:41 UTC
Created attachment 182834 [details]
Behavior Settings
Comment 5 caulier.gilles 2025-07-01 13:09:41 UTC
Hi Michael,

We have 2 problems here :

- FaceClassifier::loadTrainingData is always enabled at startup and cannot be turned off.
- When FaceClassifier::loadTrainingData is turned on, a shutdown do not close it, and a manual kill is required.

Best

Gilles
Comment 6 caulier.gilles 2025-07-01 14:58:06 UTC
Maik,

I suspect a problem with this setting which is not properly saved/read from config file :

https://invent.kde.org/graphics/digikam/-/blob/master/core/utilities/facemanagement/backgroundprocesses/facebackgroundrecognition.cpp?ref_type=heads#L64

See also the long comment in this constructor...

Gilles
Comment 7 caulier.gilles 2025-12-09 15:57:03 UTC
Hi Theliel,

Please disable the option "Enable background face recognition scan"

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

I recommend also to try using 8.9.0 pre-release installer available here : 

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

Best regards

Gilles Caulier
Comment 8 Theliel 2025-12-10 01:42:05 UTC
(In reply to caulier.gilles from comment #7)
> Hi Theliel,
> 
> Please disable the option "Enable background face recognition scan"
> 
> https://docs.digikam.org/en/setup_application/miscs_settings.html#behavior-
> settings
> 
> I recommend also to try using 8.9.0 pre-release installer available here : 
> 
> https://files.kde.org/digikam/
> 
> Best regards
> 
> Gilles Caulier

Same Gilles, the same behavior, and yes, "Enable background face recognition scan" is disabled (double checked)

Tested with latest digiKam-8.9.0-20251209T180151-Qt6-Win64. Attached new log, but its pretty the same (stripped useless lines, like addons and other stuff)

Resume:

00000001	02:12:53	[24464] digikam.widgets: Breeze icons resource file found	
00000002	02:12:53	[24464] digikam.general: Qt standard translations removed: 16	
00000003	02:12:53	[24464] digikam.general: Qt standard translations path: "C:/Program Files/digiKam/translations"	
00000004	02:12:53	[24464] digikam.general: Loaded Qt standard translations "es_ES" from catalog "qt"	
...
00000131	02:12:55	[24464] digikam.facedb: FaceDB SelectFaceSetting val ret = 0	
00000132	02:12:55	[24464] digikam.facedb: FaceDB SelectFaceSetting val ret = 0	
00000133	02:12:55	[24464] digikam.facedb: Face database: have a structure version  "6"	
00000284	02:12:56	[24464] digikam.facesengine: FaceClassifier::loadTrainingData: face classifier is ready to use with full search in  203 ms	
00000307	02:12:56	[24464] digikam.general: void __cdecl Digikam::DPluginLoader::Private::loadPlugins(void) Time elapsed: 223 ms	
00000308	02:12:56	[24464] digikam.dnnmodelmanager: Using OpenCV backend and OpenCL target	
00000309	02:12:56	[24464] digikam.facesengine: Extractor model: "SFace"	
00000310	02:12:56	[24464] digikam.dnnmodelmanager: Using OpenCV backend and OpenCL target	
00000311	02:12:56	[24464] digikam.facesengine: Recognition model: "YuNet"	
...
00000390	02:13:02	[24464] digikam.database: Search result: 1142	
00000391	02:13:02	[24464] digikam.general: One job is done Digikam::DatesJob(0x1b55582f020) time: 4318	
00000392	02:13:02	[24464] digikam.general: One job is done Digikam::TagsJob(0x1b5538c2230) time: 2502	
00000393	02:13:03	[24464] digikam.general: Cancel Main Thread	
00000394	02:13:03	[24464] digikam.general: One job is done Digikam::TagsJob(0x1b5709bb960) time: 1477	
00000395	02:13:04	[24464] digikam.facedb: FaceDB SelectFaceSetting val ret = 0	
00000396	02:13:04	[24464] digikam.facedb: FaceDB SelectFaceSetting val ret = 0	
00000397	02:13:04	[24464] digikam.geoiface: ----	
00000398	02:13:04	[24464] digikam.general: Finish Main Thread	
00000399	02:13:04	[24464] digikam.general: Finish Main Thread	
00000400	02:13:04	[24464] digikam.general: Finish Main Thread	
00000401	02:13:04	[24464] digikam.general: Finish Main Thread	
00000402	02:13:04	[24464] digikam.general: Finish Main Thread	
00000403	02:13:04	[24464] digikam.general: Finish Main Thread	
00000404	02:13:04	[24464] digikam.general: Finish Main Thread	
00000490	02:23:31	[24464] digikam.facesengine: FaceClassifier::loadTrainingData: SVM calcError is:  3.533698	
00000491	02:23:31	[24464] digikam.facesengine: FaceClassifier::loadTrainingData: training completed in  326627 ms	

---------------
Comment 9 Theliel 2025-12-10 01:46:23 UTC
Created attachment 187481 [details]
8.9.0 build with the same hight CPU usage |  facesengine: FaceClassifier::loadTrainingData
Comment 10 Maik Qualmann 2025-12-10 08:44:49 UTC

*** This bug has been marked as a duplicate of bug 504185 ***