Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faces: Error "Failed removing merged clusters for subject" seems to cause tagging of faces to become slow #2806

Closed
chansearrington opened this issue Oct 27, 2022 · 73 comments
Labels
help wanted Well suited for external contributors! incomplete Cannot be processed due to missing information

Comments

@chansearrington
Copy link

chansearrington commented Oct 27, 2022

Under certain conditions, inconsistent face assignments cannot be automatically resolved by the background worker, which can result in an unusually high CPU load when it is running:

  • if you use multiple browser tabs or windows for assigning faces and don't wait until saving the changes is complete, the likelihood of this problem increases, especially if you accidentally enter different names for the same face
  • another possible cause is running multiple instances (for example, parallel indexing workers started by a scheduler in the background) or modifying database content directly, as this may also lead to inconsistent faces, markers and subjects

Running the following command in a terminal can resolve problems with inconsistent data:

docker compose exec photoprism photoprism faces audit --fix

It can also be helpful to manually check for inconsistent assignments and fix them in the user interface. Alternatively, you can use the photoprism faces reset command for a clean start if you haven't invested much time in assigning faces yet.

Advanced users affected by this are welcome to privately provide us with a SQL dump of their subjects, faces, and markers database tables for debugging. Thank you very much!


1. What is not working as documented?

If there is an error of "faces: failed removing merged clusters for subject (ID)",
tagging any new faces becomes incredibly slow normally 1-3 seconds, now 2-5 minutes.
This behavior happens wether tagging a random photo through photo browser or a "new face" collection under People.

2. How can we reproduce it?

I don't know how to reproduce this error, but this is the second time that it has occurred.

The first time, I tried a bunch of a few recommendations like increasing the innodb buffersize but they didn't fix the problem.

Resetting the Face ID allowed me to tag quickly again (although it meant starting over) and it worked great over the next 60,000 photos.

Now the same error is back and the same lag is back.

Steps to reproduce the behavior:

I don't know how to FORCE the error to be created.

3. What behavior do you expect?

Some way to undo or stop the merge attempt. If a single failed removing merged cluster for a single subject can cause this much of a performance issue, make an undo button or better yet just automatically undo it. I don't know I'm just making up suggestions because I don't really know what the error means.

4. What could be the cause of your problem?

People have said this might be caused by Tagging the same person with a similar but different name. If that's true, great! It would be nice if Photo Prism stopped me from creating the conflict. or reverted the action once it realizes it is going to cause a conflict.

5. Can you provide us with example files for testing, error logs, or screenshots?

Here is a video I gave @lastzero when it happened the first time. https://1drv.ms/v/s!AjcUU9ZDJWosuu9yj-2Sf0U2_tD2tA?e=6r1SXm

6. Which software versions do you use?

(a) PhotoPrism Build Number: 220901-f493607b0

(b) Database Type & Version: MariaDB

(c) Operating System Types & Versions: Linux (Unraid + Docker)

@chansearrington chansearrington added the bug Something isn't working label Oct 27, 2022
@chansearrington
Copy link
Author

Another user had a similar experience here, and the same error.... but the thread is focused on the other error of "has ambiguous subject jr1e4i93ltym0svq" versus the failed removing failed cluster.

In both of my experiences of this happening, I have never had a "has ambiguous subject jr1e4i93ltym0svq" error.

Only "failed removing merged clusters for subject" errors.

The first time was ~10 different IDs.

This time it is only one ID causing the same performance impact.

@lastzero
Copy link
Member

Have you discovered the "photoprism faces audit" CLI command yet and the trace log mode? There's a big chance these can give you a clue as to what is wrong. It's absolutely true that failing to remove merged clusters would lead to this kind of behavior. We could be more aggressive here, but that could lead to data loss in rare cases, for example when the user provides inconsistent assignments that don't make sense.

@chansearrington
Copy link
Author

@lastzero was actually waiting for it to complete. Here's the audit log

CleanShot 2022-10-26 at 21 59 47@2x

@lastzero
Copy link
Member

See also: #2022 (reply in thread)

@lastzero lastzero added the help wanted Well suited for external contributors! label Oct 27, 2022
@lastzero
Copy link
Member

Could it be that these faces have been marked as "hidden" in the UI? A look at the code (note the arguments of the FacesByID function!) would explain why this warning is displayed further down, and also why they could not be matched or merging might fail:

faces

