Home

Awesome

Class agnostic Few shot Object Counting

This repository is the non-official pytorch implementation of a WACV 2021 Paper "Class-agnostic Few-shot-Object-Counting". Link

In Proc. IEEE/CVF Winter Conference on Applications of Computer Vision (WACV), 2021 Shuo-Diao Yang, Hung-Ting Su, Winston H. Hsu, Wen-Chin Chen<sup>*</sup>

39_ref_good </br> <img src="https://user-images.githubusercontent.com/76461262/181033299-cda225d3-c964-4327-9d13-bdbdaa296af3.png" width="200" height="150" /> <img src="https://user-images.githubusercontent.com/76461262/181033407-cb571edc-cb2f-4f1a-9127-fb74cafc933c.png" width="200" height="150" /> <img src="https://user-images.githubusercontent.com/76461262/181033455-84efbbea-0656-4e47-b281-34e3eeb14482.png" width="200" height="150" /> </br>

2_ref_good </br> <img src="https://user-images.githubusercontent.com/76461262/181036450-ee30acc9-1521-4dd1-b5c3-562308dc7f8d.png" width="200" height="150" /> <img src="https://user-images.githubusercontent.com/76461262/181036669-6d0b78b4-8447-4f8c-9ac6-821351bc4f0b.png" width="200" height="150" /> <img src="https://user-images.githubusercontent.com/76461262/181036720-a7539696-bd5f-4886-aff6-4a343d390276.png" width="200" height="150" /> </br>

Installation

Our code has been implemented on Python 3.8 and PyTorch 1.8.1+cu101. Please follow the instructions to setup your environment. See other required packages in requirements.txt.

conda create --name CFOCNet python=3.8
conda activate CFOCNet
pip install -r requirements.txt
pip install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"

If you have problem about installing cocoapi, come here to find the official documentation.

Getting Started

Data Preparation

We train and evaluate our methods on COCO dataset 2017. </br> Please follow the instruction here to download the COCO dataset 2017 </br> structure used in our code will be like : </br>

$PATH_TO_DATASET/
├──── images
│    ├──── train2017
│             |──── 118287 images (.jpg)
│
│    ├──── test2017
│             |──── 40670 images (.jpg)
│
│    ├──── val2017
│             |──── 5000 images (.jpg)
│
├──── annotations
│    ├──── captions_train2017.json
│
│    ├──── captions_val2017.json
│
│    ├──── instances_train2017.json
|
│    ├──── instances_val2017.json
│
│    ├──── person_keypoints_train2017.json
│
│    ├──── person_keypoints_val2017.json

After downloading the data, please navigate to our repository. </br> Then, modify the variable "coco_path" in line 8 in crop.py to your COCO dataset path.

cd CODE_DIRECTORY
python data/crop.py

After performing the above instructions, the structure of your coco dataset will be like : </br>

$PATH_TO_DATASET/
├──── images
│    ├──── train2017
│             |──── 118287 images (.jpg)
│
│    ├──── test2017
│             |──── 40670 images (.jpg)
│
│    ├──── val2017
│             |──── 5000 images (.jpg)
│
│    ├──── crop
│             |──── 80 directories which store all categories 500 images in coco dataset 2017 (for references images)
│
├──── annotations
│    ├──── captions_train2017.json
│
│    ├──── captions_val2017.json
│
│    ├──── crop.json
│
│    ├──── instances_train2017.json
|
│    ├──── instances_val2017.json
│
│    ├──── person_keypoints_train2017.json
│
│    ├──── person_keypoints_val2017.json

Training

cd CODE_DIRECTORY
bash run.sh

Testing

cd CODE_DIRECTORY
bash run.sh

Implementation Details

Acknowledgement