Bug 464266 - Face detection is extremely slow - face recognition is almost impossible
Summary: Face detection is extremely slow - face recognition is almost impossible
Status: REPORTED
Alias: None
Product: digikam
Classification: Applications
Component: Faces-Detection (show other bugs)
Version: 7.9.0
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-14 11:24 UTC by weimawei
Modified: 2024-02-26 18:40 UTC (History)
8 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
result of detection (345.87 KB, image/png)
2023-01-23 18:08 UTC, Andy
Details

Note You need to log in before you can comment on or make changes to this bug.
Description weimawei 2023-01-14 11:24:32 UTC
Dear Sir or Madam,
I have noticed that in the face recognition for my wife only about 40 images were recorded. this is clearly too few for a good 50 years of image collection. 
I tried to let the "discover faces", but canceled it after a few hours because no movement has shown still 0%.

Afterwards with "Recognize faces" the process was relatively fast finished, but has shown no success.

Then I deleted all person keywords.
Let the "Detect faces" run for many hours until about 3% were displayed.
Then "Detect faces" showed about 1300 unknown faces. I assigned about 600 of them. 
I thought now enough faces are known and "Detect" turned on, but except for 6 faces, the unknowns did not decrease, even though they are the same faces I have named hundreds of times.
To add the person keyword to each face individually does not require a face recognition program.

Am I doing something wrong?
Does "discovering faces" really take that long? I would have to run my PC for days with it!
And then the software doesn't recognize the faces.

What do I have to do?

Thanks a lot

With kind regards

Manfred Weidenmüller

Please tell me how to make it easier.   




STEPS TO REPRODUCE
1. 
2. 
3. 

OBSERVED RESULT


EXPECTED RESULT


SOFTWARE/OS VERSIONS
Edition	Windows 11 Pro
Version	22H2
Installiert am	‎07.‎10.‎2022
Betriebssystembuild	22621.1105
Leistung	Windows Feature Experience Pack 1000.22638.1000.0


ADDITIONAL INFORMATION
Comment 1 Andy 2023-01-23 13:51:07 UTC
Hi!
I have the same problem. It takes a long time to start, but faces are recognized.
After that I assigned many of the same faces to the name. If I then start a process of recognizing faces, the remaining faces are not automatically linked. I still have to assign everything manually.

I also use Picasa for testing. Here the recognition of the old program is still best and fastest.
MS Photos also takes a little longer to recognize. The administration of people/contacts is cumbersome here. Program crashes happen. Photos are not found in the folders and displayed in the timeline.....

Regards
Andy
Comment 2 Andy 2023-01-23 18:08:07 UTC
Created attachment 155536 [details]
result of detection
Comment 3 Andy 2023-01-23 18:12:31 UTC
Hi!
Here is another face recognition result. None of the faces found were recognized correctly. Maybe it's because of the scan resolution of the photos.
There are also many faces that can no longer be recognized as faces. ;-)
Regards
Andy
Comment 4 Aaron C. de Bruyn 2023-02-07 15:26:04 UTC
I'm tried using the package available under Mint 21.1 and the entire application was super slow.
I download the updated AppImage version digiKam-7.8.0-x86-64.appimage and tried it and speeds were better, but the app constantly pops up the "not responding" box and asks if I want to "wait" for "force quit".

Face recognition seems pretty slow, and the application core dumps a lot.

My box is an 8-core 3.6 GHz machine with 128 GB RAM and DigiKam is constantly eating up all the RAM, then maxing out the swapfile, then crashing.

I tried moving to an "internal MySQL" database and it's still terribly slow.

My photo storage is an external RAIDZ2 ZFS array and I'm able to read at over 900 MB/sec and write at over 500 MB/sec, so I don't think it's a performance issue with my machine.
Comment 5 caulier.gilles 2023-02-07 15:40:23 UTC
Here i tried to rebuild whole face database with my 60.000 files. yes it take a while to detect but it still suitable.

Recognition is more an idle process, i agree, but no crash. 

If fact the memory leak is due to an OpenCV bug. We have a wrap around in next 7.10.0 pre-release.

