GeCo2 - Generalized-Scale Object Counting with Gradual Query Aggregation
April 13, 2026 ยท View on GitHub
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.
https://github.com/user-attachments/assets/8b5f3f06-45f8-439f-9333-b7a747db28a5
Live Demo
Try the interactive demo on Hugging Face:
๐ DEMO HERE
Highlights
- ๐ 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).
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
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
- Train the model:
First correct data_path and model_path in train.sh, then run:
bash train.sh
- Evaluate detection performance (AP / AP50):
python eval_bboxes.py
Option 2: Inference with Official Weights
-
Download official weights for FSCD GECO2
-
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 Luke{\v{z}}i{\v{c}}, Alan and Kristan, Matej},
booktitle={Proceedings of the AAAI Conference on Artificial Intelligence},
volume={40},
number={10},
pages={8314--8321},
year={2026}
}