NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Context-Aware Crowd Counting

Weizhe Liu, Mathieu Salzmann, Pascal Fua

Abstract

State-of-the-art methods for counting people in crowded scenes rely on deep networks to estimate crowd density. They typically use the same filters over the whole image or over large image patches. Only then do they estimate local scale to compensate for perspective distortion. This is typically achieved by training an auxiliary classifier to select, for predefined image patches, the best kernel size among a limited set of choices. As such, these methods are not end-to-end trainable and restricted in the scope of context they can leverage. In this paper, we introduce an end-to-end trainable deep architecture that combines features obtained using multiple receptive field sizes and learns the importance of each such feature at each image location. In other words, our approach adaptively encodes the scale of the contextual information required to accurately predict crowd density. This yields an algorithm that outperforms state-of-the-art crowd counting methods, especially when perspective effects are strong.

Introduction

Crowd counting is a critical task in computer vision, yet it remains notoriously difficult due to perspective distortion. In a typical crowded scene, a person near the camera may occupy hundreds of pixels, while individuals in the far background appear as mere specks.

Standard Convolutional Neural Networks (CNNs) often struggle with this variance because they apply fixed-size filters across the entire image, implicitly assuming a uniform scale. Previous attempts to mitigate this involved multi-column networks or patch-based classifiers. However, multi-column networks often fuse features indiscriminately, and patch-based classifiers are rarely end-to-end trainable, struggling with rapid scale changes within a single patch. This research introduces a unified pipeline that automatically senses local scale and adjusts its receptive field pixel-by-pixel.

Methodology

The proposed Context-Aware Network (CAN) architecture is built on three main pillars designed to handle scale variation dynamically:

  1. Multi-Scale Feature Extraction: Using the first ten layers of VGG-16 as a backbone, the model employs Spatial Pyramid Pooling (SPP) to extract features at four different receptive field sizes.
  2. Contrast Features: The model computes "contrast features" by finding the difference between local features and their surrounding context. This acts as a saliency cue, helping the network identify how a region differs from its neighborhood.
  3. Adaptive Weighting: The network learns an auxiliary weighting mechanism that predicts a weight map for each scale at every pixel. These weights determine the influence of each receptive field size on the final density estimation at that specific location.
The architecture of the Context-Aware Network (CAN), illustrating the flow from feature extraction to adaptive weighting and contrast feature generation.

For scenarios where camera calibration is available, the authors also introduce ECAN (Expanded Context-Aware Network), which incorporates a perspective map as an additional input to guide the weighting process.

Experiments and Results

The model was evaluated on several rigorous benchmarks, including ShanghaiTech (Part A & B), UCF-QNRF, UCF_CC_50, and WorldExpo’10. Additionally, the authors introduced the Venice Dataset, which features strong perspective distortion captured from elevated viewpoints.

Key results include:

  • ShanghaiTech Part A: Achieved a Mean Absolute Error (MAE) of 62.3, outperforming the previous state-of-the-art (67.0).
  • UCF-QNRF: Reduced MAE to 107, a significant improvement over the previous best of 132.
  • UCF_CC_50: Achieved an MAE of 212.2, substantially lower than the 258.4 reported by previous methods.
Qualitative comparison of input images, ground truth density maps, and CAN predictions across different crowd densities.

Discussion and Insights

The success of CAN stems from the realization that scale is continuous, not discrete. By treating scale as a pixel-wise weighted combination rather than picking from a few "bins," the model allows for smooth transitions as people move through the depth of a scene. Furthermore, the inclusion of contrast features proves that the difference between a pixel and its neighbors is a powerful indicator of local scale.

While the model sets new benchmarks, future work may focus on regressing density directly to the "ground-plane" (people per square meter) rather than the image plane, and incorporating temporal consistency for video-based crowd counting. Despite the computational overhead of multi-scale branches, the end-to-end nature of the network provides a robust framework for high-accuracy density estimation in complex environments.

Summary updated

BibTeX
@inproceedings{liu2019context,
  author = {Weizhe Liu and Mathieu Salzmann and Pascal Fua},
  title = {{Context-Aware Crowd Counting}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2019},
  url = {https://openreview.net/forum?id=H6D-ZAoSsx5},
}
Figure