See the small screen-cast an screen-shots here done on my computer :  https://docs.digikam.org/en/main_window/people_view.html

i7 (2012) + 32 Gb + SSD

Gilles Caulier
Comment 6 nick 2023-04-30 20:47:41 UTC
Same issue on 8.1.
Debug view shows about 10s per image.
3800 images and one hour later it is at 1%.
Picasa is one million times faster.

Tried all different settings, including enabling OpenCL and it's exactly the same.
Comment 7 Maik Qualmann 2023-04-30 20:58:29 UTC
I'm guessing you're using Yolo-V3 face detection, which is significantly slower than the SSD model, which is fine for most things.

Maik
Comment 8 nick 2023-04-30 21:07:50 UTC
SSD model hangs on 2nd image and never progresses.
Comment 9 Maik Qualmann 2023-04-30 21:09:55 UTC
Which digiKam version under which OS?

Maik
Comment 10 nick 2023-04-30 21:14:06 UTC
Update. SD hangs on image #2 when "Work on all processor cores" is enabled.
It progresses when set to single thread.

Win 11 x64
Digicam 8.1
Comment 11 nick 2023-05-04 18:42:52 UTC
Intel i9-11900k (8 core) w/64GB w/SSD on Windows 11 x64

"Work on all processor cores" enabled is taking almost 2 minutes to scan one image with Yolo-V3

1:29:27.144 [11568] digikam.general: Try to get preview from "C:/Users/nick/Pictures/For Us/2008-11-30 22.36.49.jpg"
...
1:31:22.709 [11568] digikam.general: Found 1 faces in "2008-11-30 22.36.49.jpg" QSize(2000, 1500) QSize(3072, 2304)

Digikam is spawning 6 threads, each analyzing a different image, regardless if "Work on all processor cores" is enabled or not.

Work on all processor cores Enabled: During scan, DigiKam.exe is using 10%-56% of my CPU. Which is, rougly, 4 cores at 100%
Work on all processor cores Disabled: During scan, DigiKam.exe is using 10%-24% of my CPU. Which is, at most, 2 cores at 100%
Digikam also fluctuates between those low and high percentages, only sitting at maximum for about half the time.

