layumi/Person_reID_baseline_pytorch
:bouncing_ball_person: Pytorch ReID: A tiny, friendly, strong pytorch implement of person re-id / vehicle re-id baseline. Tutorial 👉https://github.com/layumi/Person_reID_baseline_pytorch/tree/master/tutorial
What is this repo?
Person ReID Baseline (PyTorch) is an open‑source code base for object‑re‑identification – the task of matching images of the same person (or other objects) across different camera views. It provides a compact, ready‑to‑run implementation of many tricks that have become standard in the research literature since 2017, all built on PyTorch.
Key points (from the README)
| Aspect | Details |
|---|---|
| Goal | Offer a strong (state‑of‑the‑art performance), small (fits in ~2 GB GPU memory with bf16/fp16), and friendly (easy to turn on/off tricks) baseline for person re‑identification. |
| Performance | Using only a softmax loss the baseline reaches Rank@1 ≈ 88 %, mAP ≈ 71 % on the Market‑1501 benchmark. |
| Supported models | ResNet, ResNet‑IBN, DenseNet, HRNet, EfficientNet, Swin Transformer, Swin‑V2, ConvNeXt, DinoV3, and more. |
| Losses | Cross‑entropy, Circle, Triplet, Contrastive, Sphere, Lifted, ArcFace, CosFace, Instance, and others. |
| Training tricks | bf16/fp16, random erasing, linear warm‑up, torch.compile, DDP (multi‑GPU), synthetic DG‑Market dataset, adversarial training, etc. |
| Inference / testing | TensorRT, PyTorch JIT, Conv‑BN fusion, multiple‑query evaluation, GPU‑accelerated re‑ranking, visualisation of rankings and heat‑maps. |
| Resources | 8‑minute tutorial, Chinese video, Colab notebook for free‑GPU training, pre‑trained model downloads. |
| Licensing | MIT License. |
| Community | Over 2 500 citations, several thousand GitHub stars, and a history of updates up to 2026 (e.g., DinoV3 support). |
How to get started (quick‑start)
- Install – clone the repo and install the required Python packages (PyTorch ≥ 1.8, plus the listed dependencies).
- Prepare data – follow the Dataset Preparation section to download and format a re‑ID dataset such as Market‑1501.
- Train – run a single command, e.g.:
Add flags likepython train.py --train_all # vanilla ResNet‑50 python train.py --use_swin --name swin # Swin‑Transformer model--fp16,--circle,--DG,--usamto enable specific tricks. - Test / evaluate – after training, evaluate with:
python test.py --name <model_name> python evaluate_gpu.py # fast GPU re‑ranking - Visualise – use the provided demo scripts to see ranking results or heat‑maps.
Who might use this?
- Researchers needing a reliable baseline to compare new re‑ID ideas against.
- Practitioners who want a ready‑made, memory‑efficient model for deployment (e.g., on edge GPUs).
- Students looking for a tutorial‑style code base that demonstrates common computer‑vision training tricks.
Why it matters
Person re‑identification is a core component of many surveillance, retail analytics, and autonomous‑vehicle perception pipelines. By bundling a wide range of modern architectures, loss functions, and performance‑optimising tricks into a single, well‑documented repository, this project lowers the barrier to entry and speeds up experimentation.
Citation
If you use the code or the pre‑trained models in a publication, cite the repository as indicated in the README (the authors provide a ready‑to‑copy BibTeX entry).
Related
- Project
- Project
- Project
- Dispatch
- Project