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: Improve performance and strategy for manual tagging #3124

Open
maxime1992 opened this issue Jan 17, 2023 · 21 comments
Open

Faces: Improve performance and strategy for manual tagging #3124

maxime1992 opened this issue Jan 17, 2023 · 21 comments
Assignees
Labels
bug Something isn't working performance Performance Optimization priority Supported by early sponsors or popular demand

Comments

@maxime1992
Copy link

Let me start by saying this is a new issue that'll summarize a closed, but still happening issue. I'm creating this new issue based on @lastzero 's comment.

1. What is not working as documented?

For faces that were not added automatically, tagging people manually is slow to extremely slow. With some photos or persons (unsure), it takes a few seconds only (rare) but once that issue happens, most of the time it takes in my case between 1 and 2 minutes to tag 1 person. I've decided recently to move all my photos to photoprism so I've got quite a lot already, and quite a lot more to come. I have more than a couple hundreds pictures with unrecognized faces waiting to be tagged, but I'm not able to wait 1 to 2 mn for each, it'd be unmanageable.

It's documented as a known issue. I have tried the command docker compose exec photoprism photoprism faces audit --fix but it didn't help fixing the issue.

2. How can we reproduce it?

I have no idea how exactly to reproduce this, but both @pjft and myself have shared parts of our database by email directly to help debug it. See pjft comment and mine. Best case scenario it's enough to debug, if not I'm more than happy to provide more info.

3. What behavior do you expect?

When a face is detected but unknown, it shouldn't take more than a few seconds to add it manually.

4. What could be the cause of your problem?

Really unsure, sorry.

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

As stated above, this has been done by email as it includes personal data.

6. Which software versions do you use?

(a) PhotoPrism Architecture & Build Number: AMD64, ARM64, ARMv7,...

Build 221118-e58fee0fb

(b) Database Type & Version: MariaDB, MySQL, SQLite,...

MariaDB

(c) Operating System Types & Versions: Linux, Windows, Android,...

Linux

(d) Browser Types & Versions: Firefox, Chrome, Safari on iPhone,...

Brave and Chrome

(e) Ad Blockers, Browser Plugins, and/or Firewall Software?

Probably irrelevant here. (I've tried to turn them off, doesn't change anything).

7. On what kind of device is PhotoPrism installed?

This is especially important if you are reporting a performance, import, or indexing issue. You can skip this if you're reporting a problem you found in our public demo, or if it's a completely unrelated issue, such as incorrect page layout.

(a) Device / Processor Type: Raspberry Pi 4, Intel Core i7-3770, AMD Ryzen 7 3800X,...

Intel(R) Core(TM) i3-3227U CPU @ 1.90GHz

(b) Physical Memory & Swap Space in GB

4gb and 4gb

(c) Storage Type: HDD, SSD, RAID, USB, Network Storage,...

SSD

(d) Anything else that might be helpful to know?

8. Do you use a Reverse Proxy, Firewall, VPN, or CDN?

Yes, I use SWAG which itself uses NGINX, but it's probably unrelated here as it used to work perfectly with that config.


I'll summarize what was found in the previous issue:

  • There's a suspicion that this issue may arise when photoprism thinks there are different faces, assigned to the same person
  • Make a "faces reset" works... But in the case of reporter of the previous issue it came back so not really a viable option
  • It was asked if it could come from either running multiple instances or directly modifying database content. It's not the case for neither of these for me
  • The original issue was closed because nobody shared their database, we've now send 2 of them for debugging
@maxime1992 maxime1992 added the bug Something isn't working label Jan 17, 2023
@lastzero lastzero changed the title Slow face tagging and error "Failed removing merged clusters for subject" Faces: Failed removing merged clusters for subject Jan 20, 2023
@lastzero lastzero added the performance Performance Optimization label Jan 20, 2023
@lastzero lastzero self-assigned this Jan 20, 2023
@lastzero lastzero added the help wanted Well suited for external contributors! label Jan 20, 2023
@lastzero lastzero removed their assignment Jan 20, 2023
@mdmarwil
Copy link

I have am having this same issue and the command docker compose exec photoprism photoprism faces audit --fix does not help.