Interestingly, Digikam seems to open many more files (20?) than 6 at once, but only performce face detection on 6 at once:
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item34.jpg"
[16920] digikam.general: Found 1 faces in "s.char.jpg" QSize(320, 419) QSize(320, 419)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item35.jpg"
[16920] digikam.general: Found 0 faces in "s.bank.jpg" QSize(800, 640) QSize(800, 640)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item36.jpg"
[16920] digikam.general: Found 1 faces in "s.honor.jpg" QSize(320, 418) QSize(320, 418)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item37.jpg"
[16920] digikam.general: Found 0 faces in "s.item10.jpg" QSize(213, 84) QSize(213, 84)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item38.jpg"
[16920] digikam.general: Found 0 faces in "s.item1.jpg" QSize(200, 58) QSize(200, 58)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item39.jpg"
[16920] digikam.general: Found 0 faces in "s.item11.jpg" QSize(202, 87) QSize(202, 87)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item4.jpg"
[16920] digikam.general: Found 0 faces in "s.item13.jpg" QSize(208, 83) QSize(208, 83)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item40.jpg"
[16920] digikam.general: Found 0 faces in "s.item12.jpg" QSize(196, 101) QSize(196, 101)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item41.jpg"
[16920] digikam.general: Found 0 faces in "s.item14.jpg" QSize(218, 336) QSize(218, 336)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item42.jpg"
[16920] digikam.general: Found 0 faces in "s.item16.jpg" QSize(213, 325) QSize(213, 325)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item43.jpg"
[16920] digikam.general: Found 0 faces in "s.item15.jpg" QSize(209, 369) QSize(209, 369)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item44.jpg"
[16920] digikam.general: Found 0 faces in "s.item17.jpg" QSize(209, 357) QSize(209, 357)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item45.jpg"
[16920] digikam.general: Found 0 faces in "s.item19.jpg" QSize(209, 356) QSize(209, 356)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item46.jpg"
[16920] digikam.general: Found 0 faces in "s.item18.jpg" QSize(215, 368) QSize(215, 368)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item47.jpg"
[16920] digikam.general: Found 0 faces in "s.item2.jpg" QSize(215, 128) QSize(215, 128)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item48.jpg"
[16920] digikam.general: Found 0 faces in "s.item21.jpg" QSize(213, 358) QSize(213, 358)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item49.jpg"
[16920] digikam.general: Found 0 faces in "s.item20.jpg" QSize(213, 367) QSize(213, 367)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item5.jpg"
[16920] digikam.general: Found 0 faces in "s.item22.jpg" QSize(213, 137) QSize(213, 137)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item50.jpg"
[16920] digikam.general: Found 0 faces in "s.item24.jpg" QSize(183, 69) QSize(183, 69)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item51.jpg"
[16920] digikam.general: Found 0 faces in "s.item23.jpg" QSize(215, 146) QSize(215, 146)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item52.jpg"
[16920] digikam.general: Found 0 faces in "s.item25.jpg" QSize(213, 103) QSize(213, 103)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item53.jpg"
[16920] digikam.general: Found 0 faces in "s.item27.jpg" QSize(158, 63) QSize(158, 63)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item54.jpg"
[16920] digikam.general: Found 0 faces in "s.item26.jpg" QSize(202, 103) QSize(202, 103)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item55.jpg"
[16920] digikam.general: Found 0 faces in "s.item28.jpg" QSize(143, 36) QSize(143, 36)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item56.jpg"
[16920] digikam.general: Found 0 faces in "s.item3.jpg" QSize(212, 72) QSize(212, 72)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item57.jpg"
[16920] digikam.general: Found 0 faces in "s.item29.jpg" QSize(214, 372) QSize(214, 372)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item58.jpg"
[16920] digikam.general: Found 0 faces in "s.item30.jpg" QSize(211, 385) QSize(211, 385)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item59.jpg"
[16920] digikam.general: Found 0 faces in "s.item32.jpg" QSize(152, 131) QSize(152, 131)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item6.jpg"
[16920] digikam.general: Found 0 faces in "s.item31.jpg" QSize(214, 412) QSize(214, 412)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item60.jpg"
[16920] digikam.general: Found 0 faces in "s.item33.jpg" QSize(157, 105) QSize(157, 105)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item61.jpg"
[16920] digikam.general: Found 0 faces in "s.item35.jpg" QSize(209, 88) QSize(209, 88)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item7.jpg"
[16920] digikam.general: Found 0 faces in "s.item34.jpg" QSize(207, 117) QSize(207, 117)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item8.jpg"
[16920] digikam.general: Found 0 faces in "s.item36.jpg" QSize(203, 66) QSize(203, 66)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.item9.jpg"
[16920] digikam.general: Found 0 faces in "s.item38.jpg" QSize(212, 168) QSize(212, 168)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.portrait.jpg"
[16920] digikam.general: Found 0 faces in "s.item37.jpg" QSize(202, 133) QSize(202, 133)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.rep1.jpg"
[16920] digikam.general: Found 0 faces in "s.item39.jpg" QSize(192, 141) QSize(192, 141)
[16920] digikam.general: Try to get preview from "C:/Users/nick/Pictures/Auctions/list/wow/s.rep2.jpg"

The parallelization and utilization of all cores seems to be inefficient.
Comment 12 nick 2023-05-05 00:13:15 UTC
YOLOFace
https://github.com/sthanhng/yolofacea
Using this repo, it takes 2s to recognize faces in each of my photos.
Comment 13 caulier.gilles 2023-05-05 03:44:13 UTC
Your github link is broken...
Comment 14 caulier.gilles 2023-05-05 03:46:45 UTC
You want mean this repo : https://github.com/sthanhng/yoloface ?
Comment 15 nick 2023-05-05 09:41:19 UTC
Yes, sorry for the typo.
Comment 16 caulier.gilles 2023-10-15 08:12:16 UTC
@nick@nickme.com,

This problem still reproducible with the new digiKam 8.2.0 pre-release Windows
installer available at usual place:

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

This new bundle is based on last Qt framework 5.15.11 and KDE framework 5.110.

