Attention Scaling for Crowd Counting

Xiaoheng Jiang, Li Zhang, Mingliang Xu, Tianzhu Zhang, Pei Lv, Bing Zhou, Xin Yang, Yanwei PangCVPR 2020 · DOI

TL;DR

This paper introduces a novel "Attention Scaling Network" (ASNet) that tackles the challenge of inconsistent crowd counting accuracy across regions of varying densities. By using a "Density Attention Network" (DANet) to generate density-specific attention masks and an "Adaptive Pyramid Loss" (APLoss) to refine training, ASNet significantly reduces estimation errors in both sparse and dense crowd areas, leading to state-of-the-art performance on several benchmark datasets.

What Problem Does This Paper Address?

Accurate crowd counting is crucial for applications like surveillance and public safety. While deep learning methods, particularly Convolutional Neural Networks (CNNs), have made significant strides, they often struggle with scenes containing diverse crowd densities. Specifically, these networks tend to either overestimate counts in dense areas or underestimate them in sparse regions. This inconsistency arises because standard CNNs learn a general mapping from image to density, failing to adapt to the varying visual characteristics and occlusions present in different crowd densities. The paper aims to bridge this gap by developing a method that can intelligently adjust its estimation based on local crowd density.

Methods

The proposed approach is built around two core novel components:

  • Density Attention Network (DANet): This network performs pixel-wise density segmentation. It classifies each pixel into one of several predefined density levels (e.g., background, low-density, high-density). The output is a set of binary "attention masks," where each mask highlights regions belonging to a specific density level. This allows the system to understand where different densities are located.
  • Attention Scaling Network (ASNet): This is the main counting network, composed of two branches:
  • Density Estimation Branch: Generates intermediate density maps.
  • Attention Scaling Branch: Generates "scaling factors." ASNet then combines these elements. It uses the attention masks from DANet to focus on specific density regions. For each region, it multiplies the intermediate density map by a corresponding scaling factor. These "attention-based density maps" are then summed to produce the final density map. The scaling factors are designed to dynamically adjust the density estimation, effectively attenuating errors in regions with different density patterns.

  • Adaptive Pyramid Loss (APLoss): To further improve training robustness, the authors introduce APLoss. Unlike standard losses that treat the entire density map uniformly, APLoss hierarchically divides the ground-truth density map into non-uniform sub-regions based on local crowd counts. It then calculates a localized loss for each sub-region, adapting to the varying density levels. This approach helps to mitigate training bias caused by the imbalance between low-density and high-density areas.

Datasets

The paper evaluates its approach on four widely used crowd counting datasets:

  • ShanghaiTech Part A: A common benchmark for dense crowd counting.
  • UCF_CC_50: Known for its challenging, large-scale crowd scenes.
  • UCF-QNRF: Features a large number of annotated heads and diverse scenes.
  • WorldExpo'10: Includes cross-scene test sets, evaluating the network's adaptability to different environments.

No new datasets were introduced in this paper.

Key Insights and Ideas

  • Density-Specific Attention is Key: The core insight is that treating all crowd regions the same is suboptimal. By explicitly identifying regions of different densities (low, medium, high) and applying specialized processing (attention masks and scaling factors), the model can achieve more accurate counts across the board.
  • Scaling Factors as "Human-like" Adjustment: The attention scaling mechanism is likened to how humans might adjust their perception based on context. Instead of a rigid pixel-wise correction, it applies a learned multiplicative factor, which is more efficient and potentially more robust.
  • Hierarchical Loss for Balanced Training: The Adaptive Pyramid Loss is a clever way to address the inherent data imbalance in crowd counting. By focusing on local errors within sub-regions and adapting to their density, it prevents the network from being overly influenced by dominant density types during training.
  • Cluttered Backgrounds Benefit Significantly: Qualitative results show that the attention mechanism not only helps with density variations but also makes the model more robust to cluttered backgrounds (like trees), where traditional methods often falter.

Key Results

  • Improved Accuracy: The proposed ASNet with DANet and APLoss achieved state-of-the-art or near state-of-the-art results on all four tested datasets, significantly outperforming baseline methods. For instance, on ShanghaiTech Part A, ASNet achieved an MAE of 57.78, a notable improvement.
  • Reduced Estimation Errors: Statistical analysis and qualitative visualizations demonstrate that ASNet substantially reduces estimation errors in both low-density (from 27.19 to 21.58 MAE) and high-density regions (from 55.66 to 45.94 MAE) on ShanghaiTech Part A compared to a baseline.
  • Ablation Study Success: Ablation studies confirmed the effectiveness of both attention scaling (best with 2 density levels) and the 2-level APLoss, which outperformed MSE loss and 3-level APLoss.
  • Robustness to Clutter: Qualitative analysis showed ASNet's superior performance in scenes with cluttered backgrounds.

Limitations and Future Work

  • Number of Density Levels: The paper explores using 2, 4, and 8 density levels. While 2 levels showed the best performance in their ablation study, the optimal number of levels might be dataset-dependent or could be learned adaptively.
  • Computational Cost: While not explicitly detailed, the introduction of an additional network (DANet) and more complex loss function likely increases computational overhead compared to simpler CNNs.
  • Future Work: The authors suggest that the attention scaling mechanism can be further explored for other computer vision tasks that involve varying scales or densities. The adaptive nature of the loss function also holds potential for other regression problems with imbalanced data.

Summary updated

BibTeX
@inproceedings{jiang2020attention,
  author = {Xiaoheng Jiang and Li Zhang and Mingliang Xu and Tianzhu Zhang and Pei Lv and Bing Zhou and Xin Yang and Yanwei Pang},
  title = {{Attention Scaling for Crowd Counting}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2020},
  doi = {10.1109/cvpr42600.2020.00476},
}
Figure