It comes down to better understanding what you did and what behavior is expected. Perhaps we should still work with these hidden faces when the alternative is poor performance or other problems.

@lastzero lastzero added needs-analysis Requires further investigation and removed bug Something isn't working labels Oct 27, 2022
@lastzero lastzero changed the title Error of "failed removing merged clusters for subject" causes face tagging to become incredibly slow Faces: Error "Failed removing merged clusters for subject" seems to cause tagging of faces to become slow Oct 27, 2022
@lastzero
Copy link
Member

We look forward to an answer to the above question so we can find out what is causing this.

@lastzero lastzero added the waiting Impediment / blocked / waiting label Nov 1, 2022
@QrchackOfficial
Copy link

Tuning in from #1598, I just ran photoprism audit --fix with the following output:

INFO[2022-11-10T15:37:30Z] PhotoPrism® needs your support!              
INFO[2022-11-10T15:37:30Z] Visit https://photoprism.app/membership to learn more. 
INFO[2022-11-10T15:37:30Z] migrate: executing pre migrations            
INFO[2022-11-10T15:37:31Z] migrate: executing main migrations           
INFO[2022-11-10T15:37:31Z] faces: found 8 subjects                      
INFO[2022-11-10T15:37:31Z] faces: found no invalid marker subjects      
INFO[2022-11-10T15:37:31Z] faces: found no invalid marker faces         
INFO[2022-11-10T15:37:37Z] faces: found no ambiguous subjects           
INFO[2022-11-10T15:37:37Z] faces: found no orphan face clusters         
INFO[2022-11-10T15:37:37Z] faces: found no orphan people                
INFO[2022-11-10T15:37:37Z] completed in 6.645229213s                    
INFO[2022-11-10T15:37:37Z] closed database connection

15 minutes later, I still see this in logs:

time="2022-11-10T15:49:33Z" level=warning msg="faces: failed removing merged clusters for subject jrjcvbj2hkua2p7k"
time="2022-11-10T15:49:34Z" level=warning msg="faces: failed removing merged clusters for subject jrjcvbm24uvqe65i"
time="2022-11-10T15:49:34Z" level=warning msg="faces: failed removing merged clusters for subject jrjcvbj2hkua2p7k"
time="2022-11-10T15:49:35Z" level=warning msg="faces: failed removing merged clusters for subject jrjcvbm24uvqe65i"
time="2022-11-10T15:49:36Z" level=warning msg="faces: failed removing merged clusters for subject jrjcvbj2hkua2p7k"
time="2022-11-10T15:49:36Z" level=warning msg="faces: failed removing merged clusters for subject jrjcvbm24uvqe65i"
time="2022-11-10T15:49:37Z" level=warning msg="faces: failed removing merged clusters for subject jrjcvbj2hkua2p7k"
time="2022-11-10T15:49:37Z" level=warning msg="faces: failed removing merged clusters for subject jrjcvbm24uvqe65i"
time="2022-11-10T15:49:37Z" level=warning msg="faces: failed removing merged clusters for subject jrjcvbj2hkua2p7k"
time="2022-11-10T15:49:37Z" level=warning msg="faces: failed removing merged clusters for subject jrjcvbm24uvqe65i"
time="2022-11-10T15:49:38Z" level=warning msg="faces: failed removing merged clusters for subject jrjcvbj2hkua2p7k"
time="2022-11-10T15:49:39Z" level=warning msg="faces: failed removing merged clusters for subject jrjcvbm24uvqe65i"
time="2022-11-10T15:49:39Z" level=warning msg="faces: failed removing merged clusters for subject jrjcvbj2hkua2p7k"
time="2022-11-10T15:49:39Z" level=warning msg="faces: failed removing merged clusters for subject jrjcvbm24uvqe65i"
time="2022-11-10T15:49:40Z" level=warning msg="faces: failed removing merged clusters for subject jrjcvbj2hkua2p7k"
time="2022-11-10T15:49:41Z" level=warning msg="faces: failed removing merged clusters for subject jrjcvbm24uvqe65i"
time="2022-11-10T15:49:42Z" level=warning msg="faces: failed removing merged clusters for subject jrjcvbj2hkua2p7k"
time="2022-11-10T15:49:42Z" level=warning msg="faces: failed removing merged clusters for subject jrjcvbm24uvqe65i"
time="2022-11-10T15:49:43Z" level=warning msg="faces: failed removing merged clusters for subject jrjcvbj2hkua2p7k"
time="2022-11-10T15:49:43Z" level=warning msg="faces: failed removing merged clusters for subject jrjcvbm24uvqe65i"
time="2022-11-10T15:49:44Z" level=warning msg="faces: failed removing merged clusters for subject jrjcvbj2hkua2p7k"
time="2022-11-10T15:49:44Z" level=warning msg="faces: failed removing merged clusters for subject jrjcvbm24uvqe65i"
time="2022-11-10T15:49:44Z" level=info msg="faces: merged 88 clusters [11.152160011s]"