Do you experiment the Yolo DNN model ?

Thanks in advance

Gilles Caulier
Comment 17 atoms 2024-01-14 07:42:35 UTC
I seriously don't think we will get speed until we get working GPU support.  Even with working GPU support face recognition across many images can be slow, but my experience is it's probably still at least 10-100 times faster.  At least if we had that, we wouldn't have to wait four days to find out it didn't work.  This should be our number one priority in my opinion.  I can help test with Mac, Windows, Linux and an Nvidia GPU.
Comment 18 nick 2024-01-14 12:37:43 UTC
https://github.com/akanametov/yolov8-face can do face recognition with cuda. I know it's implementation is in python.
I agree, support for performing face recognition on GPU in Digikam would be essential as it runs 20-40 times faster from what google is telling me.
Comment 19 caulier.gilles 2024-01-14 12:41:22 UTC
GPU support is already done through OpenCV library used by the DNN. There is an option in digiKam Setup/Misc dialog tab to turn on this feature (OpenCL):

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

Gilles Caulier
Comment 20 atoms 2024-01-14 19:24:26 UTC
I think everyone is aware that there is the option for GPU support, however it doesn't work.  The option to not disable it exists, which does not mean to enable it.  I assume it to mean that if your system has supported hardware and the right software libraries then it may choose to use it.

The problem is there is no documentation either (also a common complaint).  So while it may work, I have found no-one that understands how to make it work.  It may be that it requires some kind of extra open-cv library (which I did try on Windows).  Nothing I tried resulted in any extra speed from CPU processing on either Mac or Windows.  I did not try linux yet as I couldn't get 8.3 for it easily.  

And the terminology is far from clear.  Instead of 'Disable hardware acceleration OpenCL', we really need something that says the opposite 'enable hardware acceleration openCL'.

Also, on Mac, as far as I know, OpenCL is deprecated and no longer available.  https://developer.apple.com/documentation/metal/metal_sample_code_library/migrating_opengl_code_to_metal
So it's not going to work there anyway, until we get Metal support.

So to add to my list of priorities, I would say GPU support 'with proper documentation and requirements'.

In the mean time, the solution seems to be download a trial version of Lightroom and do it there, then export to XMP and re-import into Digikam.  I've just done it and it's unbelievably fast by comparison.
Comment 21 caulier.gilles 2024-01-14 19:40:02 UTC
Hi,

As all the face detection/recognition uses OpenCV in background (the neural network is based on this), the famous OpenCL option enable or not the support of GPU in OpenCV computation.

If you look in OpenCV doc, all is explained.

https://opencv.org/opencl/

There are others GPU option in OPenCV, for ex with NVIDIA cards.

About the Apple, the GPU is proprietary, so, i'm not sure that OpenCV can already support this.

In all cases, there is NO plan to introduce Pythin code in digiKam. This is a C++ project, and it's already difficult to maintain 1.5M of code lines, so to support Python, no way.

The DNN used in face engine is based on OpenCV. So the solution is located in this library (the code must be compiled with GPU support in your computer, as all is optional in OpenCV).

If there is other GPU options from OpenCV to support, sure this must be done. You are invited to contribute and to create a merge resquest over the digiKam code as explained in contribute page :

https://www.digikam.org/contribute/

Best regards

Gilles Caulier
Comment 22 atoms 2024-01-14 20:33:26 UTC
We do know about opencv support in Mac.  That's why I posted the link.  It is no longer supported.

The document you linked is completely unhelpful.  What we need is the documentation to explain exactly what supporting libraries need to be installed to make this work.  Someone knows.  But so far I've not been able to find any information on how to get it to work.  In contrast I've found dozens of threads on here, on reddit and elsewhere all complaining about the same things.  It doesn't work and it is slow.  No pointing people at code is going to answer these questions.  I am not a developer even if I am extremely technical, code is not something that I can read.

I understand already that opencv is mean to be able to work on all OS's (though not Mac any longer), but if it's not working it's pointless.

