Detects people in a scene and matches them against a reference photo using appearance-based Re-ID embeddings — simulating a real surveillance/CCTV search use case ("find this person in this camera frame"). Draws bounding boxes with match confidence and a timestamp overlay, like a real camera feed.
This is the fallback stage of the larger pipeline: used when face recognition can't resolve an identity (face too small, occluded, or angled away from camera), falling back to whole-body appearance matching instead.
| Reference | Scene (matched) |
|---|---|
![]() |
![]() |
- Detection — YOLOv8n (nano, fast) detects all people in the scene image
- Embedding — each detected person crop, and the reference photo, are passed through OSNet (via TorchReID) to get an appearance embedding
- Matching — cosine similarity between the reference embedding and each detected person's embedding
- Decision — similarity ≥
MATCH_THRESHOLD(default 50%) is flagged green as a match, below is flagged red
.
├── reid_fr.ipynb # Full Colab notebook: setup, detection, matching, annotated output
├── assets/ # Demo reference/result images
├── LICENSE
└── .gitignore
Run the notebook top to bottom. It handles:
- Setup — installs PyTorch, TorchReID, and Ultralytics (YOLOv8)
- Model loading — YOLOv8n for detection, OSNet (
osnet_x1_0) for Re-ID embeddings - Image upload — prompts for a reference photo and a scene image
- Detection + matching — runs person detection on the scene, computes similarity to the reference for each detected person
- Annotated output — draws match/no-match boxes with similarity %, plus a timestamp overlay
MATCH_THRESHOLD (in the config cell) controls the similarity cutoff for a "match." Lower catches more true matches but risks false positives; higher is stricter. 50% is a starting point — worth tuning against a labeled test set before presenting real numbers.
- Market-1501 — recommended starting point, well-established Re-ID benchmark
- MSMT17 — larger, more realistic multi-scene benchmark
- WildTrack — multi-camera surveillance scenario, closest to the CCTV use case this module targets
- Clothing color detection (extra signal for matching when face/body angle is poor)
- Height estimation via MediaPipe Pose
- Multi-camera tracking timelines (matching the same person across multiple camera feeds)
- Auto-generated case file summaries
TorchReID (OSNet) · YOLOv8 · PyTorch · OpenCV · Google Colab (GPU runtime)

