Baseline Code (with bottleneck) for Person-reID (pytorch).
We arrived Rank@1=84.83%, mAP=67.10% with stride=1.
We arrived Rank@1=82.30%, mAP=64.09% with stride=2.
Any suggestion is welcomed.
You may learn more from model.py
.
We add one linear layer(bottleneck), one batchnorm layer and relu.
- Python 3.6
- GPU Memory >= 6G
- Numpy
- Pytorch 0.3+
(Some reports found that updating numpy can arrive the right accuracy. If you only get 50~80 Top1 Accuracy, just try it.) We have successfully run the code based on numpy 1.12.1 and 1.13.1 .
- Install Pytorch from http://pytorch.org/
- Install Torchvision from the source
git clone https://github.com/pytorch/vision
cd vision
python setup.py install
Because pytorch and torchvision are ongoing projects.
Here we noted that our code is tested based on Pytorch 0.3.0/0.4.0 and Torchvision 0.2.0.
Download Market1501 Dataset
Preparation: Put the images with the same id in one folder. You may use
python prepare.py
Remember to change the dataset path to your own path.
Futhermore, you also can test our code on DukeMTMC-reID Dataset. Our baseline code is not such high on DukeMTMC-reID Rank@1=64.23%, mAP=43.92%. Hyperparameters are need to be tuned.
To save trained model, we make a dir.
mkdir model
Train a model by
python train.py --gpu_ids 0 --name ft_ResNet50 --train_all --batchsize 32 --data_dir your_data_path
--gpu_ids
which gpu to run.
--name
the name of model.
--data_dir
the path of the training data.
--train_all
using all images to train.
--batchsize
batch size.
--erasing_p
random erasing probability.
Train a model with random erasing by
python train.py --gpu_ids 0 --name ft_ResNet50 --train_all --batchsize 32 --data_dir your_data_path --erasing_p 0.5
Use trained model to extract feature by
python test.py --gpu_ids 0 --name ft_ResNet50 --test_dir your_data_path --which_epoch 59
--gpu_ids
which gpu to run.
--name
the dir name of trained model.
--which_epoch
select the i-th model.
--data_dir
the path of the testing data.
python evaluate.py
It will output Rank@1, Rank@5, Rank@10 and mAP results.
You may also try evaluate_gpu.py
to conduct a faster evaluation with GPU.
For mAP calculation, you also can refer to the C++ code for Oxford Building. We use the triangle mAP calculation (consistent with the Market1501 original code).