Skip to content

feat: Picasa-style People album for the gallery - #116

Merged
IAmJSD merged 7 commits into
mainfrom
feat/gallery-people
Sep 5, 2026
Merged

IAmJSD merged 7 commits into
mainfrom
feat/gallery-people

Conversation

@IAmJSD

@IAmJSD IAmJSD commented Sep 5, 2026 •

Copy link
Copy Markdown
Member

What

A People album for the gallery, the way Picasa did it: faces are found as photos index, you name them in a viewer, and each person becomes a sidebar album you can browse and search.

  • Detection runs on every thumbnail through the loader, using the existing UltraFace face model (renamed "Faces (Detection)" in Manage Models). Detections are cached beside thumbnails (.faces) and carried in the index snapshot, now SCHIDX2 (v1 still reads).
  • Recognition is a new catalogue model, face-embed: SFace from the OpenCV Zoo (38.7 MB, Apache-2.0, commit-pinned, hash-checked). Big faces are cropped from the thumbnail; small ones from a 1024 px decode kept from rendering the thumbnail (a thumbnail cached before the models arrived earns one more decode of the original, once). Embedding failures are recorded as tried so no photo is re-queued forever, and both models are released when indexing goes idle. Naming a face teaches it: every unnamed face in the library above a 0.5 cosine of the person's mean vector is put with them at once as an automatic tag (marked "auto", one-click "Not them"), and faces indexed later get the same pass. Between 0.45 and 0.5 a face is only offered with an "Is this …?" prompt. Only hand-named faces feed the mean, and a "not them" is remembered per name so the face is never put back.
  • Viewer: Space on a selected photo, the tray's View button, or "View & name people" in the photo menu. Faces are boxed; click one, type a name, Enter. Names autocomplete. Drag a box for a face the detector missed; "Not a face" dismisses a detection. Arrows step between photos, Escape backs out. Double-click still goes to the editor.
  • Sidebar PEOPLE section: a row per person (avatar, count) plus "Unnamed faces". Click to view their photos; right-click to rename (renaming to an existing name merges) or forget. With a bucket or folder on show, the rows work inside it: counts are the person's photos in that bucket, the grid shows only those, and the header reads "People · Ann · in Trip".
  • Search: a person's name in the search box pulls their photos in ahead of the CLIP ranking, labelled "· with Name". The box now appears once anyone is named, even without the search models, since names and places need none.
  • gallery_people MCP tool on both the in-app and stdio servers; docs/gallery.md has a People section.
  • While the two models download, the PEOPLE section (and the viewer's panel) show a progress bar in place of the "Find faces…" link.
  • Also fixes three clippy lints in the telemetry module that main currently fails on.

Verified

  • Unit tests in schist-gallery, schist-neural and the app's library module; clippy -D warnings and rustfmt clean on the touched crates.
  • Auto-tagging verified live: naming one Biden portrait "joe" put the other portrait with him automatically (tray: "Named joe · 1 more face matched automatically").
  • Headless GUI run on a 135-photo test library: 10 faces found across 7 public-domain portraits, none on 128 synthetic images; naming, suggestion (second Biden portrait suggested "joe" after one tag), person filter, name search and persistence all confirmed by screenshot.
  • Model under tract: detection ~21 ms per thumbnail, embedding ~60 ms per face. On the test portraits the same person scored 0.48–0.79 and different people at most 0.44, hence the 0.45 bar.

Performance

The sidebar's People counts are a cached summary recomputed only when the index, the people, or the bucket/folder/map filter change; scanned entries are indexed by path; a loader batch auto-tags only its own photos. Nothing in the gallery's render path walks all photos or all tags per frame. Last launch's counts are persisted (people.json in the state dir) and shown from the first frame until the indexer has caught up, so the unnamed tally does not creep up on load; the idle indexer waits for the snapshot restore instead of re-reading per-photo caches.

Notes for review

  • Library::save() is a no-op under cfg!(test) so unit tests cannot write the developer's library.json.
  • gpui gotcha that cost a rebuild: an .absolute().size_full() canvas with no offsets lands at its static position; the viewer's bounds probe needed .top_0().left_0().

🤖 Generated with Claude Code

IAmJSD and others added 7 commits September 5, 2026 17:17
Faces are detected as thumbnails index (UltraFace, the existing
"face" model) and, with the new SFace recogniser (OpenCV Zoo,
Apache-2.0), embedded so unnamed faces can be suggested as people
already named. A viewer (Space, the tray's View button, or the
photo menu) shows a photo big with its faces boxed; click one, type
a name, Enter. Missed faces are drawn by hand, wrong detections
dismissed. The sidebar lists people with avatars and an Unnamed
album; a person's name in the search box pulls their photos in
first. Names persist in library.json, detections in a .faces cache
and a v2 index snapshot (v1 still reads). gallery_people is exposed
on both MCP servers.

Also fixes three clippy lints in the telemetry module inherited from
main so the branch lints clean.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Naming a face now runs the recogniser over every unnamed face in the
library: those above a 0.5 cosine of the person's mean vector are put
with them as automatic tags (marked "auto", with a "Not them" button),
and newly indexed faces get the same pass as they arrive. Between 0.45
and 0.5 a face is still only offered. Only hand-named faces feed the
mean, so a wrong guess cannot steer the next; saying "not them" is
remembered per name so the face is not put back.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
While the detector and recogniser download, the sidebar's PEOPLE
section (and the viewer's people panel) show a progress bar in place
of the "Find faces…" link — the photo-search bar's twin, both files
counted as one so it runs once from nothing to done.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Clicking a person no longer drops the bucket: their photos are shown
within it, the sidebar counts (and the unnamed tally) are theirs in
that bucket, and the header says so ("People · Ann · in Trip"). The
same holds for a folder. Clicking the person again lifts the filter
and the bucket is back as it was.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Two costs that made a fresh library churn on load. Every photo with
faces was decoded a second time at 1024 px for the recogniser's crops:
now big faces crop from the thumbnail, and small ones use the larger
decode kept from rendering the thumbnail (only a thumbnail cached
before the models arrived earns one more decode). And a face whose
embedding failed stayed "owed" and was re-queued on every idle pass
forever: failures are recorded as tried, a recogniser that is
installed but will not load switches recognition off for the session,
and the readiness check no longer loads a model on the UI thread.
Both face models are released when the loader goes idle, like the
snapshot save; they reload in a third of a second when needed.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
The sidebar's counts were recomputed per frame: each tagged photo
looked up by walking every scanned entry, and each detected face
checked against every tag in the library — millions of comparisons a
frame on a real library, which is what made the gallery lag behind
main. Counts are now computed once per change (a cached summary keyed
on the index generation, the people revision, and the bucket, folder
and map filters), entries are indexed by path, the unnamed tally uses
per-photo claim maps, the scope is resolved once per pass, a loader
batch auto-tags only the photos it just found faces in, and the
viewer's "n of m" is worked out once on opening.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
The unnamed tally climbed batch by batch at launch: the idle indexer
re-read per-photo face caches before the index snapshot had been read
back, and a snapshot written before the last photos were indexed left
it climbing after that too. Last launch's whole-library counts are now
kept in the state directory (people.json, by name) and shown from the
first frame until the indexer has caught up, and the indexer waits for
the snapshot rather than re-deriving what it is about to be handed.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@IAmJSD
IAmJSD merged commit 0766cf4 into main Sep 5, 2026
4 checks passed
@IAmJSD
IAmJSD deleted the feat/gallery-people branch September 5, 2026 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant