This repo is the official crowd localization implementation of paper: NWPU-Crowd: A Large-Scale Benchmark for Crowd Counting and Localization. The code is developed based on C^3 Framework.
-
Prerequisites
- Python 3.x
- Pytorch 1.x: http://pytorch.org .
- other libs in
requirements.txt, runpip install -r requirements.txt.
-
Installation
- Clone this repo:
git clone https://github.com/gjy3035/NWPU-Crowd-Sample-Code-for-Localization.git
- Clone this repo:
-
Data Preparation
- Download NWPU-Crowd dataset from this link.
- Unzip
*zipfiles in turns and placeimages_part*into a folder. Finally, the folder tree is below:
-- NWPU-Crowd |-- images | |-- 0001.jpg | |-- 0002.jpg | |-- ... | |-- 5109.jpg |-- jsons | |-- 0001.json | |-- 0002.json | |-- ... | |-- 3609.json |-- mats | |-- 0001.mat | |-- 0002.mat | |-- ... | |-- 3609.mat |-- train.txt |-- val.txt |-- test.txt |-- readme.md- Run
./datasets/prepare_NWPU.musing Matlab. - Modify
__C_NWPU.DATA_PATHin./datasets/setting/NWPU.pywith the path of your processed data.
- Set the parameters in
config.pyand./datasets/setting/NWPU.py. - run
python train.py. - run
tensorboard --logdir=exp --port=6006.
We only provide an example to forward the model on the test set. You may need to modify it to test your models.
- Modify some key parameters in
test.py:- Line 35:
dataRoot, the same as__C_NWPU.DATA_PATHin./datasets/setting/NWPU.py. - Line 36:
ori_data, the original data path. - Line 37:
model_path. - Line 49: GPU Id and Model Name.
- Line 35:
- Run
python test.py.
We only provide an example to forward the model on the test set. You may need to modify it to test your models.
cd eval.python test.py.python vis4val.py.
We provide the pre-trained models in this link.
The overall results on val set:
| Method | F1_m | Pre | Rec |
|---|---|---|---|
| RAZ_loc[1] | 62.5 | 69.2 | 56.9 |
About the leaderboard on the test set, please visit Crowd benchmark.
- Recurrent Attentive Zooming for Joint Crowd Counting and Precise Localization, CPVR, 2019.
The Evaluation Python Code of the crowdbenchmark.com is shown in ./eval/eval.py.
If you find this project is useful for your research, please cite:
@article{gao2020nwpu,
title={NWPU-Crowd: A Large-Scale Benchmark for Crowd Counting and Localization},
author={Wang, Qi and Gao, Junyu and Lin, Wei and Li, Xuelong},
journal={IEEE Transactions on Pattern Analysis and Machine Intelligence},
doi={10.1109/TPAMI.2020.3013269},
year={2020}
}
Our code borrows a lot from the C^3 Framework, you may cite:
@article{gao2019c,
title={C$^3$ Framework: An Open-source PyTorch Code for Crowd Counting},
author={Gao, Junyu and Lin, Wei and Zhao, Bin and Wang, Dong and Gao, Chenyu and Wen, Jun},
journal={arXiv preprint arXiv:1907.02724},
year={2019}
}
If you use crowd counting models in this repo (RAZ_loc), please cite them.