Exploring Contextual Attribute Density in Referring Expression Counting

Zhicheng Wang, Zhiyu Pan, Zhan Peng, Jian Cheng, Liwen Xiao, Wei Jiang, Zhiguo Cao

Abstract

Referring Expression Counting (REC) is the task of identifying and counting specific objects in a crowded scene based on natural language descriptions (e.g., "people wearing red hats"). Despite the success of open-world detectors, current models often fail to distinguish fine-grained attributes in dense environments, leading to significant over-counting or under-counting. This paper introduces Contextual Attribute Density (CAD), a novel framework that models the spatial intensity of specific attributes across an image. Our proposed model, CAD-GD, integrates density estimation into a grounding pipeline, achieving a 37.8% relative reduction in Mean Absolute Error (MAE) on the REC-8K benchmark and a 10% boost in localization accuracy.

Introduction

Standard object counting focuses on broad categories, but Referring Expression Counting (REC) requires a nuanced understanding of attributes, such as actions ("cars driving to the left") or specific appearances ("person in a blue shirt"). Existing state-of-the-art models, often built upon architectures like GroundingDINO, typically rely on one-to-one matching between text and image regions. This approach frequently fails in two ways:

  1. Over-counting: The model identifies the broad class (e.g., "person") but ignores the specific attribute (e.g., "walking"), counting every instance of the class in the frame.
  2. Under-counting: Small, occluded, or distant objects are missed because the model lacks a global context of where specific attributes are likely to cluster.

To address these issues, we propose treating fine-grained attributes as a density problem. By predicting a "density map" for specific attributes, the model gains a global perspective that bridges the gap between high-level text descriptions and low-level visual patterns.

Methodology: The CAD-GD Framework

The CAD-GD (Contextual Attribute Density Aware GroundingDINO) framework enhances the standard detection pipeline with three specialized modules designed to leverage attribute intensity.

The CAD-GD architecture consists of three core modules: CAD Generate, CAD Attention, and CAD Dynamic Query, which refine visual features and initialize object queries based on attribute density.

CAD Generate Module

At the core of our approach is the U-shape CAD Estimator (CADE). This module takes multi-scale visual features and calculates their similarity to the text prompt to produce a predicted density map. This map represents the "intensity" of the requested attribute across the image, providing the model with a global heatmap of potential targets.

CAD Attention Module

The generated CAD features are used to re-weight visual data through Spatial and Channel Attention. Spatial attention focuses the model's processing power on regions with high attribute density, while channel attention emphasizes the visual characteristics (like color or texture) most relevant to the text query.

CAD Dynamic Query Module

In traditional DETR-style models, object queries are often static. CAD-GD introduces Dynamic Query Initialization, which combines text features with the top-K features from the CAD density map. This ensures that the model's search for objects begins with a "mental image" informed by both the linguistic description and the visual density of the target attributes.

Experimental Results

We evaluated CAD-GD across several benchmarks, including REC-8K, FSC-147 (for zero-shot counting), and CARPK (for cross-dataset generalization).

Quantitative Performance

On the REC-8K dataset, CAD-GD achieved a 37.8% relative reduction in MAE on the validation set compared to previous baselines. Furthermore, localization accuracy (measured by F1 score and Precision) improved by approximately 10%, demonstrating that the model is not just better at counting, but better at identifying the correct objects.

In zero-shot scenarios on the FSC-147 dataset, CAD-GD outperformed all other text-guided methods, approaching the performance of models that require visual exemplars. On the CARPK dataset, the model achieved an MAE of 3.29, surpassing the previous state-of-the-art (3.68) without any car-specific training.

Qualitative Analysis

Visual comparisons highlight the effectiveness of the CAD approach in disambiguating crowded scenes. As shown in Figure 1, baseline models often count every person in a crowd when asked for a "person walking." In contrast, CAD-GD uses the density map to isolate only the individual matching the specific attribute.

Qualitative comparison between a baseline REC model and CAD-GD. The baseline over-counts by including all people, while CAD-GD accurately isolates the target based on the "walking" attribute using the predicted density map.

Conclusion

By introducing Contextual Attribute Density, we provide a robust mechanism for models to understand the global distribution of fine-grained attributes. CAD-GD effectively mitigates the common pitfalls of over-counting and under-counting in dense scenes. While the current inference strategy occasionally presents a trade-off between counting precision and localization metrics, the overall framework sets a new standard for Referring Expression Counting. Future work will explore applying CAD to other multi-modal tasks, such as complex image retrieval and instance segmentation.

Summary updated

BibTeX
@inproceedings{wang2025exploring,
  author = {Zhicheng Wang and Zhiyu Pan and Zhan Peng and Jian Cheng and Liwen Xiao and Wei Jiang and Zhiguo Cao},
  title = {{Exploring Contextual Attribute Density in Referring Expression Counting}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2025},
  doi = {10.1109/cvpr52734.2025.01824},
}
Figure