@lastzero
Copy link
Member

Alright, did you read my last comment? See question:

Could it be that these faces have been marked as "hidden" in the UI?

@lastzero
Copy link
Member

lastzero commented Nov 10, 2022

Also enable the debug or trace mode when you run the audit command, as it displays additional logs that can be helpful.

Edit: In every event, there should never be "88 clusters" to merge every 15 minutes. One more thing that would be good to know for debugging is what database (version) you use and if you know how we might reproduce this (what did you do?).

@QrchackOfficial
Copy link

Don't recall specifically hiding or seeing a hide button, though anything is possible as I've been fumbling my way through the software just clicking things and seeing what happens. That said I can say for sure that I:

  • went to People tab, switched to New
  • saw "No people found" every time, even after adding photos, so I clicked for "Show all new faces"
  • clicked on the photo date/camera EXIF data portion of the lower half of thumbnails (this is absurdly unintuitive btw, found it by accident)
  • typed names into the boxes for a couple dozen photos
  • pretty sure a few times I had some autocorrect typos on my phone, or just keyboard on mobile popped up and I chose the wrong person
  • I remember it locking up the UI for a second or so after saving every face
  • for fixing the mistake, if I recall correctly I pressed on the X in the box I typed into

Might have also jumped around between edit photo view and gallery/thumbnail view while doing this

@QrchackOfficial
Copy link

QrchackOfficial commented Nov 10, 2022

Also enable the debug or trace mode when you run the audit command, as it displays additional logs that can be helpful.

How do I debug/trace with a docker-compose based deploy?

Edit: In every event, there should never be "88 clusters" to merge every 15 minutes.

Agreed, and it is exactly 88 clusters, every 15 minutes and maxes disk I/O plus takes the exact same ~12 seconds - every time.

One more thing that would be good to know for debugging is what database (version) you use and if you know how we might reproduce this (what did you do?).

The docker-compose stack runs mariadb:10.9 (as copied from the install instructions on the website) with photoprism/photoprism:latest and I'm sure all images have been recently pulled as the stack has watchtower for auto-updates as well.

@lastzero
Copy link
Member

Using different names for the same face ("typos") could cause conflict resolution issues, although we improved that a lot earlier this year.

You can enable trace mode and run commands like this: photoprism --trace command [subcommand] [--subcommand-flag] [argument]

@lastzero
Copy link
Member

@QrchackOfficial
Copy link

You're losing bropoints for the management script ignoring output redirection to a file, but fine - here's trace:

root@221105-jammy:/photoprism$ photoprism --trace faces audit --fix     
TRAC[2022-11-10T16:11:26Z] config: defaults file /etc/photoprism/defaults.yml does not exist 
DEBU[2022-11-10T16:11:26Z] config: overriding config with values from /photoprism/storage/config/options.yml 
DEBU[2022-11-10T16:11:26Z] config: running on 'Intel(R) Core(TM) i5-6500T CPU @ 2.50GHz', 33 GB memory detected 
DEBU[2022-11-10T16:11:26Z] settings: loaded from /photoprism/storage/config/settings.yml 
INFO[2022-11-10T16:11:26Z] PhotoPrism® needs your support!              
INFO[2022-11-10T16:11:26Z] Visit https://photoprism.app/membership to learn more. 
DEBU[2022-11-10T16:11:26Z] config: successfully initialized [3.20584ms] 
INFO[2022-11-10T16:11:26Z] migrate: executing pre migrations            
DEBU[2022-11-10T16:11:26Z] migrate: found 2 previous migrations         
DEBU[2022-11-10T16:11:26Z] migrate: 20221015-100000 skipped             
DEBU[2022-11-10T16:11:26Z] migrate: 20221015-100100 skipped              
INFO[2022-11-10T16:11:27Z] migrate: executing main migrations           
DEBU[2022-11-10T16:11:27Z] migrate: found 21 previous migrations         
DEBU[2022-11-10T16:11:27Z] migrate: 20211121-094727 skipped             
DEBU[2022-11-10T16:11:27Z] migrate: 20211124-120008 skipped              
DEBU[2022-11-10T16:11:27Z] migrate: 20220329-030000 skipped             
DEBU[2022-11-10T16:11:27Z] migrate: 20220329-040000 skipped             
DEBU[2022-11-10T16:11:27Z] migrate: 20220329-050000 skipped              
DEBU[2022-11-10T16:11:27Z] migrate: 20220329-060000 skipped             
DEBU[2022-11-10T16:11:27Z] migrate: 20220329-061000 skipped             
DEBU[2022-11-10T16:11:27Z] migrate: 20220329-070000 skipped             
DEBU[2022-11-10T16:11:27Z] migrate: 20220329-071000 skipped             
DEBU[2022-11-10T16:11:27Z] migrate: 20220329-080000 skipped             
DEBU[2022-11-10T16:11:27Z] migrate: 20220329-081000 skipped              
DEBU[2022-11-10T16:11:27Z] migrate: 20220329-083000 skipped             
DEBU[2022-11-10T16:11:27Z] migrate: 20220329-090000 skipped 
DEBU[2022-11-10T16:11:27Z] migrate: 20220329-091000 skipped             
DEBU[2022-11-10T16:11:27Z] migrate: 20220329-093000 skipped             
DEBU[2022-11-10T16:11:27Z] migrate: 20220421-200000 skipped             
DEBU[2022-11-10T16:11:27Z] migrate: 20220521-000001 skipped             
DEBU[2022-11-10T16:11:27Z] migrate: 20220521-000002 skipped             
DEBU[2022-11-10T16:11:27Z] migrate: 20220521-000003 skipped             
DEBU[2022-11-10T16:11:27Z] migrate: 20220927-000100 skipped             
DEBU[2022-11-10T16:11:27Z] migrate: 20221002-000100 skipped              
TRAC[2022-11-10T16:11:27Z] migrate: errors migrated                     
TRAC[2022-11-10T16:11:27Z] migrate: files_sync migrated                  
TRAC[2022-11-10T16:11:27Z] migrate: albums migrated                     
TRAC[2022-11-10T16:11:27Z] migrate: photos_labels migrated              
TRAC[2022-11-10T16:11:27Z] migrate: photos_keywords migrated            
TRAC[2022-11-10T16:11:27Z] migrate: reactions migrated                  
TRAC[2022-11-10T16:11:27Z] migrate: countries migrated                  
TRAC[2022-11-10T16:11:27Z] migrate: keywords migrated                   
TRAC[2022-11-10T16:11:27Z] migrate: auth_users_shares migrated          
TRAC[2022-11-10T16:11:27Z] migrate: auth_sessions migrated              
TRAC[2022-11-10T16:11:27Z] migrate: passwords migrated                  
TRAC[2022-11-10T16:11:27Z] migrate: folders migrated                     
TRAC[2022-11-10T16:11:27Z] migrate: files migrated                                                    
TRAC[2022-11-10T16:11:27Z] migrate: photos migrated                                                   
TRAC[2022-11-10T16:11:27Z] migrate: places migrated                                                   
TRAC[2022-11-10T16:11:27Z] migrate: faces migrated                                                    
TRAC[2022-11-10T16:11:27Z] migrate: auth_users_settings migrated             
TRAC[2022-11-10T16:11:27Z] migrate: duplicates migrated                 
TRAC[2022-11-10T16:11:27Z] migrate: photos_albums migrated                                   
TRAC[2022-11-10T16:11:27Z] migrate: labels migrated                                                                                                                                                          
TRAC[2022-11-10T16:11:27Z] migrate: migrations migrated                                                                                                                                                      
TRAC[2022-11-10T16:11:27Z] migrate: auth_users_details migrated                          
TRAC[2022-11-10T16:11:27Z] migrate: services migrated                   
TRAC[2022-11-10T16:11:27Z] migrate: files_share migrated                          
TRAC[2022-11-10T16:11:27Z] migrate: categories migrated                 
TRAC[2022-11-10T16:11:27Z] migrate: subjects migrated                   
TRAC[2022-11-10T16:11:27Z] migrate: auth_users migrated                 
TRAC[2022-11-10T16:11:27Z] migrate: photos_users migrated               
TRAC[2022-11-10T16:11:27Z] migrate: details migrated                     
TRAC[2022-11-10T16:11:27Z] migrate: cells migrated                      
TRAC[2022-11-10T16:11:27Z] migrate: cameras migrated                     
TRAC[2022-11-10T16:11:27Z] migrate: lenses migrated                     
TRAC[2022-11-10T16:11:27Z] migrate: albums_users migrated                
TRAC[2022-11-10T16:11:27Z] migrate: links migrated                      
TRAC[2022-11-10T16:11:27Z] migrate: markers migrated                    
DEBU[2022-11-10T16:11:27Z] migrate: completed in 674.150323ms            
INFO[2022-11-10T16:11:27Z] faces: found 8 subjects                      
INFO[2022-11-10T16:11:27Z] faces: found no invalid marker subjects      
INFO[2022-11-10T16:11:27Z] faces: found no invalid marker faces         
INFO[2022-11-10T16:11:32Z] faces: found no ambiguous subjects           
INFO[2022-11-10T16:11:32Z] faces: found no orphan face clusters         
INFO[2022-11-10T16:11:32Z] faces: found no orphan people                 
INFO[2022-11-10T16:11:32Z] completed in 6.59606644s                     
INFO[2022-11-10T16:11:32Z] closed database connection

Let me know if this helps anything, or if there's anything else I can run to help. For reference, this is running on Proxmox, in a LXC with Alpine Linux installed, that has Docker installed in it, and PhotoPrism runs in that Docker environment as a docker-compose stack.

@lastzero
Copy link
Member

There's also the faces optimize and index subcommands you might want to try. Use the command help please, these do have descriptions including descriptions for different flags you can use.

What are "bropoints" and why do I lose them? I'm on my phone and preparing dinner right now 😋

@QrchackOfficial
Copy link

Hah, sure will have a look around. Bropoints as in buddy/friend points, not being able to redirect to a file and copypasta straight to you (vs piecing together one screen of terminal at a time in a text editor) makes me a sad panda

@QrchackOfficial
Copy link

Enjoy your meal tho! No peeking at github randoms 👀

@lastzero
Copy link
Member

That's intentional, because otherwise you'll have debug logs in your SQL dump, or CSV export. This would make all our other users sad, and they wouldn't notice until they need the backup.

@QrchackOfficial
Copy link

Database migrations all say OK. I'm getting 8 faces matched to the same person in stats.

root@221105-jammy:/photoprism$ photoprism faces stats
INFO[2022-11-10T16:23:37Z] migrate: executing pre migrations            
INFO[2022-11-10T16:23:37Z] migrate: executing main migrations           
INFO[2022-11-10T16:23:38Z] faces: computing distance of 2023 samples    
INFO[2022-11-10T16:23:41Z] faces: min Ø 0.130527 < median 0.395307 < 1.159296 
INFO[2022-11-10T16:23:41Z] faces: max Ø 1.539482 < median 1.636065 < 1.756611 
INFO[2022-11-10T16:23:41Z] faces: computing distance of faces matching to the same person 
INFO[2022-11-10T16:23:42Z] faces: 8 faces match to the same person      
INFO[2022-11-10T16:23:42Z] faces: jrjcvbj2hkua2p7k Ø min 0.000798, max 1.253921 
INFO[2022-11-10T16:23:42Z] faces: jrjcvbm24uvqe65i Ø min 0.058338, max 0.968240 
INFO[2022-11-10T16:23:42Z] faces: jrjcvfo22ij4mh1d Ø min 0.434862, max 1.213797 
INFO[2022-11-10T16:23:42Z] faces: jrjdqhzy4d7hfmiu Ø min 0.813886, max 0.813886 
INFO[2022-11-10T16:23:42Z] faces: jrjdrfx2atteb9ex Ø min 0.663006, max 0.746730 
INFO[2022-11-10T16:23:42Z] faces: jrjcv4ffauojtasv Ø min 0.451921, max 1.332812 
INFO[2022-11-10T16:23:42Z] faces: jrjcv7b3hladq4l1 Ø min 0.376884, max 1.220350 
INFO[2022-11-10T16:23:42Z] faces: jrjcvbfq24luirjt Ø min 0.362785, max 1.546963 
INFO[2022-11-10T16:23:42Z] completed in 5.186810182s                    
INFO[2022-11-10T16:23:42Z] closed database connection         

