Crowd Transformer Network

Viresh Ranjan, Mubarak Shah, Minh Hoai NguyenarXiv 2019

Abstract

In this paper, we tackle the problem of Crowd Counting and present a crowd density estimation-based approach for obtaining the crowd count. Most existing crowd counting approaches rely on local features for estimating the crowd density map. In this work, we investigate the usefulness of combining local with non-local features for crowd counting. We use convolution layers for extracting local features and a type of self-attention mechanism for extracting non-local features. We combine the local and the non-local features and use them for estimating the crowd density map. We conduct experiments on three publicly available Crowd Counting datasets and achieve significant improvement over previous approaches.

Introduction

Crowd counting models typically use Convolutional Neural Networks (CNNs) to estimate a "density map" of an image, where the sum of the map's pixels equals the total number of people. However, standard convolution operations are inherently local—they only "see" a small patch of the image at a time based on their receptive field.

To make accurate predictions, a model often needs global, non-local context, such as understanding the overall perspective or lighting of the scene. While adding fully connected layers can capture this global information, it destroys the spatial locality crucial for generating accurate 2D density maps. Conversely, making a CNN extremely deep to expand its receptive field introduces optimization hurdles. The authors propose the Crowd Transformer Network (CTN) to efficiently capture long-range, non-local dependencies across an image while preserving the spatial layout needed for precise density estimation.

Methodology

The CTN is an end-to-end architecture consisting of three main components:

  1. Local Feature Block: A standard CNN (based on the first five layers of VGG-16) that extracts local spatial features from the input image.
  2. Non-local Feature Block: This core novelty takes the local features and applies a self-attention mechanism inspired by the Transformer architecture. To improve upon standard self-attention, the authors introduce Contextual Multi-Head Attention. This module uses 1D convolutions to incorporate a local neighborhood (a context window) before computing attention, rather than transforming single vectors in isolation.
  3. Density Prediction Head: A decoder that uses a skip connection to concatenate high-resolution local features with upsampled non-local features. This combined representation is passed through final convolution layers to predict the 2D crowd density map.
The proposed CTN architecture combining local and non-local feature blocks with a transformer-based attention mechanism.

Experiments and Results

The authors evaluated their model on three standard, highly challenging crowd counting benchmarks: UCF-QNRF, UCF Crowd Counting (UCF-CC), and Shanghaitech (Parts A and B).

On the UCF-QNRF dataset, which features extremely dense crowds, CTN achieved state-of-the-art performance. It reduced the Mean Absolute Error (MAE) by approximately 20%, from 132 to 102.6, and the RMSE from 191 to 177.7 compared to the previous best method (Composition Loss-CNN).

Comparison of CTN against state-of-the-art methods on the UCF-QNRF dataset, showing significant improvements in MAE and RMSE.

Additional results include:

  • UCF-CC: CTN reduced the MAE by ~15% (from 258.4 to 219.3) compared to the previous state-of-the-art.
  • Shanghaitech: The model achieved highly competitive results with an MAE of 64.3 on Part A and 8.6 on Part B.

Ablation studies confirmed that relying solely on local or non-local features yields poor results; the skip connection combining both is vital. Local features pinpoint exact locations, while non-local features provide the global scene context necessary to adjust density estimates based on perspective.

Conclusion

The Crowd Transformer Network demonstrates that integrating non-local context via contextual self-attention significantly enhances crowd density estimation. While the self-attention mechanism is memory-intensive—requiring large images to be processed in crops—it successfully captures long-range dependencies that standard CNNs miss. Future work may involve optimizing the memory footprint of the attention mechanism to handle high-resolution images more efficiently.

Summary updated

BibTeX
@misc{ranjan2019crowd,
  author = {Viresh Ranjan and Mubarak Shah and Minh Hoai Nguyen},
  title = {{Crowd Transformer Network}},
  year = {2019},
  eprint = {1904.02774},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1904.02774},
}
Figure