MCPcopy Index your code
hub / github.com/layumi/Person_reID_baseline_pytorch

github.com/layumi/Person_reID_baseline_pytorch @v1.1.0 sqlite

repository ↗ · DeepWiki ↗ · release v1.1.0 ↗
110 symbols 502 edges 31 files 13 documented · 12%
README

Pytorch ReID

Strong, Small, Friendly

Python3.6+ License: MIT

A tiny, friendly, strong baseline code for Object-reID (based on pytorch) since 2017.

Share to

<a href="http://www.facebook.com/sharer.php?u=https://github.com/layumi/Person_reID_baseline_pytorch/" target="_blank">
    <img src="https://github.com/layumi/Person_reID_baseline_pytorch/raw/master/docs/1_Facebook_colored_svg_copy-64.webp" alt="Facebook" width="60"/>
</a>

<a href="https://twitter.com/share?url=https://github.com/layumi/Person_reID_baseline_pytorch/&amp;text=Strong,%20Small,%20Friendly%20Pytorch%20re-ID&amp;hashtags=pytorch re-ID" target="_blank">
    <img src="https://github.com/layumi/Person_reID_baseline_pytorch/raw/master/docs/2018_social_media_popular_app_logo_twitter-64.webp" alt="Twitter" width="60"/>
</a>

<a href="https://service.weibo.com/share/share.php?url=https://github.com/layumi/Person_reID_baseline_pytorch/&amp;text=Strong,%20Small,%20Friendly%20Pytorch%20re-ID&amp;hashtags=pytorch re-ID" target="_blank">
    <img src="https://github.com/layumi/Person_reID_baseline_pytorch/raw/master/docs/Weibo-64.webp" alt="Weibo" width="60" />
</a>

<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=https://github.com/layumi/Person_reID_baseline_pytorch/" target="_blank">
    <img src="https://github.com/layumi/Person_reID_baseline_pytorch/raw/master/docs/circle-linkedin-64.webp" alt="LinkedIn" width="60" />
</a>

<a href="mailto:?Subject=Strong, Small, Friendly Pytorch Re-identification&amp;Body=I%20saw%20this%20and%20thought%20of%20you!%20 https://github.com/layumi/Person_reID_baseline_pytorch/">
    <img src="https://github.com/layumi/Person_reID_baseline_pytorch/raw/master/docs/Email-64.webp" alt="Email" width="60"/>
</a>

Tutorial

Table of contents

Features

Now we have supported:

Training

  • bf16 and fp16 (Float16) to save GPU memory based on native pytorch (replace apex).
  • Running the code on Google Colab with Free GPU. Check Here (Thanks to @ronghao233)
  • DG-Market (10x Large Synthetic Dataset from Market CVPR 2019 Oral)
  • Swin Transformer / EfficientNet / HRNet
  • ResNet/ResNet-ibn/DenseNet
  • Circle Loss, Triplet Loss, Contrastive Loss, Sphere Loss, Lifted Loss, Arcface, Cosface and Instance Loss
  • Part-based Convolutional Baseline(PCB)
  • Random Erasing
  • Linear Warm-up
  • torch.compile (faster training)
  • DDP (Multiple GPUs)

Testing

  • TensorRT
  • Pytorch JIT
  • Fuse Conv and BN layer into one Conv layer
  • Multiple Query Evaluation
  • Re-Ranking (CPU & GPU Version)
  • Visualize Training Curves
  • Visualize Ranking Result
  • Visualize Heatmap

Here we provide hyperparameters and architectures, that were used to generate the result. Some of them (i.e. learning rate) are far from optimal. Do not hesitate to change them and see the effect.

P.S. With similar structure, we arrived Rank@1=87.74% mAP=69.46% with Matconvnet. (batchsize=8, dropout=0.75) You may refer to Here. Different framework need to be tuned in a slightly different way.

Some News

22 Dec 2024 We are holding a workshop at ACM WWW 2025 on Multimedia Object Re-ID. You are welcome to show your insights. https://www.zdzheng.xyz/MORE2025/ Submission DDL is 1 Jan 2025.

12 Jan 2024 We are holding a workshop at ACM ICMR 2024 on Multimedia Object Re-ID. You are welcome to show your insights. See you at Phuket, Thailand!😃 The workshop link is https://www.zdzheng.xyz/MORE2024/ . Submission DDL is 15 April 2024. Good papers will be recommended to ACM TOMM Special Issue (CCF-B). (Re-submission is needed.)

2023 News

12 Aug 2023 Large Person Langauge Model is currently available at HereGitHub stars accepted by ACM MM'23. You are welcomed to check it.

19 Mar 2023 We host a special session on IEEE Intelligent Transportation Systems Conference (ITSC), covering the object re-identification & point cloud topic. The paper ddl is by May 15, 2023 and the paper notification is at June 30, 2023. Please select the session code ``w7r4a'' during submission. More details can be found at Special Session Website.

9 Mar 2023 Market-1501 is in 3D. Please check our single 2D to 3D reconstruction work https://github.com/layumi/3D-Magic-Mirror GitHub stars.

Magic Mirror

2022 News

7 Sep 2022 We support SwinV2.

24 Jul 2022 Market-HQ is released with super-resolution quality from 128*64 to 512*256. Please check at https://github.com/layumi/HQ-Market

14 Jul 2022 Add adversarial training by python train.py --name ftnet_adv --adv 0.1 --aiter 40.

1 Feb 2022 Speed up the inference process about 10 seconds by removing the cat function in test.py.