That's intentional, because otherwise you'll have debug logs in your SQL dump, or CSV export. This would make all our other users sad, and they wouldn't notice until they need the backup.

Does this mean the management script outputs SQL dumps / CSV to stdout instead of taking an output file to write to? Sounds a bit crazy...

@lastzero
Copy link
Member

Try photoprism --trace faces optimize. The backup command will output a SQL dump, for example. Since you normally use docker exec, stdout is used by default, otherwise you will have to use a temporary file in a mounted directory, which I would not recommend unless you hate yourself.

@lastzero
Copy link
Member

If you want to know details about the backup command, please check the command help :)

@lastzero
Copy link
Member

Also, if you're nice, I might eventually show you how to pipe the logs to a file.

@QrchackOfficial
Copy link

Hmm. Full on faces index also failed:

[...]
WARN[2022-11-10T16:45:42Z] faces: failed removing merged clusters for subject jrjcvbj2hkua2p7k 
WARN[2022-11-10T16:45:42Z] faces: failed removing merged clusters for subject jrjcvbm24uvqe65i 
WARN[2022-11-10T16:45:43Z] faces: failed removing merged clusters for subject jrjcvbj2hkua2p7k 
WARN[2022-11-10T16:45:43Z] faces: failed removing merged clusters for subject jrjcvbm24uvqe65i 
WARN[2022-11-10T16:45:44Z] faces: failed removing merged clusters for subject jrjcvbj2hkua2p7k 
WARN[2022-11-10T16:45:44Z] faces: failed removing merged clusters for subject jrjcvbm24uvqe65i 
WARN[2022-11-10T16:45:45Z] faces: failed removing merged clusters for subject jrjcvbj2hkua2p7k 
WARN[2022-11-10T16:45:45Z] faces: failed removing merged clusters for subject jrjcvbm24uvqe65i 
WARN[2022-11-10T16:45:46Z] faces: failed removing merged clusters for subject jrjcvbj2hkua2p7k 
WARN[2022-11-10T16:45:46Z] faces: failed removing merged clusters for subject jrjcvbm24uvqe65i 
WARN[2022-11-10T16:45:47Z] faces: failed removing merged clusters for subject jrjcvbj2hkua2p7k 
WARN[2022-11-10T16:45:48Z] faces: failed removing merged clusters for subject jrjcvbm24uvqe65i 
WARN[2022-11-10T16:45:48Z] faces: failed removing merged clusters for subject jrjcvbj2hkua2p7k 
WARN[2022-11-10T16:45:48Z] faces: failed removing merged clusters for subject jrjcvbm24uvqe65i 
WARN[2022-11-10T16:45:49Z] faces: failed removing merged clusters for subject jrjcvbj2hkua2p7k 
WARN[2022-11-10T16:45:50Z] faces: failed removing merged clusters for subject jrjcvbm24uvqe65i 
WARN[2022-11-10T16:45:51Z] faces: failed removing merged clusters for subject jrjcvbj2hkua2p7k 
WARN[2022-11-10T16:45:51Z] faces: failed removing merged clusters for subject jrjcvbm24uvqe65i 
WARN[2022-11-10T16:45:51Z] faces: failed removing merged clusters for subject jrjcvbj2hkua2p7k 
WARN[2022-11-10T16:45:52Z] faces: failed removing merged clusters for subject jrjcvbm24uvqe65i 
WARN[2022-11-10T16:45:53Z] faces: failed removing merged clusters for subject jrjcvbj2hkua2p7k 
WARN[2022-11-10T16:45:53Z] faces: failed removing merged clusters for subject jrjcvbm24uvqe65i 
INFO[2022-11-10T16:45:53Z] faces: merged 88 clusters [11.734218074s]    
INFO[2022-11-10T16:45:56Z] indexed 8,642 files in 21m2.487376532s       
INFO[2022-11-10T16:45:56Z] closed database connection 

@lastzero
Copy link
Member

OK, so we know as much as before. Thanks for trying though! 👍

@lastzero
Copy link
Member

@ER-EPR Based on your profile picture, I think the user experience would be much better for you if our model worked better with Asian faces. Except for the noise your fan might make. We want to solve these and many other problems, but it takes time and money to build a team of specialists.

Be aware that I have only studied Physics and read research papers, I am not a full time face recognition specialist who does nothing else in his life. We certainly can't hire someone like that with our current resources. So our next goal is to improve funding instead of introducing more and more workarounds and tiny improvements, like experimenting with the worker schedule. That ties up resources we need for the bigger goals.

@lastzero
Copy link
Member

Wow, quite the traffic in here recently. I'll add that in my specific case there's just one instance running, but the manual tagging was most certainly done fast and to avoid waiting for the UI blocking progress bar I would close out of the tab and tag in another. Meaning there's a decent chance that there were several tags being applied while the database was updating in the background.

Using multiple tabs instead of waiting would almost certainly cause the behavior you observed. Thanks for letting us know! We should include that as a note in our docs.

@ER-EPR
Copy link

ER-EPR commented Nov 14, 2022

@QrchackOfficial The merge fail can be cured by untagging small clusters of one subject as I did in the above posts using MySQL. You can search in the markers table for a subj_uid, and see the face_id listed in the warning, and clear the tags of the small groups and let them merge with the big group.(don't untag the big group) But remember to backup your database first. It's a dangerous act.

@lastzero
Copy link
Member

lastzero commented Nov 14, 2022

You are welcome to privately provide us with a SQL dump of the subjects, faces, and markers tables for debugging. This would save us hours of reverse-engineering your (potential) database content based on the GitHub issue comments, which could eventually lead us to solutions that don't work for you because we got it wrong. Thank you very much!

lastzero added a commit to photoprism/photoprism-docs that referenced this issue Nov 14, 2022
lastzero added a commit to photoprism/photoprism-docs that referenced this issue Nov 14, 2022
lastzero added a commit to photoprism/photoprism-docs that referenced this issue Nov 14, 2022
lastzero added a commit to photoprism/photoprism-docs that referenced this issue Nov 14, 2022
@lastzero
Copy link
Member

The documentation has been updated for you:

Legacy Hardware

It is a known issue that the user interface and backend operations, especially face recognition, can be slow or even crash on older hardware due to a lack of resources.

Like most applications, PhotoPrism has certain requirements and our development process does not include testing on unsupported or unusual hardware.

Asian Faces and Children

It is a known issue that children and Asian-looking faces cannot be recognized reliably. Detection without automatic recognition should not be affected by that.

This is because the model we use was trained with North American images, which unfortunately do not include many Asians. The absence of children in the training data comes from the fact that parents do not usually share such images under a public license (and may not have the right to do so).

We will continue to improve our models over time as our resources allow.

Background Worker

Face recognition was developed and tested under the assumption that the background worker runs every 15 minutes, unless the backend is busy with other tasks like indexing. It has not been tested with much longer intervals and is not designed for that.

PhotoPrism's background worker groups new faces by similarity, compares faces with clusters, and optimizes existing clusters as needed. Without these routine tasks, the number of faces to be processed becomes too large. The first and next time the worker runs, it can then cause a heavy server load until all the faces, face clusters, and related pictures have been updated. The longer you wait, the more CPU is required and the longer it takes.

An important reason for the worker to run independently of actual changes in the main instance is that some users change the database content directly or run additional instances, for example for indexing. It is a problem that can be solved, but it takes time. If we were to ignore this and don't run the worker at all times, it could lead to many additional support requests, further reducing the amount of time we can spend on development.

The handling of changes in multiple instances will be improved over time so that the worker can be run less frequently in future releases.

Removing Merged Clusters Fails

Under certain conditions, inconsistent face assignments cannot be automatically resolved by the background worker, which can result in an unusually high CPU load when it is running:

  • if you use multiple browser tabs or windows for assigning faces and don't wait until saving the changes is complete, the likelihood of this problem increases, especially if you accidentally enter different names for the same face
  • another possible cause is running multiple instances (for example, parallel indexing workers started by a scheduler in the background) or modifying database content directly, as this may also lead to inconsistent faces, markers and subjects
  • see Faces: Error "Failed removing merged clusters for subject" seems to cause tagging of faces to become slow #2806

Running the following command in a terminal can resolve problems with inconsistent data:

docker compose exec photoprism photoprism faces audit --fix

It can also be helpful to manually check for inconsistent assignments and fix them in the user interface. Alternatively, you can use the photoprism faces reset command for a clean start if you haven't invested much time in assigning faces yet.

Advanced users affected by this are welcome to privately provide us with a SQL dump of their subjects, faces, and markers database tables for debugging. Thank you very much!

lastzero added a commit to photoprism/photoprism-docs that referenced this issue Nov 14, 2022
lastzero added a commit to photoprism/photoprism-docs that referenced this issue Nov 14, 2022
lastzero added a commit to photoprism/photoprism-docs that referenced this issue Nov 15, 2022
@lastzero
Copy link
Member

I am closing this issue as we have not received any further feedback from the original reporter and there are now too many comments, making it difficult for anyone who has not participated in the discussion to understand. Everything important is now covered in the Known Issues. If someone affected provides us with a dump of the database tables, we can fix the problem - otherwise it requires too much time and luck:

👉 https://docs.photoprism.app/known-issues/#removing-merged-clusters-fails

@lastzero lastzero added invalid Works as documented or cannot be reproduced and removed waiting Impediment / blocked / waiting needs-analysis Requires further investigation labels Nov 17, 2022
@ER-EPR
Copy link

ER-EPR commented Nov 18, 2022

I have sent you two emails containing download links for the mysql dump for the three tables. The first link may have expired, please use the second one.

@lastzero lastzero added incomplete Cannot be processed due to missing information and removed invalid Works as documented or cannot be reproduced labels Nov 22, 2022
@pjft
Copy link

pjft commented Jan 2, 2023

@lastzero happy new year. I'm happy to provide you with the database files for debugging, but I'd probably need some guidance in getting them. I am running into the exact same issues.

Single instance, on docker. I did not manually edit the database.

Happy to help in any way here.

@maxime1992
Copy link

Same over here. It takes sometimes about a minute or maybe 2 to add someone, when it works. It sometimes says it's "busy" or just "Have you lost network" (can't remember exactly but anyway, like something went wrong).
If there's a step by step guide I'm willing to provide some data as well as this feature is fantastic but pretty much unusable at all for me at the moment as I've started to use photoprism recently and I'm massively adding pictures, and have a lot to tag as well.

