Home

Awesome

AlignedReID++ (Pattern Recognition)

Alignedreid++: Dynamically Matching Local Information for Person Re-Identification. [PDF]

@article{luo2019alignedreid++,
  title={AlignedReID++: Dynamically matching local information for person re-identification},
  author={Luo, Hao and Jiang, Wei and Zhang, Xuan and Fan, Xing and Qian, Jingjing and Zhang, Chi},
  journal={Pattern Recognition},
  volume={94},
  pages={53--61},
  year={2019},
  publisher={Elsevier}
}

@article{zhang2017alignedreid,
  title={Alignedreid: Surpassing human-level performance in person re-identification},
  author={Zhang, Xuan and Luo, Hao and Fan, Xing and Xiang, Weilai and Sun, Yixiao and Xiao, Qiqi and Jiang, Wei and Zhang, Chi and Sun, Jian},
  journal={arXiv preprint arXiv:1711.08184},
  year={2017}
}

Version

Python2/Python3

torch0.4.0

torchvision0.2.1

Now, we support ResNet, ShuffleNet, DenseNet and InceptionV4.

Demo

<img src='imgs/Figure_1.png' align="right" width=415> <img src='imgs/Figure_0.png' align="left" width=415>

Have a try

Your can test the demo with your own model and datasets. You should change the path of the model and images by manually. The default model is ResNet50 for Market1501.

python Alignedreid_demo.py

Results (rank1/mAP) and models

Market1501

ModelLossGlobalLocalDMLIGlobal+DMLIGlobal+DMLI(RK)Download
Resnet50Alignedreid89.2/75.990.7/75.591.1/77.491.0/77.692.0/88.5model
Resnet50Alignedreid(LS)90.6/77.791.4/76.791.9/78.891.8/79.192.8/89.4model

DukeMTMCReID

ModelLossGlobalLocalDMLIGlobal+DMLIGlobal+DMLI(RK)Download
Resnet50Alignedreid79.3/65.680.9/66.981.0/67.780.7/68.085.2/81.2model
Resnet50Alignedreid(LS)81.2/67.481.5/68.481.8/69.482.1/69.786.2/82.8model

CUHK03

ModelLossGlobalLocalDMLIGlobal+DMLIGlobal+DMLI(RK)Download
Resnet50Alignedreid60.7/58.460.2/58.260.9/59.660.9/59.767.6/70.7model
Resnet50Alignedreid(LS)59.7/58.159.9/57.261.1/59.461.5/59.667.9/70.7model

MSMT17

ModelLossGlobalLocalDMLIGlobal+DMLIDownload
Resnet50Alignedreid63.4/38.463.866.3/40.266.3/40.6model
Resnet50Alignedreid(LS)67.6/41.867.3/38.469.6/43.369.8/43.7model

Market1501-Partial

ModelLossGlobalLocalDMLI
Resnet50Softmax59.0/46.456.5/43.763.3/50.0
Resnet50Softmax+TriHard62.4/49.751.8/37.668.0/52.7
Resnet50Alignedreid65.9/53.552.8/38.170.1/55.3

DukeMTMCReID-Partial

ModelLossGlobalLocalDMLI
Resnet50Softmax45.9/34.748.6/36.153.6/40.6
Resnet50Softmax+TriHard47.8/36.443.3/31.553.7/40.5
Resnet50Alignedreid49.8/38.244.8/33.355.3/42.8

You can download the models on Google Drive.

Prepare data

Create a directory to store reid datasets under this repo via

cd AlignedReID/
mkdir data/

If you wanna store datasets in another directory, you need to specify --root path_to_your/data when running the training code. Please follow the instructions below to prepare each dataset. After that, you can simply do -d the_dataset when running the training code.

Market1501 :

  1. Download dataset to data/ from http://www.liangzheng.org/Project/project_reid.html.
  2. Extract dataset and rename to market1501. The data structure would look like:
market1501/
    bounding_box_test/
    bounding_box_train/
    ...
  1. Use -d market1501 when running the training code.

CUHK03 [13]:

  1. Create a folder named cuhk03/ under data/.
  2. Download dataset to data/cuhk03/ from http://www.ee.cuhk.edu.hk/~xgwang/CUHK_identification.html and extract cuhk03_release.zip, so you will have data/cuhk03/cuhk03_release.
  3. Download new split [14] from person-re-ranking. What you need are cuhk03_new_protocol_config_detected.mat and cuhk03_new_protocol_config_labeled.mat. Put these two mat files under data/cuhk03. Finally, the data structure would look like
cuhk03/
    cuhk03_release/
    cuhk03_new_protocol_config_detected.mat
    cuhk03_new_protocol_config_labeled.mat
    ...
  1. Use -d cuhk03 when running the training code. In default mode, we use new split (767/700). If you wanna use the original splits (1367/100) created by [13], specify --cuhk03-classic-split. As [13] computes CMC differently from Market1501, you might need to specify --use-metric-cuhk03 for fair comparison with their method. In addition, we support both labeled and detected modes. The default mode loads detected images. Specify --cuhk03-labeled if you wanna train and test on labeled images.

DukeMTMC-reID [16, 17]:

  1. Create a directory under data/ called dukemtmc-reid.
  2. Download dataset DukeMTMC-reID.zip from https://github.com/layumi/DukeMTMC-reID_evaluation#download-dataset and put it to data/dukemtmc-reid. Extract the zip file, which leads to
dukemtmc-reid/
    DukeMTMC-reid.zip # (you can delete this zip file, it is ok)
    DukeMTMC-reid/ # this folder contains 8 files.
  1. Use -d dukemtmcreid when running the training code.

MSMT17 [22]:

  1. Create a directory named msmt17/ under data/.
  2. Download dataset MSMT17_V1.tar.gz to data/msmt17/ from http://www.pkuvmc.com/publications/msmt17.html. Extract the file under the same folder, so you will have
msmt17/
    MSMT17_V1.tar.gz # (do whatever you want with this .tar file)
    MSMT17_V1/
        train/
        test/
        list_train.txt
        ... (totally six .txt files)
  1. Use -d msmt17 when running the training code.

Train

Since the performance of Market1501 and DukeMTMCReID is too high, we suggest to using CUHK03 and MSMT17 for future research.

python train_alignedreid.py  -d cuhk03 -a resnet50 --test_distance global_local --reranking (--labelsmooth)

Note: You can add your experimental settings for 'args'

Test

Global+Local(DMLI)

python train_alignedreid.-d cuhk03 -a resnet50 --evaluate --resume YOUR_MODEL_PATH --save-dir log/resnet50-cuhk03-alignedreid --test_distance global_local (--reranking)

Local(DMLI)

python train_alignedreid.py -d cuhk03 -a resnet50 --evaluate --resume YOUR_MODEL_PATH --save-dir log/resnet50-cuhk03-alignedreid --test_distance local (--reranking)

Local(Without DMLI)

python train_alignedreid.py -d cuhk03 -a resnet50 --evaluate --resume YOUR_MODEL_PATH --save-dir log/resnet50-cuhk03-alignedreid --test_distance local --unaligned (--reranking)

Global

python train_alignedreid.py -d cuhk03 -a resnet50 --evaluate --resume YOUR_MODEL_PATH --save-dir log/resnet50-cuhk03-alignedreid --test_distance global (--reranking)

Note: (--reranking) means whether you use 'Re-ranking with k-reciprocal Encoding (CVPR2017)' to boost the performance.

Test on Partial ReID

scp -r data/market1501 data/market1501-partial
python gen_partial_dataset.py
python train_alignedreid.py -d market1501-partial -a resnet50 --evaluate --resume YOUR_MODEL_PATH --save-dir log/resnet50-market1501-partial-alignedreid --test_distance local (--unaligned)