1 Feb 2022 Add the demo with TensorRT (The fast inference speed may depend on the GPU with the latest RT Core).

2021 News

30 Dec 2021 We add supports for new losses, including arcface loss, cosface loss and instance loss. The hyper-parameters are still tunning.

3 Dec 2021 We add supports for four losses, including triplet loss, contrastive loss, sphere loss and lifted loss. The hyper-parameters are still tunning.

1 Dec 2021 We support EfficientNet/HRNet.

15 Sep 2021 We support ResNet-ibn from ECCV2018 (https://github.com/XingangPan/IBN-Net).

17 Aug 2021 We support running code on Google Colab with free GPU. Please check it out at https://github.com/layumi/Person_reID_baseline_pytorch/tree/master/colab .

14 Aug 2021 We have supported the training with DG-Market for regularization via Self-supervised Memory Learning. You only neeed to download/unzip the dataset and add --DG to train model.

12 Aug 2021 We have supported the transformer-based model Swin by --use_swin. The basic performance is 92.73% Rank@1 and 79.71%mAP.

23 Jun 2021 Attack your re-ID model via Query! They are not robust as you expected! Check the code at Here.

5 Feb 2021 We have supported Circle loss(CVPR20 Oral). You can try it by simply adding --circle.

11 January 2021 On the Market-1501 dataset, we accelerate the re-ranking processing from 89.2s to 9.4ms with one K40m GPU, facilitating the real-time post-processing. The pytorch implementation can be found in GPU-Re-Ranking.

2020 News

11 June 2020 People live in the 3D world. We release one new person re-id code Person Re-identification in the 3D Space, which conduct representation learning in the 3D space. You are welcomed to check out it.

30 April 2020 We have applied this code to the AICity Challenge 2020, yielding the 1st Place Submission to the re-id track :red_car:. Check out here.

01 March 2020 We release one new image retrieval dataset, called University-1652, for drone-view target localization and drone navigation :helicopter:. It has a similar setting with the person re-ID. You are welcomed to check out it.

2019 News

07 July 2019: I added some new functions, such as --resume, auto-augmentation policy, acos loss, into developing thread and rewrite the save and load functions. I haven't tested the functions throughly. Some new functions are worthy of having a try. If you are first to this repo, I suggest you stay with the master thread.

01 July 2019: My CVPR19 Paper is online. It is based on this baseline repo as teacher model to provide pseudo label for the generated images to train a better student model. You are welcomed to check out the opensource code at here.

03 Jun 2019: Testing with multiple-scale inputs is added. You can use --ms 1,0.9 when extracting the feature. It could slightly improve the final result.

20 May 2019: Linear Warm Up is added. You also can set warm-up the first K epoch by --warm_epoch K. If K <=0, there will be no warm-up.

2018 & 2017 News

What's new: FP16 has been added. It can be used by simply added --fp16. You need to update your pytorch to 2.0.

Float16 could save about 50% GPU memory usage without accuracy drop. Our baseline could be trained with only 2GB GPU memory.

python train.py --fp16

What's new: Visualizing ranking result is added.

python prepare.py
python train.py
python test.py
python demo.py --query_index 777

What's new: Multiple-query Evaluation is added. The multiple-query result is about Rank@1=91.95% mAP=78.06%.

python prepare.py
python train.py
python test.py --multi
python evaluate_gpu.py

What's new:  PCB is added. You may use '--PCB' to use this model. It can achieve around Rank@1=92.73% mAP=78.16%. I used a GPU (P40) with 24GB Memory. You may try apply smaller batchsize and choose the smaller learning rate (for stability) to run. (For example, --batchsize 32 --lr 0.01 --PCB)

python train.py --PCB --batchsize 64 --name PCB-64
python test.py --PCB --name PCB-64

What's new: You may try evaluate_gpu.py to conduct a faster evaluation with GPU.

What's new: You may apply '--use_dense' to use DenseNet-121. It can arrive around Rank@1=89.91% mAP=73.58%.

What's new: Re-ranking is added to evaluation. The re-ranked result is about Rank@1=90.20% mAP=84.76%.

What's new: Random Erasing is added to train.

What's new: I add some code to generate training curves. The figure will be saved into the model folder when training.

Trained Model

I re-trained several models, and the results may be different with the original one. Just for a quick reference, you may directly use these models. The download link is Here.

Methods Rank@1 mAP Reference
[EfficientNet-b4] 85.78% 66.80% `python train.py --use_efficient --name e

Core symbols most depended-on inside this repo

save_network
called by 8
utils.py
convert_label_to_similarity
called by 3
circle_loss.py
copy_file
called by 3
prepare_VeRi.py
k_reciprocal_neigh
called by 2
re_ranking.py
fuse_all_conv_bn
called by 2
utils.py
evaluate
called by 2
evaluate_gpu.py
ODFA
called by 2
ODFA.py
evaluate
called by 2
evaluate.py

Shape

Function 53
Method 38
Class 19

Languages

Python100%

Modules by API surface

model.py42 symbols
GPU-Re-Ranking/utils.py8 symbols
utils.py7 symbols
random_erasing.py6 symbols
test_with_TensorRT.py4 symbols
test_MSMT.py4 symbols
test.py4 symbols
instance_loss.py4 symbols
circle_loss.py4 symbols
train_DDP.py3 symbols
train.py3 symbols
dgfolder.py3 symbols

Dependencies from manifests, versioned

timm0.6.0 · 1×

For agents

$ claude mcp add Person_reID_baseline_pytorch \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact