TL;DR
Referring Expression Counting (REC) requires enumerating objects that match specific contextual attributes (e.g., "person walking" vs. "person sitting"). The authors introduce C-REX, a framework that replaces fragile cross-modal (image-text) contrastive learning with an image-space supervised contrastive loss that treats the top-$N$ most similar visual tokens as positives (where $N$ is the ground-truth count). Combined with a simple shift from bounding-box detection to point centroid prediction, C-REX outperforms existing REC methods by over 22% in MAE and 10% in RMSE.
What Problem Does This Paper Address?
Traditional object counters typically generalize across broad categories (class-agnostic counting). REC takes this a step further: it demands counting only instances that satisfy nuanced contextual or attribute-level constraints within the same category (e.g., distinguishing "cars driving to the right" from parked cars or cars driving left).
Prior approaches (notably GroundingREC) rely on cross-modal contrastive learning, pulling image features toward text embeddings. However, image-text contrastive learning is notorious for space misalignment and data inefficiency when trained at smaller scales. Furthermore, language-based negative sample pools per image are tiny—usually fewer than four candidate expressions—limiting the discriminative power needed to separate visually near-identical instances.
Methods
C-REX introduces two key architectural and training contributions:
[Prompt: "Person riding bicycle"]
│
▼ (mask class token)
[Masked RE Embedding: "riding bicycle"]
│ Cosine Similarity
▼
[Image Tokens from Grounding DINO Backbone]
│
├─► Top-N Similar Tokens ──► Positive Pool (I⁺)
└─► Remaining Tokens ──► Negative Pool (I⁻)
│
▼
Image-Space Supervised Contrastive Loss (L*sup)
(Only positive tokens serve as anchors)
- Centroid-Based Open-Set Detector Baseline: Analyzing why recent detection models perform well on counting tasks, the authors show that predicting object centroids (center points via an $L_1$ loss) rather than full bounding boxes is the decisive architectural choice for dense scenes. They fine-tune Grounding DINO with point regression and cross-entropy classification losses, creating a baseline (
GDino improved) that outperforms specialized prior work on its own. - Within-Image Supervised Contrastive Loss ($\mathcal{L}^*_{sup}$): Instead of contrasting image features against text tokens, C-REX contrasts visual tokens against visual tokens:
- It masks the category label in the referring expression prompt (leaving only the attribute, e.g., "riding a bicycle").
- It computes the cosine similarity between all candidate visual tokens and the masked attribute embedding.
- Using the image's ground-truth count $N$, it selects the top-$N$ most similar image tokens to form the positive set ($I^+$), treating the remaining hundreds of visual tokens as negatives ($I^-$).
- Positive-Only Anchors: Standard Supervised Contrastive Loss (SupCon) attracts negative samples to one another. Because negatives in REC span diverse backgrounds and distinct non-target classes, clustering them hurts representations. The authors modify SupCon so that only samples from the positive set ($I^+$) serve as anchors, pulling instances of the designated attribute together while pushing background and non-target objects away.
Datasets
- REC-8K: The primary REC benchmark, consisting of 8,011 images and 17,122 image–referring expression pairs annotated with ground-truth point locations.
- FSC-147: Standard class-agnostic counting benchmark containing 6,135 images across 147 classes.
- CARPK: Drone-captured parking lot dataset (1,448 images) used to evaluate zero-shot transfer capabilities in class-agnostic counting.
Key Insights and Ideas
- Image-Space Contrast Outperforms Vision-Language Contrast: Learning discriminative features entirely in the visual embedding space sidesteps cross-modal representation gaps and increases negative samples from $\sim 3$ text queries to hundreds of background/non-target image tokens.
- Ground-Truth Count as a Natural Top-$K$ Filter: Using ground-truth count $N$ to select pseudo-positives yields an estimated 80% label purity. The remaining 20% acts as controlled label noise, which empirical and theoretical self-supervised learning literature shows can prevent overfitting.
- Negative Clustering is Actively Harmful: Restricting anchors strictly to the positive set ($I^+$) prevents the loss from forcing disparate background tokens and un-targeted object classes into a single cluster.
Key Results
- REC-8K Benchmark: C-REX sets a new state-of-the-art on the REC-8K test set, reducing Mean Absolute Error (MAE) from 6.50 (GroundingREC) to 5.06 (a 22.1% improvement) and Root Mean Squared Error (RMSE) from 19.79 to 17.53 (a 11.4% improvement), while reaching an F1 score of 0.70.
- Attribute Breakdowns: The most dramatic improvements occur in attributes requiring spatial or visual disambiguation, such as action (MAE drops from 7.15 to 5.79), orientation (MAE drops from 3.81 to 1.94), and location (MAE drops from 21.91 to 16.14).
- Class-Agnostic Counting (FSC-147): When adapted to general class-agnostic counting, C-REX achieves 10.01 MAE and 101.46 RMSE on the test set, outperforming existing text-guided counters (e.g., CounTX's 15.88 MAE and GroundingREC's 10.12 MAE).
Limitations and Future Work
- Ultra-Fine OCR and Reading Comprehension: C-REX struggles when referring expressions require reading minute text (e.g., identifying bottle caps marked with the specific letter "T").
- Complex Multi-Layered Spatial Queries: Extreme spatial clutter across multiple lines (e.g., distinguishing birds specifically on the "bottom line" of closely spaced power cables) still leads to occasional boundary bleeding and false positives.
- Broader Vision-Language Tasks: The authors suggest adapting this image-space contrastive formulation beyond counting to referring expression comprehension and instance segmentation.
Summary updated