Skip to content

Implementation of the paper "Counting Through Occlusion: Framework for Open World Amodal Counting"

Notifications You must be signed in to change notification settings

Safaeid48/CountOCC

Repository files navigation

CountOCC

1. Dataset

Download the following datasets:

  • FSC-147-OCC (occlusion-augmented FSC-147 dataset)
  • CARPK-OCC (occlusion-augmented CARPK dataset)
  • CAPTURE-Real
<repo-root>/
  data/
    FSC147_OCC/
      images/
      annotations/
        fsc147_val_occ.json
        fsc147_test_occ.json
    CARPK_OCC/
      test/
      carpk_occ.json
    Capture/
      real_dataset/
      real_dataset.json

2. System Requirements

The code has been tested with the following setup:

  • OS: Ubuntu 24.04.3 LTS
  • Compiler: GCC 11.3 and 11.4
  • Python: 3.9.19
  • GPU: RTX 5090

3. Installation

3.1 Install GCC.

In this project, GCC 11.3 and 11.4 were tested. The following command installs GCC and other development libraries and tools required for compiling software in Ubuntu.

sudo apt update
sudo apt install build-essential

3.2 Set Up Anaconda Environment:

The following commands will create a suitable Anaconda environment for running the training and inference procedures.

conda create -n countocc python=3.9.19
conda activate countocc
cd countocc
pip install -r requirements.txt
export CC=/usr/bin/gcc-11 # this ensures that gcc 11 is being used for compilation
cd models/GroundingDINO/ops
python setup.py build install
python test.py # should result in 6 lines of * True
pip install git+https://github.com/facebookresearch/segment-anything.git
cd ../../../

3.3 Download Pre-Trained Weights

Make the checkpoints directory inside the CountOCC repository.

mkdir checkpoints

Execute the following command.

python download_bert.py

Download the pretrained Swin-B GroundingDINO weights.

wget -P checkpoints https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha2/groundingdino_swinb_cogcoor.pth

Download the pretrained ViT-H Segment Anything Model (SAM) weights.

wget -P checkpoints https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth

4. CountOCC Inference - FSC-147-OCC

Download the pretrained weights. To reproduce the results in the paper, run the following commands after activating the Anaconda environment.

For the validation set:

python -u main_inference.py --output_dir ./countocc_val -c config/cfg_fsc147_val.py --eval --datasets config/datasets_fsc147_val.json --pretrain_model_path checkpoints/checkpoint_best.pth --options text_encoder_type=checkpoints/bert-base-uncased --crop --sam_tt_norm --remove_bad_exemplar --use_frm

For the test set:

python -u main_inference.py --output_dir ./countocc_test -c config/cfg_fsc147_test.py --eval --datasets config/datasets_fsc147_test.json --pretrain_model_path checkpoints/checkpoint_best.pth --options text_encoder_type=checkpoints/bert-base-uncased --crop --sam_tt_norm --remove_bad_exemplar --use_frm

5. CountOCC Inference - CARPK-OCC

For the test set:

python test_carpk.py --pretrain_model_path ./checkpoints/checkpoint_best.pth --images_path ./data/CARPK-OCC/test --annotations_json ./data/CARPK-OCC/carpk_occ.json --use_exemplars --confidence_thresh 0.40 --use_frm

6. CountOCC Inference - Capture-Real

For the Capture-Real set:

python test_capture.py --pretrain_model_path ./checkpoints/checkpoint_best.pth --images_path ./data/Capture/real_dataset --annotations_json ./data/Capture/real_dataset_updated.json --use_exemplars --confidence_thresh 0.40 --use_frm

About

Implementation of the paper "Counting Through Occlusion: Framework for Open World Amodal Counting"

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published