- Implement Siamese network proposed by Zhedong in Keras
- Using RankNet to regress ranking probability
python2.7, tensorflow 1.4 and keras 2.1.5
- Refer to Zhedong's pytorch baseline, we write a memory-friendly evaluation script, when you generate ranking id tables, for example named with 'market_rank_pid.txt', you can use
python3 eval_on_result.py --target_dataset_path /home/cwh/coding/dataset/market --pid_path market_rank_pid.txt --result_path market_result.log
to compute map and rank1, rank5, rank10. (test on python3, pytorch 0.4.0)
- Base Network:ResNet50
- Input:Given a ranking list, choose a probe image A, two gallery image B, C
- Output:Compute the probability that rank AB > rank AC
- NVIDIA TITANX 11G
- Memory: >=16G
Take Market-1501 as an example:
- download
- rename training directory to 'train', rename probe directory to 'probe', renmae gallery directory to 'test'
Your data directory will look like this:
Market-1501
├── probe
│ ├── 0003_c1s6_015971_00.jpg
│ ├── 0003_c3s3_064744_00.jpg
│ ├── 0003_c4s6_015641_00.jpg
│ ├── 0003_c5s3_065187_00.jpg
│ └── 0003_c6s3_088392_00.jpg
├── test
│ ├── 0003_c1s6_015971_02.jpg
│ ├── 0003_c1s6_015996_02.jpg
│ ├── 0003_c4s6_015716_03.jpg
│ ├── 0003_c5s3_065187_01.jpg
│ ├── 0003_c6s3_088392_04.jpg
│ └── 0003_c6s3_088442_04.jpg
└── train
├── 0002_c1s1_000451_03.jpg
├── 0002_c1s1_000551_01.jpg
├── 0002_c1s1_000776_01.jpg
├── 0002_c1s1_000801_01.jpg
├── 0002_c1s1_069056_02.jpg
└── 0002_c6s1_073451_02.jpg
- replace all paths containing '/home/cwh/coding' to your data path in these file:
- Train a Resnet-based softmax classifer: specify source dataset and run baseline/train.py
- Train a siamese network: specify source dataset and run pretrain/pair_train.py
- Train a RankNet: refer to TFusion
-
baseline:ResNet52 base network
- evaluate.py
extract_feature
: compute ranking result by base network and evaluate rank accuracy + mAPsimilarity_matrix
: Cosine similarity of CNN features(accelerated by GPU)- On test set, compute ranking table with
test_predict
- On training set,compute ranking table with
train_predict
- Compute rank accuracy and mAP with
map_rank_quick_eval
on Market1501(can be extended to DukeMTMC4ReID) - Compute rank accuracy with
grid_result_eval
on GRID
- train.py
- Use source dataset to pretrain ResNet52 base network
- evaluate.py
-
pair: pretrain siamese network
- pair_train.py:pretrain with two input images
- pair_generator: data generator, selecting positive and negative samples according to person id
- pair_model: build a Keras based Siamese network
- eval:evaluate on Siamese Network and ranknet
- load corresponding model
- call function in baseline/evaluate.py for test
- pair_train.py:pretrain with two input images
-
transfer: incremental training with ranking table
- simple_rank_transfer.py: learning to rank with three input images
- triplet_generator_by_rank_list:image generator
- rank_transfer_model:three input image, one ranking loss
- simple_rank_transfer.py: learning to rank with three input images
Please cite this paper in your publications if it helps your research:
@article{
title={Unsupervised Cross-dataset Person Re-identification by Transfer Learning of Spatial-Temporal Patterns},
author={Jianming, Lv and Weihang, Chen and Qing, Li and Can, Yang},
journal={CVPR},
year={2018}
}