Pytorch ReID: the 2017 baseline that still trains on a laptop GPU
: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
At a glance
- What is it?
- Person_reID_baseline_pytorch is layumi's tiny, friendly, strong PyTorch baseline for object re-identification, covering person and vehicle re-ID since 2017 under MIT. It reaches Rank@1 88.24 percent and mAP 70.68 percent with softmax loss alone, trains in as little as 2GB of GPU memory using native bf16 and fp16, offers a menu of loss functions from triplet to Arcface, and added DinoV3 support in February 2026.
- Who is it for?
- Start from this repository when entering object re-identification, person or vehicle, since the 8 minute tutorial, per dataset preparation scripts, one line tricks and Colab notebook remove the usual week of glue code, and its results are consistent with the baselines used in top conference papers. Move to a framework like torchreid or a more recent method implementation when you need a maintained engineering surface rather than a research baseline.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 11 days ago.
- What is it written in?
- Mainly Python, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on October 2, 2026, and from our analysis. They are not legal advice.
Editorial analysis
Strong, small, friendly, since 2017
The project's three word identity is earned, not decorative. Strong, because it is consistent with the new baseline result in several top conference works, naming Joint Discriminative and Generative Learning for Person Re-identification from CVPR19, Beyond Part Models from ECCV18 and Camera Style Adaptation from CVPR18, and reporting Rank@1 88.24 percent with mAP 70.68 percent using only softmax loss. Small, because with bf16 or fp16 supported natively by PyTorch, the baseline trains with only 2GB of GPU memory. Friendly, because off the shelf options apply many state of the art tricks in one line, and newcomers get an 8 minute tutorial before touching the code. The repository has served as the object re-ID entry point since 2017, maintained by layumi under MIT, with the last push on 2026-09-24.
2GB of GPU memory, native half precision
The memory claim is the Small in the tagline, and the mechanism is deliberately boring in the best way, bf16 and fp16 as supported by native PyTorch, explicitly replacing apex, the deprecated third party mixed precision library that older baselines depended on. That single choice is what moves training from datacenter GPUs to a laptop with a small card, or to the free GPU tier of Google Colab, for which a dedicated colab directory exists thanks to a named contributor. Training speed gets its own attention, torch.compile for faster compilation and DDP for multiple GPUs with a train_DDP.py entry and a DDP.sh driver script, so the same baseline scales from a free notebook to a cluster without changing code shape.
A menu of losses and backbones
The training feature list reads as a survey of metric learning. Losses include Circle Loss, Triplet Loss, Contrastive Loss, Sphere Loss, Lifted Loss, Arcface, Cosface and Instance Loss, with dedicated source files for circle_loss and instance_loss visible in the repository root. Backbones span generations, ResNet, ResNet-ibn and DenseNet from the classic era, Swin Transformer, EfficientNet and HRNet from the modern one, with timm and efficientnet_pytorch in the requirements supporting the wider catalog. Part-based Convolutional Baseline, PCB, is supported as a training strategy, and the augmentation staples Random Erasing and Linear Warm-up are built in. The friendly claim cashes out here, each of these is an option switch rather than a code merge, the difference between trying Arcface and reading a paper about it.
One prepare script per dataset
Dataset onboarding is a row of prepare scripts at the root, prepare_Duke, prepare_MSMT, prepare_viper, prepare_CUB, prepare_VeRi and prepare_VehicleID, the last two naming the vehicle re-identification half of the project's scope, with test_MSMT.py acknowledging that dataset's peculiarities and prepare_static and dgfolder supporting the synthetic DG-Market, described as a 10x large synthetic dataset from Market, a CVPR 2019 Oral. The pattern matters for newcomers, the annoying step in re-ID is always reshaping a downloaded archive into the directory layout the training code expects, and here each dataset has a script doing exactly that once. The repository also keeps leaderboards for the main benchmarks plus two specialized ones, 3D and RGB-Infrared, collecting results beyond the standard Market and Duke setup.
TensorRT, JIT, and fused Conv-BN at test time
The testing side has its own feature list aimed at deployment speed. TensorRT export has a dedicated test_with_TensorRT.py and its own release note in the version history, PyTorch JIT is supported, and the classic inference optimization of fusing a Convolution and BatchNorm layer into a single Convolution is available, the trio that turns a training model into a fast serving model. Multiple Query Evaluation extends the standard protocol, and re-ranking is supported on CPU with the re_ranking.py implementation and on GPU through the GPU-Re-Ranking directory, the accuracy squeezing technique that reorders retrieval results using mutual neighbors. The provided hyperparameters and architectures generate the documented results, with the honest note that some, the learning rate explicitly, are far from optimal, and users are invited to change them and see the effect.
Visualization from curves to heatmaps
Understanding what a trained model does gets three dedicated tools. Training curves can be visualized to watch loss and metric progression, the ranking result can be visualized to see which gallery images a query retrieved, in order with distances, the closest thing re-ID has to a demo, and a heatmap visualization script in the dev branch shows which image regions drive the embedding, the interpretability window into what the network attends to. For a field where a baseline can silently learn background shortcuts, the heatmap tool is the debugging instrument, and demo.py plus a bundled show image suggest the visualization path is intended to be run early, not discovered late.
A tutorial in eight minutes, in three languages
The onboarding material is unusually complete. An 8 minute tutorial exists in the repository, a Chinese version on Zhihu, and a Chinese video introduction on Bilibili, with an Answers to Quick Questions file covering the follow ups tutorials always generate. The requirements list is short, pyyaml, pretrainedmodels, timm, scipy, efficientnet_pytorch, pytorch_metric_learning, tqdm, gdown and matplotlib, a refreshingly small surface for a deep learning project, consistent with the tiny identity. The project's homepage links to the author's academic site, and the repository even carries a sitemap.xml, the odd but telling artifact of a project treated as a small website of its own.
DinoV3 in 2026, and a geo-localization spinoff
Development continues on the main line, with the newest item adding support for DinoV3 through a --use_dino flag on 16 February 2026, and the release history showing v1.0.3 adding instance loss support and a feature dimension change in 2021, v1.0.4 adding TensorRT and adversarial training in 2022, and v1.1.0 updating bfloat16 in May 2025. Around the code runs an academic community, workshops on multimedia object re-ID held at ACM ICMR 2024 in Phuket with a TOMM special issue connection and at ACM WWW 2025, a special session at IEEE ITSC 2023, and pointers to related work like the large person language model APTM. The README also pitches the graduation path, the same retrieval and metric learning skills transfer almost one to one to cross-view geo-localization, drone to satellite to street, starting from the author's University-1652 benchmark, an ACM MM 2020 dataset with 500 plus citations built in the same tiny, friendly, strong style.
Editorial conclusion
Start from this repository when entering object re-identification, person or vehicle, since the 8 minute tutorial, per dataset preparation scripts, one line tricks and Colab notebook remove the usual week of glue code, and its results are consistent with the baselines used in top conference papers. Move to a framework like torchreid or a more recent method implementation when you need a maintained engineering surface rather than a research baseline. Before training, read the provided hyperparameters with the project's own warning that some, including the learning rate, are far from optimal, verify your dataset's prepare script exists, and note the sister Matconvnet repository when comparing across frameworks, since each tunes differently.
Frequently asked questions
What is Person_reID_baseline_pytorch?
Person_reID_baseline_pytorch is a tiny, friendly, strong PyTorch baseline for object re-identification, covering person and vehicle re-ID, maintained since 2017 under the MIT license. It reports Rank@1 of 88.24 percent and mAP of 70.68 percent using only softmax loss, and trains in as little as 2GB of GPU memory with native bf16 or fp16.
Which loss functions does Person_reID_baseline_pytorch support?
Circle Loss, Triplet Loss, Contrastive Loss, Sphere Loss, Lifted Loss, Arcface, Cosface and Instance Loss are all available as off the shelf options, alongside the part-based PCB strategy and Random Erasing augmentation, each applied through one line options rather than code changes.
How do you get started with Person_reID_baseline_pytorch?
Read the 8 minute tutorial in the repository first, with its answers to quick questions, prepare your dataset with the matching prepare_ script such as prepare_Duke or prepare_MSMT, then train and evaluate with the provided scripts. A free GPU path exists through the colab directory for Google Colab.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/layumi-person-reid-baseline-pytorch)