At the end of the day, users of this software don't care about the technology, just a working solution, which we currently don't have.
Comment 23 Theliel 2024-02-26 03:42:32 UTC
Facial Recognition has evolved enormously, especially since the inclusion of Yolo-v3 (DNN barely recognizes me people, for me Yolo-v3 is mandatory). It is true that Yolo-v3 is slower than DNN, but currently the detection speed is more than acceptable. I just ran a couple of tests on a folder of 402 photos I had, almost all portraits and posed:

(win11, 7700k, 4060ti)
Yolo-v3: About 3pps (About 10,800 photos per hour)
DNN: About 4pps

Probably with CUDA it would be much faster, but I think they are acceptable times. On the other hand, if Apple wants to get rid of OpenCL to force developers to use Metal, it is a totally different matter, it is not precisely the fault of Digikam's dev. This is an open source project, if it were that easy to implement a new API, anyone could do it then... and that's obviously not the case.

Currently as far as I know, OpenCV does not support Metal (and may not support it in the near future). The only way would be through Vulkan and MoltenVK, and it remains to be seen the performance in comparison.
Comment 24 atoms 2024-02-26 04:10:03 UTC
Perhaps it has but it doesn't mean my reports and the many many others are not valid.  I fail to see the purpose of your coming on here other than you seem to want to tell us we're wrong - which we're not.  By the way I also tried Windows with same result.  I'm pretty sure this is OS agnostic and you have a different use case, you certainly don't have many photographs in this example. Perhaps we can stay on topic and focus on the actual bug report instead of trying to list opposing opinions.  It's either a bug or it isn't.

I'm sorry if this sounds harsh, I do not mean to offend but you have caught me at a time when I find a lot of people jumping in and trying to say their opinion and say that therefore it invalidates the ticket and to close it.  Perhaps you are not doing that'd I'm just grumpy today. :)

I also mentioned open cv is not supported just two posts up - doesn't seem you read that.
Comment 25 weimawei 2024-02-26 16:31:55 UTC
Hello atoms@electropositive.net

I only wrote once about facial recognition , that was in January 2023.
I also got an answer from Andy, which I was happy with.

The other participants who contacted you about this have nothing to do 
with me.
I am completely satisfied with digikam.

Did the comments somehow end up on my account?

I think you are all doing a very good job.

Yours sincerely
Manfred Weidenmüller

Translated with www.DeepL.com/Translator (free version)

Am 26.02.2024 um 05:10 schrieb bugzilla_noreply@kde.org:
> https://bugs.kde.org/show_bug.cgi?id=464266
>
> --- Comment #24 from atoms@electropositive.net ---
> Perhaps it has but it doesn't mean my reports and the many many others are not
> valid.  I fail to see the purpose of your coming on here other than you seem to
> want to tell us we're wrong - which we're not.  By the way I also tried Windows
> with same result.  I'm pretty sure this is OS agnostic and you have a different
> use case, you certainly don't have many photographs in this example. Perhaps we
> can stay on topic and focus on the actual bug report instead of trying to list
> opposing opinions.  It's either a bug or it isn't.
>
> I'm sorry if this sounds harsh, I do not mean to offend but you have caught me
> at a time when I find a lot of people jumping in and trying to say their
> opinion and say that therefore it invalidates the ticket and to close it.
> Perhaps you are not doing that'd I'm just grumpy today. :)
>
> I also mentioned open cv is not supported just two posts up - doesn't seem you
> read that.
>
Comment 26 Theliel 2024-02-26 18:40:35 UTC
The bug was opened due to speed problems when using facial detection. My comment was to point out that, at least with my equipment, as of today, the performance is adequate with about 2-3pps. I have not talked at any time about closing the bug, I have simply shown the results that I currently obtain

For me at least, OpenCL works. It's not a dramatic improvement as long as it doesn't multiply the speed X times, but it works. Whether the performance is adequate or not would be a totally different debate. Obviously any improvement that can be made to it is welcome, and that is when Gilles himself encourages anyone who wants to collaborate and improve the current code.

Obviously 404 photos is not an important sample, I have simply used it as a test. My current library is about 200k photos, there are currently about 150k people tags (about 600 different people), and another 80k detected and ignored. As you will understand, in my use, the speed to detect and identify is quite important.

Greetings.