PS: I've tried to run the commands and work arounds from that issue but none of them worked for me.

@pjft
Copy link

pjft commented Jan 14, 2023

I reset my faces, even though I already had a meaningful amount of faces tagged - no more clusters to tag, from 780 original clusters, as well as individual faces that needed to be fixed in clusters where they had been mis-tagged.

I am now first taking care of organizing my full library, with albums and whatnot, and then I'll do a backup and try to go after the face tagging.

The commands didn't really help.

@lastzero
Copy link
Member

Unfortunately, even after 5 years, I'm still the only full-time developer. I'll took into it as soon as possible.

@pjft
Copy link

pjft commented Jan 14, 2023

Hi @lastzero . Never meant this to be taken in any way other than just updating here.

My last post still stands: happy to share my "broken" database if it helps, though I think it's still around 1GB.

Thanks for building Photoprism. It's a fantastic app. I know there are other priorities on the table.

Just let us know how we can help.

@lastzero
Copy link
Member

The dump might be really helpful. However, the subjects, markers and faces tables should be enough for debugging. That will reduce the size so you can send a link or attach it as a zip to an email. Thank you! ❤️

@pjft
Copy link

pjft commented Jan 14, 2023

Just sent it to the hello@ email address, with a link to download the database.

Hope it helps - let me know if you don't get it for some reason.

Have a great weekend!

@maxime1992
Copy link

Hello @lastzero 👋

Unfortunately, even after 5 years, I'm still the only full-time developer. I'll took into it as soon as possible.

Same as what @pjft said, we very much appreciate your time on the project and we know there are some priorities. We're just here to help so that if you feel looking back into this issue at one point, you've got the data you need. Sorry if my previous message came across the wrong way!

I just sent you on the hello address a dump of the 3 tables you asked for. Hope it helps 🤞 !

I am closing this issue as we have not received any further feedback from the original reporter [...]. If someone affected provides us with a dump of the database tables, we can fix the problem [...]

Based on this comment and the fact that you shall now have the data you need to debug, would you consider reopening the issue maybe?

Have a good weekend

@lastzero
Copy link
Member

Given the long list of comments, it seems best to open a new issue. The new issue should contain a summary of everything that seems important to get to a solution and, for example, has been mentioned here, but also in GitHub Discussions. Feel free to move ahead with this, as I'm drowning in work right now and don't know when I'll get to it. Thank you very much, also for the kind words!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Well suited for external contributors! incomplete Cannot be processed due to missing information
Projects
None yet
Development

No branches or pull requests

6 participants