This repo provides details about how to use SOLIDER pretrained representation on person re-identification task. We modify the code from TransReID, and you can refer to the original repo for more details.
We use python version 3.7, PyTorch version 1.7.1, CUDA 10.1 and torchvision 0.8.2. More details of installation and dataset preparation can be found in TransReID-SSL.
You can download models from SOLIDER, or use SOLIDER to train your own models. Before training, you should convert the models first.
python convert_model.py path/to/SOLIDER/log/lup/swin_tiny/checkpoint.pth path/to/SOLIDER/log/lup/swin_tiny/checkpoint_tea.pthWe utilize 1 GPU for training. Please modify the MODEL.PRETRAIN_PATH, DATASETS.ROOT_DIR and OUTPUT_DIR in the config file.
sh run.shsh runtest.sh| Method | Model | MSMT17 (w/o RK) |
Market1501 (w/o RK) |
MSMT17 (with RK) |
Market1501 (with RK) |
|---|---|---|---|---|---|
| SOLIDER | Swin Tiny | 67.4/85.9 (Link,Log) |
91.6/96.1 (Link,Log) |
81.5/89.2 | 95.3/96.6 |
| SOLIDER | Swin Small | 76.9/90.8 (Link,Log) |
93.3/96.6 (Link,Log) |
86.5/91.7 | 95.4/96.4 |
| SOLIDER | Swin Base | 77.1/90.7 (Link,Log) |
93.9/96.9 (Link,Log) |
86.5/91.7 | 95.6/96.7 |
mAP/Rank1are used as evaluation metric,RKindicates whether re-ranking is involved.RKshares the same models withw/o RK.- We use the pretrained models from SOLIDER.
- The semantic weight is set to 0.2 in these experiments.
export_reid.py exports a fine-tuned Swin-Tiny model to ONNX for deployment with Triton Inference Server (or any ONNX runtime).
| Name | Shape | Dtype | |
|---|---|---|---|
| Input | input |
[batch, 3, 384, 128] |
FP32 |
| Output | output |
[batch, 768] |
FP32, L2-normalised |
Batch size is dynamic. The 384×128 input size matches the MSMT17 training config (configs/MSMT17/swin_tiny.yml).
pip install torch onnx onnxruntime yacsDownload the MSMT17 fine-tuned Swin-Tiny weights (MSMT17 Swin-Tiny checkpoint on Google Drive) and place the file at:
triton-models/reid-solider/solider_swin_tiny_msmt17.pth
The script locates the SOLIDER-REID repository automatically (looks for a sibling directory named SOLIDER-REID). Override with an environment variable if needed:
# Auto-discovery (SOLIDER-REID is a sibling of the calling repo)
python export_reid.py
# Explicit path
SOLIDER_REID_PATH=/path/to/SOLIDER-REID python export_reid.pyThe script writes the model to triton-models/reid-solider/1/model.onnx (~110 MB) and runs shape and L2-norm sanity checks via onnxruntime before exiting.
- Swin-Tiny backbone with SOLIDER semantic controller (
semantic_weight=0.2) - BN bottleneck neck (
NECK=bnneck,NECK_FEAT=after) - L2 normalisation fused into the graph (equivalent to
TEST.FEAT_NORM=yes) - Classifier head excluded
If you find this code useful for your research, please cite our paper
@inproceedings{chen2023beyond,
title={Beyond Appearance: a Semantic Controllable Self-Supervised Learning Framework for Human-Centric Visual Tasks},
author={Weihua Chen and Xianzhe Xu and Jian Jia and Hao Luo and Yaohua Wang and Fan Wang and Rong Jin and Xiuyu Sun},
booktitle={The IEEE/CVF Conference on Computer Vision and Pattern Recognition},
year={2023},
}