huyhoang17 / LearningToCountEverything

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Learning To Count Everything


This is the official implementation of the following CVPR 2021 paper:

Learning To Count Everything
Viresh Ranjan, Udbhav Sharma, Thu Nguyen and Minh Hoai
Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2021.

Link to arxiv preprint:

Short presentation video

Short Presentation

Dataset download

Images can be downloaded from here:

Precomputed density maps can be found here:

Place the unzipped image directory and density map directory inside the data directory.

Installation with Conda

conda create -n fscount python=3.7 -y

conda activate fscount

python -m pip install matplotlib opencv-python notebook tqdm

conda install pytorch==1.4.0 torchvision==0.5.0 cudatoolkit=10.0 -c pytorch

Quick demo

Provide the input image and also provide the bounding boxes of exemplar objects using a text file:

python --input-image orange.jpg --bbox-file orange_box_ex.txt 

Use our provided interface to specify the bounding boxes for exemplar objects

python --input-image orange.jpg


We are providing our pretrained FamNet model, and the evaluation code can be used without the training.

Testing on validation split without adaptation

python --data_path /PATH/TO/YOUR/FSC147/DATASET/ --test_split val

Testing on val split with adaptation

python --data_path /PATH/TO/YOUR/FSC147/DATASET/ --test_split val --adapt


python --gpu 0


If you find the code useful, please cite:

  author = {Viresh Ranjan and Udbhav Sharma and Thu Nguyen and Minh Hoai},
  title = {Learning To Count Everything},
  year = {2021},
  booktitle = {Proceedings of the {IEEE/CVF} Conference on Computer Vision and Pattern Recognition (CVPR)},


License:MIT License


Language:Python 100.0%