Learning Discriminative Features for Crowd Counting

Yuehai Chen, Qingzhong Wang, Jing Yang, Badong Chen, Haoyi Xiong, Shaoyi Du · DOI

TL;DR

LDFNet introduces two lightweight, "plug-and-play" modules—Masked Feature Prediction (MPM) and Supervised Pixel-level Contrastive Learning (CLM)—to significantly enhance the accuracy of crowd counting in highly congested scenes. By forcing the model to reconstruct missing features and better separate people from cluttered backgrounds in the feature space, the framework achieves state-of-the-art performance across multiple major benchmarks.

What Problem Does This Paper Address?

Crowd counting in extremely dense environments (like protests, concerts, or busy city centers) is notoriously difficult for standard Convolutional Neural Networks (CNNs). Two main issues plague existing regression-based models:

  1. Weak Localization: Because heads in dense crowds are tiny, high-level CNN features often lack the resolution to pinpoint them accurately, leading to "over-smoothed" density maps where individual people are blurred together.
  2. Foreground-Background Confusion: In overcrowded regions, models often fail to distinguish between the foreground (people) and complex backgrounds, leading to significant underestimation of the total count.
Fig. 1. Problems of existing regression-based crowd counting models. From left to right: input images from ShanghaiTech Part A dataset [9], Ground Truth density maps, the predicted density maps from DM-Count [6], and the predicted density maps from our LDFNet+DM-Count.

Methods

The authors propose the Learning Discriminative Features Network (LDFNet), which consists of a standard backbone (like VGG-19) augmented by two novel modules:

  • Masked Feature Prediction Module (MPM): Inspired by Masked Autoencoders (MAE), this module randomly masks feature vectors in the feature map during training. A Transformer encoder then attempts to reconstruct these masked vectors based on the surrounding context. This forces the model to learn fine-grained spatial relationships and contextual cues, which directly improves its ability to localize small objects in dense regions.
  • Supervised Pixel-level Contrastive Learning Module (CLM): This module operates in the feature space to pull "head" features closer together while pushing them away from "background" features. By maximizing this separation, the model becomes much more robust at identifying people against cluttered backgrounds.
Fig. 3. The proposed learning discriminative feature network (LDFNet) framework. The LDFNet mainly contains a backbone, a masked feature prediction module (MPM), and a supervised pixel-level contrastive learning module (CLM). All the components including the backbone, MPM, CLM, and regression decoder are trainable in the training phase. While in the inference phase, the CLM would be removed and other components are used for inference. The masking process is pixel-wise on feature map whose size is 1/32 of the input image. For intuitive visualization, we upsample the feature map to the size of the original image. As a result, this figure presents that the masking process seems patch-wise (32×32).

Crucially, these modules are plug-and-play. They can be added to existing architectures like CSRNet or DM-Count. Furthermore, the CLM is only used during training as a regularizer and can be removed during inference, meaning it adds zero computational overhead when the model is actually deployed.

Datasets

The researchers evaluated LDFNet on six widely used crowd counting benchmarks:

  • ShanghaiTech Part A & B: Images from the internet and busy streets.
  • UCF_CC_50: An extremely dense dataset with only 50 images.
  • UCF-QNRF: A large-scale, challenging dataset with a wide range of counts.
  • NWPU-Crowd: Currently the largest and most challenging public dataset.
  • JHU-Crowd++: A large dataset categorized by density levels (low, medium, high).

Key Insights and Ideas

  • Feature-Level Masking is Key: Unlike standard MAE which masks raw image pixels, MPM masks deep features. The authors found that feature maps contain richer semantic information, and reconstructing them is more effective for the specific task of counting than reconstructing raw pixels.
  • Optimal Masking Ratios: While MAE often uses a high masking ratio (e.g., 75%), this paper found an optimal ratio of 15% for crowd counting. Too much masking makes it impossible to reconstruct the dense, overlapping features of a crowd.
  • Contrastive Learning as a Separator: The CLM acts as a powerful discriminator. By pulling targets together in the feature space, it mitigates the common problem where dense foreground regions are misidentified as background.
Fig. 2. The proposed supervised pixel-level contrastive learning module pulls pull the targets closer to each other and push them further away from the background.

Key Results

LDFNet consistently improved the performance of every baseline model it was plugged into.

  • State-of-the-Art on NWPU: The "LDFNet+MAN" combination achieved the best performance on the challenging NWPU dataset with an MAE of 72.1 and RMSE of 314.4.
  • Density-Specific Gains: On the JHU-Crowd++ dataset, LDFNet improved the baseline DM-Count model by 16.5% in MAE overall, with the most significant gains coming from medium and high-density scenes.
  • Localization Boost: Beyond just counting, the MPM significantly improved localization metrics (Precision, Recall, and F1-score) when integrated into point-based frameworks like P2PNet.
Table showing performance improvements across multiple datasets when LDFNet is added to various baselines.

Limitations and Future Work

  • Low-Density Trade-off: The authors noted that while LDFNet excels in dense scenes, it can slightly degrade performance in very low-density areas (e.g., a -7.3% MAE change for DM-Count on low-density JHU-Crowd++ images). This suggests the model becomes highly specialized for congestion.
  • Computational Cost of MPM: While CLM is removed at inference, the MPM (specifically the Transformer encoder) does add some parameters and FLOPs during inference compared to pure CNN baselines, though it remains much lighter than full Vision Transformer models like ViT-B.
  • Future Directions: The authors suggest that these modules could be beneficial for other dense prediction tasks, such as object detection in cluttered environments.

Summary updated

BibTeX
@article{chen2024learning,
  author = {Yuehai Chen and Qingzhong Wang and Jing Yang and Badong Chen and Haoyi Xiong and Shaoyi Du},
  title = {{Learning Discriminative Features for Crowd Counting}},
  journal = {IEEE Trans. Image Process.},
  year = {2024},
  url = {https://openreview.net/forum?id=yNaNJt9GGd},
}
Figure