Skip to content

jerpelhan/GECO2

Repository files navigation

GeCo2 - Generalized-Scale Object Counting with Gradual Query Aggregation

Official repository of GeCo2
🏆 Accepted to AAAI 2026
📄 Read the paper: GeCo2 PDF


Abstract

Few-shot detection-based counters estimate the number of category instances in an image using only a few test-time exemplars. Existing methods often rely on ad-hoc image upscaling and tiling to detect small, densely packed objects, and they struggle when object sizes vary widely within a single image. GeCo2 introduces a generalized-scale dense query map that is gradually aggregated across multiple backbone resolutions. Scale-specific query encoders interact with exemplar appearance and shape prototypes at each feature level and then fuse them into a high-resolution query map for detection. This avoids heuristic upscaling/tiling, improves counting and detection accuracy, and reduces memory and runtime. A lightweight SAM2-based mask refinement further polishes box quality. On standard few-shot counting/detection benchmarks, GeCo2 achieves strong gains in MAE/RMSE and AP/AP50, while running ~3× faster with a smaller GPU footprint.

geco_demo.mp4

Live Demo

Try the interactive demo on Hugging Face:
👉 DEMO HERE

Highlights

GECO2_first_image_motivation_neurips-1
  • 🔁 Gradual cross-scale query aggregation → one high-res dense query map without tiling.
  • 🧩 Per-scale exemplar interaction with appearance + shape prototypes.
  • Fast & memory-efficient inference.
  • 📈 Strong results on FSCD147, FSCD-LVIS, and MCAC (few-shot & multi-class).
Geco2_architevture-1

Demo Installation

You can easily install and run the demo using the provided install.sh script.

bash install.sh

Download Weights

Download the model weights from:

👉 CNTQG_multitrain_ca44.pth

and place the file in the project root directory.

Launch the Demo

Then run:

python demo_gradio.py

GeCoV2Qualitative_segmentation-1

Reproducing Results on FSCD147

This section describes how to reproduce the reported counting and detection results on the FSCD147 benchmark.

Prerequisites

Both training and inference require Detectron2 for evaluation of detection metrics (AP / AP50).

Please install Detectron2 following the official instructions corresponding to your PyTorch and CUDA versions.


Option 1: Retraining on FSCD147

  1. Train the model:

First correct data_path and model_path in train.sh, then run:

        bash train.sh
  1. Evaluate detection performance (AP / AP50):
        python eval_bboxes.py

Option 2: Inference with Official Weights

  1. Download official weights for FSCD GECO2

  2. Run evaluation:

        python eval_bboxes.py

Citation

If you find this work useful, please cite:

@inproceedings{pelhan2026generalized,
  title={Generalized-Scale Object Counting with Gradual Query Aggregation},
  author={Pelhan, Jer and Lukezic, Alan and Kristan, Matej},
  booktitle={Proceedings of the AAAI Conference on Artificial Intelligence},
  pages={},
  year={2026}
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published