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

feat(server): optimize partial facial recognition #6634

Merged
merged 4 commits into from
Jan 25, 2024

Conversation

mertalev
Copy link
Contributor

@mertalev mertalev commented Jan 25, 2024

Description

Based on the discussion here, this PR changes facial recognition queuing:

  • Face detection will not queue facial recognition if no faces are detected
  • Only detected faces are queued, not all missing faces
  • A nightly job is added to do more thorough recognition
  • Manually running "missing" still does the more thorough recognition

Specifically, this is the new behavior for clustering:

  • If the face is a core face (i.e. there are min faces - 1 faces around it) and a person exists for it, clustering works as normal
  • If the face is a core face and there's no similar face with a person, a person is created, but the other faces aren't clustered unless they're in the same batch of new faces
  • If the face is a non-core face and there's a similar face with a person, clustering works as normal
  • If the face is a non-core face and there's no similar face with a person, then it won't be clustered

There is an edge case where this change can lead to a duplicate person: if a new person is created in the partial clustering and the faces similar to it existed before this batch of faces, then only the core face that created the person will be assigned this person until the nightly job runs. This means that if another image containing a face of this person is uploaded before the nightly job, then it will only be clustered if it can reach the face that created the person, not just any face of that person. If it can't and the face is a core face, a new person will be created.

Implementation notes:

  • The queue facial recognition job is added before adding the individual recognition jobs as a gatekeeper to prevent the jobs from running until all queued detection jobs are finished
  • The recognition jobs are queued within the detection handler instead of in onDone to support the more nuanced queueing
  • Bulk upload should work the same, just with a different queueing method

How Has This Been Tested?

Tested with debug logging to check that it queues the faces from Face Detection, not all missing faces.

@mertalev
Copy link
Contributor Author

No clue why those mobile tests are failing

Copy link

cloudflare-pages bot commented Jan 25, 2024

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: aef9d2e
Status: ✅  Deploy successful!
Preview URL: https://c8ec1a81.immich.pages.dev
Branch Preview URL: https://feat-optimize-partial-facial.immich.pages.dev

View logs

@mertalev mertalev marked this pull request as draft January 25, 2024 01:52
@mertalev mertalev marked this pull request as ready for review January 25, 2024 01:56
@mertalev mertalev marked this pull request as draft January 25, 2024 02:07
@mertalev mertalev marked this pull request as ready for review January 25, 2024 02:08
server/src/domain/person/person.service.ts Outdated Show resolved Hide resolved
@mertalev mertalev merged commit bd87eb3 into main Jan 25, 2024
24 checks passed
@mertalev mertalev deleted the feat/optimize-partial-facial-recognition branch January 25, 2024 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants