Skip to content

Re-ID

Re-ID provides tools to load and evaluate re-identification models. Extract appearance embeddings from cropped images or detection boxes, and compare model performance with retrieval and re-association protocols.

Person re-identification (Re-ID) recognizes the same person in different images: in another camera, or later in a video after they were out of view. A Re-ID model turns each crop of a person into an embedding, a vector of numbers. Crops of the same person get embeddings that are close together and crops of different people get embeddings far apart, so the distance between two embeddings tells how likely the two crops show the same person.

Gallery retrieval with the default model, osnet_x1_0_msmt17_combineall: crops ranked by cosine distance to a query player, closest first.


Install

pip install "reid==0.1.0rc1"

Quickstart

import numpy as np
import supervision as sv
from reid import ReIDModel

model = ReIDModel.from_pretrained("osnet_x1_0_msmt17_combineall")
frame = np.zeros((256, 128, 3), dtype=np.uint8)
detections = sv.Detections(xyxy=np.array([[0, 0, 128, 256]], dtype=np.float32))
embeddings = model.extract_embeddings(detections, frame)

print(embeddings.shape)  # (1, 512)

Guides

  • Load a model: use pretrained weights or load a saved model
  • Evaluate a model: how a query is ranked against a gallery, and how to measure a model's accuracy
  • Re-ID metrics: understand Rank-k, mAP, mINP, and MRR

Tutorials

  • How to Use Re-ID


    A query player and the first eight crops of the gallery ranked by distance, the same player at ranks 1 to 6

    Load a model, match the boxes of a MOT17 frame to a later frame with distance_matrix, see identities cluster, and evaluate with retrieval and re-association.

    Run Google Colab

  • How to Benchmark Re-ID Models


    A query player, a gallery of crops, and the gallery ranked by similarity with the matches outlined

    Evaluate OSNet x1.0 on Market-1501 and MSMT17 and compare against the torchreid model zoo.

    Run Google Colab