My background is mostly in python, but I tried to do some digging through the code.

The Warning message faces: failed removing merged clusters for subject comes from the following code block in internal/query/faces.go:

// PurgeOrphanFaces removes unused faces from the index.
if removed, err := PurgeOrphanFaces(merge.IDs()); err != nil {
return merged, err
} else if removed > 0 {
log.Debugf("faces: removed %d orphans for subject %s", removed, clean.Log(subjUID))
} else {
log.Warnf("faces: failed removing merged clusters for subject %s", clean.Log(subjUID))
}

Just prior to this block of code MatchMarkers() is called. It is trying to match 1 Face to 4 other Faces with the same subj_uid, but it looks like the distance of the embeddings of the 4 others Faces is too far from the first Face to be considered a match. So none complete.

Going back to the block of code shown above that means:

  • No error was encountered
  • The number removed is 0, since no faces were reassigned and thus orphaned

So it falls into the else block with a warning message, although for this case the more accurate message would be to state there were no orphaned cluster to remove.

@dalfry
Copy link

dalfry commented Feb 5, 2023

Running into this issue. Tried running the audit fix command with no change. I have the merge failed error for one single subject. Library has 100k+ files. Spent a week tagging faces. Would prefer not to reset faces. :-)

BTW, Thanks for all your work! Photoprism is awesome! and I am a sponsor as well.

