CountGD++: Generalized Prompting for Open-World Counting
Paper • 2512.23351 • Published
CountGD++: Generalized Prompting for Open-World Counting (CVPR 2026)
A multi-modal open-world counting model. You say what to count with text, visual exemplars (boxes on example objects), or both. You can also say what not to count with negative text and negative exemplars. Exemplars can come from the image being counted or from a different image.
This repository holds both the weights (model.safetensors, config.json)
and the inference code, so nothing has to be downloaded from Google Drive.
pip install torch torchvision "transformers<4.50" timm addict "yapf==0.40.1" termcolor \
scipy matplotlib opencv-python-headless pycocotools pyyaml huggingface_hub safetensors
import sys
from huggingface_hub import snapshot_download
repo = snapshot_download("nikigoli/CountGDPlusPlus") # code + weights
sys.path.insert(0, repo)
from countgdpp import CountGDPlusPlus, count
model = CountGDPlusPlus.from_pretrained("nikigoli/CountGDPlusPlus").to("cuda").eval()
# Text only
print(count(model, f"{repo}/img/336.jpg", "strawberry")["count"])
# Positive text + negative text
print(count(model, f"{repo}/img/336.jpg", "strawberry", negative_texts=["blueberry"])["count"])
# Text + visual exemplars drawn on another image, with a negative exemplar
result = count(
model, f"{repo}/img/336.jpg", "strawberry",
exemplar_boxes=[[x1, y1, x2, y2]], # pixels, on exemplar_image
exemplar_image=f"{repo}/img/synthetic_strawberry.jpg",
negative_texts=["blueberry"],
negative_exemplar_boxes=[[[x1, y1, x2, y2]]], # one list per negative text
negative_exemplar_images=[f"{repo}/img/synthetic_blueberry.jpg"],
)
print(result["count"], result["boxes"]) # boxes: normalized (cx, cy, w, h)
example.py is a runnable version that also saves a picture of the detections.
Notes:
bert-base-uncased) is fetched from the Hugging Face Hub
by transformers the first time the model loads.count(). See the test scripts in the GitHub repository.@InProceedings{AminiNaieni26b,
title={CountGD++: Generalized Prompting for Open-World Counting},
author={Amini-Naieni, N. and Zisserman, A.},
booktitle = {Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
year={2026}
}