Evaluating thresholds¶
DoppelSort ships default models and thresholds for general use, but face detection and embedding quality depend on your images. The evaluation harness measures accuracy, false-accept rate (FAR), and false-reject rate (FRR) on a labeled pair set so you can validate or tune those defaults.
Create a labeled pair set¶
Create a CSV with two image paths and a truth label per row. Relative paths are resolved against the CSV file's directory:
image_a,image_b,label
people/alice-1.jpg,people/alice-2.jpg,same
people/alice-1.jpg,people/bob-1.jpg,different
Accepted positive labels are 1, true, yes, same, and match. Accepted
negative labels are 0, false, no, different, and nonmatch.
Run the evaluation¶
uv run python benchmarks/evaluate_pairs.py --pairs pairs.csv
uv run python benchmarks/evaluate_pairs.py --pairs pairs.csv --sweep
Options:
| Option | Default | Description |
|---|---|---|
--pairs |
required | CSV with image_a,image_b,label columns. |
--model-name |
ArcFace |
Embedding model. |
--detector-backend |
retinaface |
Face detector backend. |
--threshold |
per model | Override the configured model threshold. |
--sweep |
off | Print accuracy/FAR/FRR across candidate thresholds. |
The script caches one embedding per image path, so repeated appearances in the pair list do not repeat inference.
Metrics¶
For a given threshold, a pair is predicted as same when
distance <= threshold.
| Metric | Definition |
|---|---|
| Accuracy | (true_positives + true_negatives) / pairs |
| FAR | false_positives / (false_positives + true_negatives) |
| FRR | false_negatives / (false_negatives + true_positives) |
The best-observed threshold maximizes accuracy, then prefers lower FAR, then lower FRR, then the lower threshold.
Matching benchmark¶
benchmarks/benchmark_match.py measures the vectorized exact-search path with
synthetic vectors, separate from model quality:
Use it when changing the matching implementation; use the labeled-pair harness when changing models, detectors, or thresholds.