Person Re-Identification Search
Re-identification finds the same person across cameras that never overlap, matching clothes and shape since faces are usually too small to help.
Why Does This Exist?
One camera sees a shopper enter; another, three aisles away, sees someone leave. Faces are blobs at that resolution and the cameras never share a frame. Face recognition has nothing to work with, and a human operator can't watch every feed. Security and retail analytics still need the answer: same person or not.
Re-identification (ReID) exists for this cross-camera matching. It learns clothing, shape, and gait signatures that survive viewpoint and lighting jumps, then ranks gallery crops by similarity to a probe. Trackers like DeepSORT consume those matches to hold identities in multi-object tracking.
This page covers the embedding-and-ranking mechanism plus the two metrics that judge it. The training loss itself lives on the triplet loss page.
Think of It Like This
Spotting a friend in away-game colors
You lose your friend in a stadium crowd and scan the far stand for their walk, jacket blocks, and height rather than their face, which is far too small. A changed scarf fools you; a distinctive backpack saves you. ReID networks scan galleries the same way, ranking crops by learned appearance signatures.
The analogy stops at the failure it hides: when everyone wears black winter coats, you fail exactly where ReID fails, and only gait or context rescues either of you.
How It Actually Works
The embedding and the ranking
A backbone network maps each pedestrian crop to an embedding vector, often with part branches for head, torso, and legs so occlusion of one part leaves the others votable. At query time the probe embedding (the person you're searching for) is compared against every gallery embedding (the candidate crops) by distance, closest first. The output is a ranked list, not a yes-or-no verdict.
How the space gets trained
Training uses triplet loss with hard mining plus a classification head: an anchor crop is pulled toward a crop of the same person and pushed away from a crop of someone else. Short-term benchmarks assume one outfit per identity, so models lean hard on shirt color. That shortcut is the source of the clothes-change pitfall below.
Worked example: rank-1 versus average precision
A probe returns five gallery crops with two true matches at ranks 1 and 4. Two metrics read this list differently. CMC rank-1 accuracy asks only whether the top hit is correct, so it scores . Average precision (AP) averages precision at each true hit: at rank 1 and at rank 4, giving . CMC praises the top hit; AP punishes burying the second match at rank 4. Report both, because a system with rank-1 and AP still strands half its evidence.
Code
def average_precision(relevant): hits = 0 total = 0.0 for rank, rel in enumerate(relevant, start=1): if rel: hits += 1 total += hits / rank return total / hits
ranks = [1, 0, 0, 1, 0] # true matches at ranks 1 and 4print(average_precision(ranks)) # -> 0.75print(ranks[0]) # -> 1 (rank-1 accuracy is 1.0: the top hit is correct)Watch Out For
Clothes-change blindness in long deployments
Short-term benchmarks assume one outfit per identity, so models lean on shirt color and collapse when people change clothes. The symptom is rank-1 accuracy halving across days. Fix it by training on clothes-change datasets and weighting face, gait, and body-shape cues that survive a wardrobe swap.
Trusting rank-1 accuracy alone
Rank-1 only checks the top hit, so a list with the second true match buried at rank 40 still scores perfectly. The symptom is a demo that looks flawless while operators drown in false leads below rank 1. Always report mean average precision alongside rank-1; the worked example above shows how far apart they can fall.
The Quick Version
- ReID matches pedestrians across cameras with no overlapping views, using clothing, shape, and gait signatures ranked by embedding distance.
- Part-based embeddings keep working when one body part is occluded.
- Triplet loss with hard mining plus a classification head trains the ranking space.
- Rank-1 accuracy checks only the top hit; average precision punishes burying later matches.
- Outfit changes defeat clothes-biased models, so test across days, not minutes.