This is the official code of article "Parsing-based viewaware embedding network for vehicle ReID"[arxiv], which has been accpeted by CVPR20 as a poster article.
- python 3.6+
- torch 1.3.1+
Clone this repository. Then excute the following commands
cd PVEN
pip install -r requirements.txt
python setup.py install
If you want to develop this project, use the following commands instead
cd vehicle_reid.pytorch
pip install -r requirements.txt
python setup.py develop
Before the pipeline, you should preparing your vehicle ReID dataset first. For each dataset, we need to generate a description pickle file for it, which is a pickled dict with following structure:
{
"train":[
{
"filename": "0001_c001_00016450_0.jpg",
"image_path": "/data/datasets/VeRi/VeRi/image_train/0001_c001_00016450_0.jpg",
"id": "0001",
"cam": "001",
},
...
],
"gallery":[
...
],
"query":[
...
]
}
For different dataset, we provide the generate scripts to help you generate the pickle file.
cd examples/preprocess_data
# For VeRi776
python preprocess_veri776.py --input-path <VeRi_PATH> --output-path ../outputs/veri776.pkl
# For VehicleID and VeRiWild
# Will be published soon
As is described in the article, we annotate the parsing information of 3165 images from VeRi776.
We just annotate the vertexs of the polygons as the vehicles are composed by several polygons.
The vertexs information is in examples/parsing/poly.json
.
Run following command to convert the polygons to parsing masks
cd examples/parsing
python veri776_poly2mask.py --json-path poly.json --output-path ../outputs/veri776_parsing3165
The parsing masks will be generated in veri776_parsing3165
folder.
Run following command to train the parsing model
cd examples/parsing
python train_parsing.py --train-set trainval --masks-path ../outputs/veri776_parsing3165 --image-path <VeRi_PATH>/image_train
where the <VeRi_PATH>
is the path of your VeRi776 dataset.
Running the following command to generate masks for the whole ReID dataset and write the mask_path
to the dataset pickle file.
cd examples/parsing
python generate_masks.py --model-path best_model_trainval.pth --reid-pkl-path ../outputs/veri776.pkl --output-path ../outputs/masks
where the <PKL_PATH>
is the generated pickle file above.
Run the following model to train the PVEN ReID model.
cd examples/parsing_reid
# For VeRi776
CUDA_VISIBLE_DEVICES=0 python main.py train -c configs/veri776_b64_parsing.yml
cd examples/parsing_reid
# For VeRi776
python main.py eval -c configs/veri776_b64_parsing.yml
If you found our method helpful in your research, please cite our work in your publication.
@inproceedings{meng2020parsing,
title={Parsing-based View-aware Embedding Network for Vehicle Re-Identification},
author={Meng, Dechao and Li, Liang and Liu, Xuejing and Li, Yadong and Yang, Shijie and Zha, Zheng-Jun and Gao, Xingyu and Wang, Shuhui and Huang, Qingming},
booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
pages={7103--7112},
year={2020}
}