This is an official implementaion of the paper "PCC Net" (PCC Net: Perspective Crowd Counting via Spatial Convolutional Network, completed in February 2018, accepted by TCSVT in May 2019).
In the paper, the experiments are conducted on the three populuar datasets: Shanghai Tech, UCF_CC_50 and WorldExpo'10. To be specific, Shanghai Tech Part B contains crowd images with the same resolution. For easier data prepareation, we only release the pre-trained model on ShanghaiTech Part B dataset in this repo.
- Python 2.7
- Pytorch 0.2.0
- TensorboardX (pip)
- torchvision (pip)
- easydict (pip)
- pandas (pip)
cd ./misc/roi_pooling
python build.py
- Download the original ShanghaiTech Dataset [Link: Dropbox / BaiduNetdisk]
- Resize the images and the locations of key points.
- Generate the density maps by using the code.
- Generate the segmentation maps.
We also provide the processed Part B dataset for training. [Link]
- Run the train_lr.py:
python train_lr.py
. - See the training outputs:
Tensorboard --logdir=exp --port=6006
.
In the experiments, training and tesing 800 epoches take 21 hours on GTX 1080Ti.
We show the Tensorboard visualization results as below:
The mae and mse are the results on test set. Others are triaining loss.
Visualization results on the test set as below:
Column 1: input image; Column 2: density map GT; Column 3: density map prediction; Column 4: segmentation map GT; Column 5: segmentation map prediction.
In this code, the validation is directly on the test set. Strictly speaking, it is evaluated on val set (randomly selected from training set), which is adoped in the paper. Here, for a comparble reproduction (namely fixed splitting sets), this code directly adopt the test set for validation, which causes that the results of this code are better than that of our paper.
If you use the code, please cite the following paper:
@article{gao2019perspective,
title={PCC Net: Perspective Crowd Counting via Spatial Convolutional Network},
author={Gao, Junyu and Wang, Qi and Li, Xuelong},
journal={arXiv preprint arXiv:1905.10085},
year={2019}
}