This repository contains the code for our paper Unlabeled Samples Generated by GAN Improve the Person Re-identification Baseline in vitro.
News: We provide one new end-to-end framework for data generation and representation learning. You are welcomed to check out it at https://github.com/NVlabs/DG-Net
The first stage is to generate fake images by DCGAN. We used the code provided in https://github.com/carpedm20/DCGAN-tensorflow and modify some hyper-parameters at https://github.com/layumi/DCGAN-tensorflow. You can directly use my forked code.
For more reference, you can find our modified training code and generating code in ./DCGAN.
We wrote a detailed README. If you still has some question, feel free to contact me ([email protected]).
The second stage is to combine the original data and generated data to train the network. This repos includes the baseline code and the three different methods in the paper.
| Models | Reference |
|---|---|
| resnet52_market.m | ResNet50 baseline |
| resnet52_market_K_1.m | One extra class for generated images |
| resnet52_market_lsro.m | The proposed method, uniform probability |
| resnet52_market_pseudo.m | Give the most likely label for generated images |
-
You can find more detailed code for proposed loss in [forward code] [backward code]. (We write the label smooth loss first and then extend it to LSRO. Here we also provide a brief illustration.)
-
Pseudo label is realized in https://github.com/layumi/Person-reID_GAN/blob/master/matlab/%2Bdagnn/Pseudo_Loss.m
(Note that I have included my Matconvnet in this repo, so you do not need to download it again. I has changed some codes comparing with the original version. For example, one of the difference is in /matlab/+dagnn/@DagNN/initParams.m. If one layer has params, I will not initialize it again, especially for pretrained model.)
You just need to uncomment and modify some lines in gpu_compile.m and run it in Matlab. Try it~
(The code does not support cudnn 6.0. You may just turn off the Enablecudnn or try cudnn5.1)
If you fail in compilation, you may refer to http://www.vlfeat.org/matconvnet/install/
Download Market1501 Dataset. [Google] [Baidu] We take Market1501 as an example in this repos and you can easily extend it to other datasets.
-
Make a dir called
databy typingmkdir ./data. -
Download ResNet-50 model pretrained on Imagenet. Put it in the
datadir.
-
Add your dataset path into
prepare_data.mand run it. Make sure the code outputs the right image path. -
Run
train_id_net_res_market_new.m.
-
Add your generated data path into
prepare_data_gan.mand run it. It will add generated image path into the original image database. -
Run
train_id_net_res_market_K_1.mfor training extra-class method.
Or run train_id_net_res_market_lsro.m for training the proposed method.
Or run train_id_net_res_market_pseudo.m for training the pseudo-label method.
(What's new: I also include train_id_net_res_2stream_gan.m for training the code with the method proposed in my another paper. I do not import all files, and you may find the missing code in https://github.com/layumi/2016_person_re-ID. )
- Run
test/test_gallery_query_crazy.mto extract the features of images in the gallery and query set. They will store in a .mat file. Then you can use it to do evaluation. - Evaluate feature on the Market-1501. Run
evaluation/zzd_evaluation_res_faster.m.
Please cite this paper in your publications if it helps your research:
@inproceedings{zheng2017unlabeled,
title={Unlabeled Samples Generated by GAN Improve the Person Re-identification Baseline in vitro},
author={Zheng, Zhedong and Zheng, Liang and Yang, Yi},
booktitle={Proceedings of the IEEE International Conference on Computer Vision},
year={2017}
}