Repository navigation
Conversation
Nearest-member search by cosine distance (same as pgvector <=>) and the metrics for open-set 1:N identification: FPIR, misID, FNIR, FDR, exact threshold for a target FPIR, EER, CMC, distance distributions, d-prime, 1:1 TAR@FAR, Wilson intervals and per-identity counts. Pure numpy. The eval/ folder ignores images, embeddings and results so personal data can't be committed.
Load a <root>/<identity>/<image> dataset (optional labels.csv with face boxes and enroll/probe roles) and split it into enrolled members, their probe photos and strangers. Every image goes through FaceEmbeddingService.detect_faces with the model wrapped in a recorder, and is cached per image. A parity check re-enrolls identities through the real compute_average_embedding and fails the run if the harness's 'current' template differs. Enrollment strategies: current (faces[0], mean of raw embeddings, as in production), largest face, most confident face, normalized mean, and keeping all K vectors.
Enroll the gallery with a strategy, pick each probe's labelled face (by box, or nearest the centre) and search it. Failed enrollments make that person a stranger, as in the app. Detection misses are counted for the end-to-end FNIR.
python -m eval.face_matching runs the protocol over gallery sizes, seeds and strategies, and writes report.md (with a metrics glossary), summary.json, per-seed JSON, operating-point and DET CSVs and plots. --checkpoint-every writes interim reports during long extractions, identities are extracted in a seeded random order so each checkpoint is a random sample, and --cached-only evaluates what is already cached.
python -m eval.face_matching.photos stats reports faces per photo, face sizes in original and detector pixels, detector confidence, and the faces the production detector size misses compared with a larger one.
Metrics against hand-computed cases (FPIR, FNIR, misID, FDR, exact threshold, CMC, Wilson), strategy outputs, probe face selection, the gallery/stranger split and enroll/probe roles, and extraction plus the parity check with a fake insightface model.
Method, metric definitions, commands, and results on an LFW subset and on detection stats for one set of event photos. Decisions on the threshold, single-face auto-approval, enrollment method and detector size are left open.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #111. This adds an offline harness that measures how often the photo worker sends a photo to the wrong person (FPIR, misID) or misses the right one (FNIR), plus first results. No app code changes. The threshold and enrollment decisions are left for a follow-up, once we have labelled MicroClub data.
What's added
backend/eval/face_matching/backend/eval/face_matching/photos.pybackend/tests/unit/test_eval_face_matching.pymake testbackend/docs/face-matching-eval.mdThe harness isn't part of
make testor CI, since it needs model weights and a dataset. Images, embeddings and results stay outside the repo;backend/eval/.gitignoreis a second safety net.How it measures
FaceEmbeddingService.detect_faces. Before any metric is computed, a parity check re-enrolls a sample of identities through the realcompute_average_embeddingand stops the run if the harness's template differs. It matched exactly (max |diff| = 0.0) on every run.MIN_ENROLL_IMAGES= 3 photos. Their other photos are searched against a gallery of N members, and photos of people who aren't enrolled are searched too. The search uses exact cosine distance, identical to pgvector<=>(there's no ANN index onface_embedding). Results are the mean over 5 seeds, with 95% Wilson intervals.current(production):faces[0], mean of raw embeddings.Results 1: LFW (public dataset, random subset)
The run used 4,556 images of 2,152 people, of whom 238 can be enrolled. That's the part extracted before the full run was paused; the subset is a seeded random sample of identities. Gallery sizes were 50 and 238.
Production method (
current):Rank-1 is 99.99%, EER is 0.20%, failure-to-enroll is 0.17%, and detection misses are 0.07%.
Members' photos sit around 0.26 from their own template, and strangers' photos around 0.82 from the closest member. 0.5 sits well inside the gap, so on LFW it is conservative: about 1.4% of members' photos are missed.

The one false match at 0.5 is caused by
faces[0]enrollment. One of Bob Hope's enrollment photos contains two faces, andfaces[0]is Jane Russell's. His averaged template therefore partly contains her face, and her photo matches him at distance 0.495. On this data, 7.8% of multi-face photos havefaces[0]≠ the labelled person. In the app, the same thing happens when a selfie shows someone in the background.Results 2: MicroClub event photos (detection only)
These are 472 photos from one event camera folder ("Cam 250D", 6000×4000 JPEGs), used with members' written consent. They're unlabelled and no selfies were provided, so FPIR and FNIR weren't measured on this set. Only detection was analysed.

What this doesn't decide yet
LFW is easy (frontal, well-lit celebrity photos), and 238 members is a small gallery. These results show the harness works and expose the
faces[0]problem. They don't justify changingPHOTO_WORKER_SIMILARITY_THRESHOLD. Still open from #111:labels.csvwithrole=enroll/probeHow to reproduce
Each run writes
report.md(every metric with a glossary),summary.json, per-seed JSON, CSVs and plots.Testing
uv run ruff check .anduv run mypy .are clean.uv run pytest tests/unit: 257 passed.