TRAC[2023-02-05T19:31:33Z] config: defaults file /etc/photoprism/defaults.yml does not exist
INFO[2023-02-05T19:31:33Z] config: case-insensitive file system detected
DEBU[2023-02-05T19:31:33Z] config: running on 'Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz', 4.1 GB memory detected
DEBU[2023-02-05T19:31:33Z] settings: loaded from /photoprism/storage/config/settings.yml
DEBU[2023-02-05T19:31:33Z] config: successfully initialized [35.329727ms]
INFO[2023-02-05T19:31:33Z] migrate: executing pre migrations
DEBU[2023-02-05T19:31:33Z] migrate: found 2 previous migrations
DEBU[2023-02-05T19:31:33Z] migrate: 20221015-100000 skipped
DEBU[2023-02-05T19:31:33Z] migrate: 20221015-100100 skipped
INFO[2023-02-05T19:31:34Z] migrate: executing main migrations
DEBU[2023-02-05T19:31:34Z] migrate: found 21 previous migrations
DEBU[2023-02-05T19:31:34Z] migrate: 20211121-094727 skipped
DEBU[2023-02-05T19:31:34Z] migrate: 20211124-120008 skipped
DEBU[2023-02-05T19:31:34Z] migrate: 20220329-030000 skipped
DEBU[2023-02-05T19:31:34Z] migrate: 20220329-040000 skipped
DEBU[2023-02-05T19:31:34Z] migrate: 20220329-050000 skipped
DEBU[2023-02-05T19:31:34Z] migrate: 20220329-060000 skipped
DEBU[2023-02-05T19:31:34Z] migrate: 20220329-061000 skipped
DEBU[2023-02-05T19:31:34Z] migrate: 20220329-070000 skipped
DEBU[2023-02-05T19:31:34Z] migrate: 20220329-071000 skipped
DEBU[2023-02-05T19:31:34Z] migrate: 20220329-080000 skipped
DEBU[2023-02-05T19:31:34Z] migrate: 20220329-081000 skipped
DEBU[2023-02-05T19:31:34Z] migrate: 20220329-083000 skipped
DEBU[2023-02-05T19:31:34Z] migrate: 20220329-090000 skipped
DEBU[2023-02-05T19:31:34Z] migrate: 20220329-091000 skipped
DEBU[2023-02-05T19:31:34Z] migrate: 20220329-093000 skipped
DEBU[2023-02-05T19:31:34Z] migrate: 20220421-200000 skipped
DEBU[2023-02-05T19:31:34Z] migrate: 20220521-000001 skipped
DEBU[2023-02-05T19:31:34Z] migrate: 20220521-000002 skipped
DEBU[2023-02-05T19:31:34Z] migrate: 20220521-000003 skipped
DEBU[2023-02-05T19:31:34Z] migrate: 20220927-000100 skipped
DEBU[2023-02-05T19:31:34Z] migrate: 20221002-000100 skipped
TRAC[2023-02-05T19:31:34Z] migrate: migrations migrated
TRAC[2023-02-05T19:31:34Z] migrate: auth_sessions migrated
TRAC[2023-02-05T19:31:34Z] migrate: countries migrated
TRAC[2023-02-05T19:31:34Z] migrate: labels migrated
TRAC[2023-02-05T19:31:35Z] migrate: photos_labels migrated
TRAC[2023-02-05T19:31:35Z] migrate: reactions migrated
TRAC[2023-02-05T19:31:35Z] migrate: files_share migrated
TRAC[2023-02-05T19:31:35Z] migrate: files_sync migrated
TRAC[2023-02-05T19:31:35Z] migrate: details migrated
TRAC[2023-02-05T19:31:35Z] migrate: photos_albums migrated
TRAC[2023-02-05T19:31:35Z] migrate: auth_users_shares migrated
TRAC[2023-02-05T19:31:35Z] migrate: places migrated
TRAC[2023-02-05T19:31:35Z] migrate: lenses migrated
TRAC[2023-02-05T19:31:35Z] migrate: keywords migrated
TRAC[2023-02-05T19:31:35Z] migrate: auth_users migrated
TRAC[2023-02-05T19:31:35Z] migrate: folders migrated
TRAC[2023-02-05T19:31:36Z] migrate: duplicates migrated
TRAC[2023-02-05T19:31:36Z] migrate: photos_users migrated
TRAC[2023-02-05T19:31:36Z] migrate: albums migrated
TRAC[2023-02-05T19:31:36Z] migrate: albums_users migrated
TRAC[2023-02-05T19:31:40Z] migrate: photos_keywords migrated
TRAC[2023-02-05T19:31:40Z] migrate: links migrated
TRAC[2023-02-05T19:31:40Z] migrate: subjects migrated
TRAC[2023-02-05T19:31:40Z] migrate: markers migrated
TRAC[2023-02-05T19:31:40Z] migrate: auth_users_settings migrated
TRAC[2023-02-05T19:31:40Z] migrate: services migrated
TRAC[2023-02-05T19:31:40Z] migrate: errors migrated
TRAC[2023-02-05T19:31:40Z] migrate: passwords migrated
TRAC[2023-02-05T19:31:40Z] migrate: cells migrated
TRAC[2023-02-05T19:31:40Z] migrate: cameras migrated
TRAC[2023-02-05T19:31:40Z] migrate: categories migrated
TRAC[2023-02-05T19:31:40Z] migrate: faces migrated
TRAC[2023-02-05T19:31:40Z] migrate: auth_users_details migrated
TRAC[2023-02-05T19:31:41Z] migrate: files migrated
TRAC[2023-02-05T19:31:41Z] migrate: photos migrated
DEBU[2023-02-05T19:31:41Z] migrate: completed in 7.796722162s
INFO[2023-02-05T19:31:41Z] faces: found 104 subjects
INFO[2023-02-05T19:31:41Z] faces: found no invalid marker subjects
INFO[2023-02-05T19:31:41Z] faces: found no invalid marker faces
INFO[2023-02-05T19:32:10Z] faces: found no ambiguous subjects
INFO[2023-02-05T19:32:10Z] faces: found no orphan face clusters
INFO[2023-02-05T19:32:10Z] faces: found no orphan people
INFO[2023-02-05T19:32:10Z] completed in 36.75042936s
INFO[2023-02-05T19:32:10Z] closed database connection

@lastzero lastzero self-assigned this Feb 9, 2023
@lastzero lastzero added the in-progress Somebody is working on this label Feb 9, 2023
lastzero added a commit that referenced this issue Feb 21, 2023
Signed-off-by: Michael Mayer <michael@photoprism.app>
lastzero added a commit that referenced this issue Feb 21, 2023
Signed-off-by: Michael Mayer <michael@photoprism.app>
@lastzero lastzero added please-test Ready for acceptance test and removed in-progress Somebody is working on this labels Feb 21, 2023
@lastzero
Copy link
Member

I now have a clearer idea of the underlying problem and think we can improve the situation by not matching manually labeled faces if they do not meet the constraints set for automatic clustering (more specifically, cluster core and core distance).

When testing with the pictures we had been using during development, a more aggressive approach for manually labeled faces seemed to work well, but this is only feasible for faces that the model can categorize well. For example, all these faces were matched after labeling a single face in the edit dialog:

single-w

@lastzero lastzero added in-progress Somebody is working on this and removed please-test Ready for acceptance test help wanted Well suited for external contributors! labels Feb 23, 2023
@pjft
Copy link

pjft commented Feb 24, 2023

Thank you for the update - this looks promising! What consequences would this change bring about? Meaning, what will change by not matching manually labeled faces if they do not meet the constraints set for automatic clustering?

Just curious to understand the "why the original decision, what problems did it solve" and "what consequences does it have".

Not urgent, by any means - just intellectual curiosity. :)

Thank you, and happy Friday!

@lastzero lastzero changed the title Faces: Failed removing merged clusters for subject Faces: Improve performance and strategy for manual tagging Feb 24, 2023
@lastzero
Copy link
Member

@pjft We can't tell what the final effect will be until it's implemented. It is expected that you will have to tag a few more faces that belong to the same person before the automatic matching starts, so basically how most other apps work.

Since these changes require extensive testing, we will probably wait until after the next stable release to avoid delaying it even further.

The sample faces we use for testing can be downloaded here:

@pjft
Copy link

pjft commented Feb 24, 2023

Of course - appreciate the time and effort in looking into this.

Let us know how we can help.

lastzero added a commit that referenced this issue Feb 24, 2023
Signed-off-by: Michael Mayer <michael@photoprism.app>
lastzero added a commit that referenced this issue Mar 8, 2023
This may reduce server load and prevent disks from spinning up.
We welcome tests reports!

Signed-off-by: Michael Mayer <michael@photoprism.app>
seeschloss pushed a commit to seeschloss/photoprism that referenced this issue Apr 10, 2023
Signed-off-by: Michael Mayer <michael@photoprism.app>
seeschloss pushed a commit to seeschloss/photoprism that referenced this issue Apr 10, 2023
…sm#3124

This may reduce server load and prevent disks from spinning up.
We welcome tests reports!

Signed-off-by: Michael Mayer <michael@photoprism.app>
@pjft
Copy link

pjft commented May 19, 2023

Just wanted to say that this seems to be solved in the latest builds!

Awesome work :) It's a breeze to label hundreds of clusters now.

@lastzero
Copy link
Member

@pjft Thank you! That's good to know, since the feedback we've received on the optimizations hasn't been very enthusiastic so far. Most users didn't seem to notice (or care about) the changes when they tested our development preview builds.

@pjft
Copy link

pjft commented May 19, 2023

I have no issues whatsoever, and I recall having to wait 1 min or so before having to move forward after a while.

Only comment I have is that, for some reason, the "audit fix" and "optimize faces" commands seem to cause more long-lasting issues than the ones I experience without them. Unsure if temporary or not, but I have not dug into them as it's painful to go back and redo all the work 😅

@lastzero
Copy link
Member

We will change how manually labeled faces are clustered and compared in one of the upcoming releases. This should solve the remaining issues.

@pjft
Copy link

pjft commented May 19, 2023

Awesome:) if you need any testing at any point, by all means tag me directly. I'm always happy to help if I can. I appreciate all the work you and @graciousgrey put into making Photoprism great! Thank you so much.

@graciousgrey graciousgrey removed the in-progress Somebody is working on this label Jun 29, 2023
@berturu
Copy link

berturu commented Jul 24, 2023

Unfortunately I still experience a delay when tagging new faces. The delay ranges from 2/3 seconds to possibly a full minute at times. Running Build 1.2306.25

@lastzero
Copy link
Member

Unfortunately, we haven't had time to work on this yet. We will reference this issue in the related commits and mention it in the release notes once the improvements are available. Alternatively, feel free to work on this and provide us with a pull request that we just need to merge. Thank you! ❤️

@judej
Copy link

judej commented Aug 30, 2023

+1 on the perf issue. When I manually tag faces, it can take about 20 seconds before I can tag another one. If I try tagging it give me a "busy, try again later" error.

I have found that if I navigate in the reverse order when tagging, sometimes, the tagging is faster - sub second. I get to tag about 4 or so pics and then it slows down again.

not sure if this helps...

@pabsi
Copy link

pabsi commented Oct 2, 2023

Hi there @lastzero , the Photoprism team, and its awesome community,
I was about to raise a new issue, but I think this one fits my usecase.

I have a huge amount of photos for which I manually have to tag faces to. It seems that Tensorflow does not play nicely with children growing from the baby stage, into toddlers, then kids, then teenagers. Obvious face change, but it does require more manual intervention from me. Also, going to public paces (a zoo, a museum, a restaurant, etc) catches lots of unwanted people.

I often found myself having to edit many faces per photo, and find this process extremely tedious and slow. I think, in my humble opinion, and ideally, we shouold be able to do all changes in one photo (add, remove, modify face tags) and when leaving the photo, commit the changes to the DB. Again, in my humble opinion, the way it works now (make change, wait for it to be committed) it's very very slow and underperforming.

Unsure if this GitHub issue is for the same purpose, but thought I'd mention it here first, before raising a new issue unnecessarily.

Thank you so much for this amazing piece of software 🙏

@richardpickett
Copy link

richardpickett commented Oct 6, 2023

I'm having this same issue. 26,000+ photos, mostly Asian family. I'm happy to provide as much info as possible, if it's helpful in resolving this issue.

running photoprism/photoprism:ubuntu on a k8s w/ mariadb:10.11

version 230923-e59851350-Linux-AMD64-Plus

Sometimes manually tagging will take 6+ minutes (update: 8+ minutes), with usual wait times around 2 minutes. During the wait I can see 20+ messages like this:

time="2023-10-06T15:53:24Z" level=warning msg="faces: failed removing merged clusters for subject js1xgms3dgksr08g"

Each with a different subject name.

I've run:
photoprism migrations run -f - no output, completes in less than a minute

photoprism index --cleanup - (a) warnings on mp4s that are too big, (b) errors on jpgs making thumbnails (unexpected EOF while decoding), and (c) a lot of failed removing merged clusters for subject <****>

I'm adept on mysql, k8s, bash, etc, so I'm completely comfortable with low-level debugging to help resolve this - just warn me before we do something that may potentially be destructive (also, would like to know where the db backup saves so I can copy it off as needed).

lastzero added a commit that referenced this issue Oct 15, 2023
Signed-off-by: Michael Mayer <michael@photoprism.app>
lastzero added a commit that referenced this issue Oct 15, 2023
Signed-off-by: Michael Mayer <michael@photoprism.app>
lastzero added a commit that referenced this issue Oct 15, 2023
Signed-off-by: Michael Mayer <michael@photoprism.app>
@lastzero lastzero added priority Supported by early sponsors or popular demand and removed important labels Dec 14, 2023
@stephanvierkant
Copy link

I'm having the same issue. It takes about 30-60 seconds to add faces. While it would be great to improve the performance, could it be possible to have it done by a background process? I think it shouldn't block the front end.

@graciousgrey
Copy link
Member

We will take care of this as soon as we have released the new authentication options we are currently working on :)

@trop1kal
Copy link

trop1kal commented Jan 28, 2024

Awesome! I notice the delay when tagging manually tagging faces as well.
Takes upwards of 2-3mins in most cases.

You guys rock! TY in advance!

@niclan
Copy link

niclan commented Mar 13, 2024

Same, takes minutes with CPU usage on the server ~30%+ and then peaking at 100% right before finishing. And sometimes it takes just seconds.

It seems like the server is blocking while this is going on.

A bit under 150K images.

@nodecentral
Copy link

Just wanted to add to this, and share how inconsistent it can be when manually tagging (or de-tagging) faces. As such a key part of the product for me (and to help my aging parents remember people from their past) - anything that can be done to speed things up would be amazing..

The face tagging feature is the most important feature for a number of people - thank you so much for making it available

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working performance Performance Optimization priority Supported by early sponsors or popular demand
Projects
Status: Development 🐝
Development

No branches or pull requests