Home

Awesome

SAFECount

Official PyTorch Implementation of Few-shot Object Counting with Similarity-Aware Feature Enhancement, Accepted by WACV 2023.

SAFECount Image text

1. Quick Start

1.1 FSC147 in Original Setting

|-- data
    |-- FSC147_384_V2
        |-- images_384_VarV2
        |-- gt_density_map_adaptive_384_VarV2
        |-- train.json
        |-- val.json
        |-- test.json
        |-- fold0.json
        |-- fold1.json
        |-- fold2.json
        |-- fold3.json
PlatformVal MAEVal RMSETest MAETest RMSECheckpoints
8 GPUs (NVIDIA Tesla V100 16GB)14.4251.7213.5691.30here

1.2 FSC147 in Cross Validation Setting

Here we provide one example (3 shot, fold0 as val set), and others are similar.

ShotVal FoldVal MAEVal RMSEShotVal FoldVal MAEVal RMSE
1015.6251.203013.8443.99
117.1415.77316.2913.89
1214.0592.483211.1986.81
1313.8838.383311.7333.85

1.3 Cross-dataset Generalization (FSC147 to CARPK)

MAE (pretrain on FSC147)RMSE (pretrain on FSC147)MAE (finetune on CARPK)RMSE (finetune on CARPK)
17.7820.954.916.32

1.4 Class-specific Counting

The train and eval of class-specific counting are similar to FSC147. Here we only provide the construction of the dataset directory. The checkpoints (trained on 8 NVIDIA Tesla V100 16GB GPUs) and the corresponding results are given.

CARPKPUCPR+UCSDMallShanghaiTech PartAShanghaiTech PartB
MAE4.912.241.011.7774.369.75
RMSE6.323.441.342.24121.1515.87
checkpointsherehereherehereherehere

1) CARPK

|-- data
    |-- CARPK_devkit
        |-- Images
        |-- gen_gt_density.py
        |-- train.json
        |-- test.json
        |-- exemplar.json

2) PUCPR+

|-- data
    |-- PUCPR+_devkit
        |-- Images
        |-- gen_gt_density.py
        |-- train.json
        |-- test.json
        |-- exemplar.json

3) UCSD

|-- data
    |-- UCSD
        |-- ucsdpeds_vidf
        |-- gen_gt_density.py
        |-- train.json
        |-- test.json
        |-- exemplar.json
        |-- mask.png

4) Mall

|-- data
    |-- Mall
        |-- frames
        |-- gen_gt_density.py
        |-- train.json
        |-- test.json
        |-- exemplar.json
        |-- mask.png

5) ShanghaiTech

|-- data
    |-- ShanghaiTech
        |-- part_A
            |-- train_data
                |-- images
            |-- test_data
                |-- images
            |-- gen_gt_density.py
            |-- train.json
            |-- test.json
            |-- exemplar.json
        |-- part_B
            |-- train_data
                |-- images
            |-- test_data
                |-- images
            |-- gen_gt_density.py
            |-- train.json
            |-- test.json
            |-- exemplar.json

2. Learn More About Our Methods

datasetmodelcircumstance
custom_dataset.pysafecount.pyThe support images are parts of the query image, and annotated by bounding boxes, e.g., FSC147.
custom_exemplar_dataset.pysafecount_exemplar.pyThe support images are sampled then fixed, and not parts of the query image, e.g., CARPK, PUCPR+, UCSD, Mall, and ShanghaiTech.
custom_dataset.pysafecount_crossdataset.pyIn cross-dataset generalization, pretraining a model on FSC147 and finetuning on class-specific counting.

3. Questions