PictoPy icon indicating copy to clipboard operation
PictoPy copied to clipboard

BUG: face search misses everyone but the first face in a group photo

Open harshvardhanrp opened this issue 2 months ago • 3 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

What happened?

Face search only compares the first stored face of a photo. Anyone who is not the first detected face in a group shot cannot be found at all.

Reproduced with the photos already in the repo. The detector finds 3 faces in tests/inputs/three_khans.png, and neither shipped portrait matches face 0:

amir_khan.png    cosine vs the 3 faces [0.257, 0.713, 0.348] -> face 1
salman_khan.png  cosine vs the 3 faces [0.124, 0.235, 0.836] -> face 2

Searching with salman_khan.png returns 0 results even though he is in the library. Searching with amir_khan.png returns only his solo portrait and not the group photo.

The cause is get_all_face_embeddings in backend/app/database/faces.py. It keys its result by image_id, so a photo with N faces collapses into one row and the other embeddings are dropped. The same loop appends tags once per join row, so a photo with 3 faces and 3 tags comes back with 9 tag entries instead of 3.

A face row with a null bbox also kills the whole search, because json.loads(None) raises TypeError and only JSONDecodeError is caught.

Steps to reproduce:

  1. Add a folder with a group photo plus a solo portrait of someone who is not the first face detected in it
  2. Let AI tagging finish
  3. Search by face using the solo portrait
  4. The group photo is missing from the results

Not a duplicate of #1164. That one is about clusters showing fewer photos than search. This one is search itself returning too few.

Record

  • [x] I agree to follow this project's Code of Conduct

harshvardhanrp avatar Oct 02 '26 10:10 harshvardhanrp

👋 Thanks for opening this issue! The maintainers will review it shortly. Till then, do not open any PR. This is a strict rule we like to follow around here :)

github-actions[bot] avatar Oct 02 '26 10:10 github-actions[bot]

⚠️ Potential Duplicate Issue (Semantic Match)

This issue appears semantically similar to the following issues in AOSSIE-Org/PictoPy:

  1. BUG: Face clusters show fewer photos than face search for the same person (#1164, open) https://github.com/AOSSIE-Org/PictoPy/issues/1164 Similarity: 66.3%

  2. BUG: Face Clustering Algorithm Fails to Detect Similar/Identical Faces (#348, closed) https://github.com/AOSSIE-Org/PictoPy/issues/348 Similarity: 65.6%

  3. BUG: Face Clustering Quality Issues (#793, closed) https://github.com/AOSSIE-Org/PictoPy/issues/793 Similarity: 65.1%

Please review before proceeding.

github-actions[bot] avatar Oct 02 '26 10:10 github-actions[bot]

Link your account with Gitcord

Thanks for opening this issue, @harshvardhanrp!

To receive Discord notifications and contributor tracking for this organization:

  1. Join Discord: https://discord.gg/hjUhu33uAn
  2. In Discord, run /link harshvardhanrp
  3. Paste the verification code into your GitHub bio (or a public gist)
  4. Click Verify in Discord (or run /verify-link harshvardhanrp)

Once linked, Gitcord can notify you about assignments, mentions, and more.

— Posted by Gitcord

gitcordapp[bot] avatar Oct 03 '26 20:10 gitcordapp[bot]