rongliangzi / Dense-Scale-Network-for-Crowd-Counting

An unofficial implement of paper "Dense Scale Network for Crowd Counting", link: https://arxiv.org/abs/1906.09707
31 stars 8 forks source link
convolutional-neural-networks crowd-counting deep-learning

Dense-Scale-Network-for-Crowd-Counting

An unofficial implement of paper "Dense Scale Network for Crowd Counting".

Dataset setup

Download the shanghaitech dataset from here, UCF-QNRF dataset from here.

Data preparation

In make_sh_gt.py, modify variable root in line 18 to your dataset path and set the min_size in line 16 for image. Then run the .py file. It will save images and .h5 file in root/{dataset}_preprocessed/train/ and root/{dataset}_preprocessed/test/.

Train

In main.py, set train_path to root/{dataset}_preprocessed/train/ and test_path to root/{dataset}_preprocessed/test/ in line 81 and 82. Also specify the save_path. When training shanghaitech PartA dataset, the model shows faster convergence if learning rate is set as 1e-4 compared to 1e-5 which is claimed by the paper.

Test

Test on one image

python test_one_image.py --gpu 0 --model_path pretrained_model_path --test_img_path your_image_path

Test on a dataset

python test_dataset.py --gpu 0 --model_path pretrained_model_path --test_img_dir your_image_directory

Result

Dataset MAE MSE
sha 69.35 104.4
shb 8.58 14.87
qrnf tbd tbd

Anyone interested in implementing crowd counting models is welcomed to contact me.