/Counting-with-Focus-for-Free

Code for Counting with Focus for Free, ICCV, 2019

Primary LanguagePython

Counting-with-Focus-for-Free

Zenglin Shi, Pascal Mettes, and Cees G. M. Snoek. Counting with Focus for Free, ICCV, 2019 image

Overview of our approach

Requirements

1. CUDA 8.0 and Cudnn 7.5 or higher
2. GPU memory 10GB or higher
3. Python 2.7
4. Tensorflow 1.04 or or higher

Data preprocessing

Datasets

1. ShanghaiTech partA and partB
2. TRANCOS
3. Dublin Cell Counting
4. WIDER FACE
5. UCF-QNRF

Density map generation

Bsed on equation (1) and (7), for datasets with dense objects, ie, ShanghaiTech Part_A, TRANCOS and UCF-QNRF, we use our proposed non-uniform kernel with beta=0.3 and k=5. For ShanghaiTech Part_B and DCC, we set the Gaussian kernel variance to sigma=5 and sigma=10 respectively. For WIDER FACE, we obtain the Gaussian kernel variance by leveraging the box annotations. You can find the code in folder ¨data/getDmap.m¨.

Segmentation map generation

Bsed on equation(2), we use the same sigma as density map generation. You can find the code in folder ¨data/getPmap.m¨.

Global density generation

Bsed on equation(4) and (5), we use M=8 density levels for ShanghaiTech Part_A and UCF-QNRF, and 4 for the other datasets.

Training

1. Prepare your data following the step of ¨data preprocessing¨.
2. Set the experiment settings in ¨code/tr_param.ini¨ in which phase = train, and set other parameters accordingly (refer to our paper).
3. Run ¨python code/main.py¨

Testing

1. Prepare your data following the step of ¨data preprocessing¨.
2. Set the experiment settings in ¨code/tr_param.ini¨ in which phase = test, and set other parameters accordingly (refer to our paper).
3. Run ¨python code/main.py¨

Tips

1. The dataload function in this code is a little bit slow, you can impove it by using Dataset API in TF.
2. Please generate your groundtruth map following the step of ¨data preprocessing¨ if you want to reproduce our reported numbers in Table 6.
3. You may get different results for each run because some random functions are used even with a fixed random seeds.
4. Our proposed focus for free is independent to the base network, which means you can use the latest more powerful base network to get better results.
5. WIDER FACE is a perfact dataset to support you to claim that your method can deal with multi-scale objects (see details in our paper). The ground truth density map and segmentation map are avaliable at [WIDER FACE].
6. If you have any questions, feel free to post them in ¨Issues¨.
7. You can find more information at my homepage

Citation

Please cite our paper when you use this code.
 @inproceedings{shi2019counting,
 title={Counting with Focus for Free},
 author={Zenglin Shi, Pascal Mettes, and Cees G. M. Snoek},
 booktitle={ICCV},
 year={2019}
 }