Crowd counting on the ShanghaiTech dataset, using multi-column convolutional neural networks.
This is an unofficial implementation of CVPR 2016 paper "Single Image Crowd Counting via Multi Column Convolutional Neural Network".
Note: Predictions can be made. The work on heatmap generation in under progress.
- Install Tensorflow and Keras
- Install OpenCV
- Clone this repository (in case you don't want train the model and want to use the pre-trained one).
Download ShanghaiTech Dataset from:
- Dropbox: https://www.dropbox.com/s/fipgjqxl7uj8hd5/ShanghaiTech.zip?dl=0
- Baidu Disk: http://pan.baidu.com/s/1nuAYslz
Create a folder: ROOT/data/original/shanghaitech/
Here ROOT is the folder conatining all files, it's the main folder. (Don't create a folder called ROOT!)
- Save "part_A" under ROOT/data/original/shanghaitech/
- Save "part_B" under ROOT/data/original/shanghaitech/
- Got to ROOT/data_preparation/
- There, run create_gt_test_set_shtech.m in matlab/octave to create ground truth files for test data.
- Then go to ROOT/data_preparation/ again.
- run create_training_set_shtech.m in matlab to create training and validataion set along with ground truth files.
- Save the ground truth csv files in ROOT/data/
That completes data-setup!
- Follow steps 1, 2, 3, 4 and 5 from Data-Setup.
- Download pre-trained model files:
[Shanghai Tech A] : https://www.dropbox.com/s/8bxwvr4cj4bh5d8/mcnn_shtechA_660.h5?dl=0
[Shanghai Tech B] : https://www.dropbox.com/s/kqqkl0exfshsw8v/mcnn_shtechB_110.h5?dl=0
- Save the model files under: ROOT/final_models
- Finally run: test.py
-
Not recommended unless you have a great processor, or a GPU, because training takes a lot of time. Load the pre-trained model and test it on the test set instead.
-
For tensorflow:
run from prompt: python3 train.py A(or B)
Model is saved to modelA/ or modelB/. -
For keras: run: python3 keras_train.py B
model is saved to keras_modelB/