Diffusion-based Data Augmentation for Object Counting Problems

Zhen Wang, Yuelei Li, Jia Wan, Nuno Vasconcelos

Crowd counting—the task of estimating the number of people in a dense image—is a critical tool for public safety and urban planning. However, training the deep learning models that power this technology is a logistical nightmare. Labeling a single image can involve manually placing thousands of dots on individual heads. Consequently, even the "large" datasets in this field are tiny, often containing fewer than 3,500 images.

In the paper "Diffusion-based Data Augmentation for Object Counting Problems," researchers from UC San Diego and the Harbin Institute of Technology propose a clever solution: if you don't have enough data, use a generative AI to dream up some more—but with a level of precision that standard models can't match.

TL;DR

The authors present the first framework to use diffusion models (specifically a modified ControlNet) to generate synthetic crowd images conditioned on precise "location dot maps." By introducing a novel counting loss and guided sampling, they created high-quality training data that significantly improves the accuracy of state-of-the-art counting models across multiple benchmarks.

What Problem Does This Paper Address?

Deep learning models are data-hungry. In crowd counting, this leads to a "data scarcity" trap. Because manual labeling is so labor-intensive, models often overfit to the limited scenes available in existing datasets.

Standard data augmentation (like flipping or rotating images) helps, but it doesn't change the underlying distribution of the crowd. Generative models like GANs or standard Diffusion models could theoretically help, but they struggle with "high-frequency" details—they might generate a beautiful park scene but fail to put exactly 452 people in the specific spots required by the training label. This paper tackles the challenge of controllable generation: ensuring the "where" and "how many" of the generated image perfectly match the input metadata.

Methods

The researchers built their pipeline on ControlNet, a popular adapter for Stable Diffusion that allows for extra conditioning (like depth maps or edges). However, they introduced three key innovations to make it work for counting:

  1. Smoothed Density Map Input: Raw dot maps (where a single pixel represents a head) are too sparse for diffusion models to understand. The authors convolve these dots with a Gaussian kernel to create a "smoothed density map." This provides the spatial context the model needs to learn where to place human features.
  2. Counting Loss ($L_{count}$): During training, the generated image is passed through a pre-trained crowd-counting model. The system calculates the difference between the intended count and the generated count, using this "counting loss" to fine-tune the generator.
  3. Counting-Guided Sampling: During the actual generation (inference), the authors use the gradient of the counting loss to "nudge" the diffusion process. This ensures that as the image emerges from the noise, it aligns more accurately with the dot map.
  4. Background Diversity: By using BLIP (a vision-language model) to generate descriptive text prompts, they ensured the synthetic images weren't just "people in a vacuum" but included diverse backgrounds like cinemas, music festivals, and streets.

Datasets

The authors evaluated their method on the "Big Four" of crowd counting:

  • ShanghaiTech (Part A & B): Standard benchmarks for web-collected and street-view images.
  • UCF-QNRF: A high-resolution dataset with extremely dense crowds.
  • NWPU-Crowd: Currently the largest and most challenging dataset (over 2.1 million annotated heads).
  • TRANCOS: Used to demonstrate versatility, this dataset focuses on vehicle counting in traffic congestion.

Key Insights and Ideas

  • The Sparsity Problem: The most significant "aha" moment was realizing that standard conditioning fails on dot maps because they are "too empty." Smoothing the dots into a density map was the key to unlocking ControlNet’s potential for this task.
  • Weak Guidance is Stronger: The authors found that applying the counting loss only when the noise level is low ($t < 400$) is more effective. Early in the diffusion process, the image is too noisy for a counting model to provide meaningful feedback.
  • The 30% Rule: Through ablation studies, they discovered that the optimal "synthetic-to-real" data ratio is about 30%. Adding too much synthetic data can eventually degrade performance because of the subtle "domain gap" between AI-generated images and reality.

Key Results

The results were consistent across the board: adding synthetic data made existing models better.

  • NWPU-Crowd: Using their augmentation, the CUT model saw its Mean Squared Error (MSE) drop from 304.0 to 259.2, a massive improvement in stability.
  • ShanghaiTech Part A: The STEERER model improved its Mean Absolute Error (MAE) from 54.5 to 52.3.
  • Versatility: The method worked just as well for cars. On the TRANCOS dataset, they achieved a new state-of-the-art MAE of 1.7.

Limitations and Future Work

The authors acknowledge a fundamental trade-off: by forcing the model to be hyper-accurate about where people are, they sometimes sacrifice the visual quality of the individual people (they might look a bit "melty" upon close inspection).

Future work will likely focus on closing this gap—improving the photorealism of the generated crowds without losing the strict spatial correspondence. There is also potential to expand this to other "counting" fields, such as microscopic cell counting or agricultural yield estimation.

Summary updated

BibTeX
@inproceedings{wang2025diffusion,
  author = {Zhen Wang and Yuelei Li and Jia Wan and Nuno Vasconcelos},
  title = {{Diffusion-based Data Augmentation for Object Counting Problems}},
  booktitle = {IEEE International Conference on Acoustics, Speech and Signal Processing},
  year = {2025},
  doi = {10.1109/icassp49660.2025.10888449},
}
Figure