C^3 Framework: An Open-source PyTorch Code for Crowd Counting

Junyu Gao, Wei Lin, Bin Zhao, Dong Wang, Chenyu Gao, Jun WenarXiv 2019

Abstract

The C³ Framework (Crowd Counting Code Framework) is an open-source PyTorch-based development kit designed to standardize the "wild west" of crowd counting research. By providing unified data preprocessing, solid baseline models (AlexNet, VGG, ResNet), and a robust logging system, it enables researchers to perform fair, reproducible comparisons across major datasets.

Introduction

Crowd counting—estimating the number of people in a crowded image via density maps—has seen a surge in deep learning-based solutions. However, the field has been plagued by a lack of standardization. Different researchers often use varying image scales, data augmentation tricks, and training hyperparameters, making it nearly impossible to determine if a performance boost comes from a novel architecture or just a better-tuned training pipeline.

The authors introduce the C³ Framework to eliminate this "noise" by providing a uniform interface and a set of high-quality baselines, allowing the community to focus on architectural innovation rather than boilerplate code.

Methodology and Pipeline

The framework is built on three pillars: standardized preprocessing, label transformation, and a modular model zoo.

Overview of the C³ Framework pipeline, from input image to loss calculation.

Standardized Preprocessing

To ensure neural network layers (like max-pooling) function correctly without alignment errors, the framework automatically restrains input image dimensions to be multiples of 16. This "Divisible by 16" rule avoids "off-by-one" errors that occur during multiple stages of down-sampling (2^4 = 16). It also handles batching strategies specifically for datasets with varying image sizes.

Label Transformation and Normalization

The authors address how ground-truth density maps are handled. While some models down-sample the ground truth to match a smaller output, the C³ Framework suggests stacking up-sampling layers in the model to match the original image size. This preserves the integrity of image quality metrics like PSNR and SSIM. Additionally, they utilize Label Normalization (multiplying density maps by 100) to accelerate convergence and achieve lower estimation errors.

Modular Model Zoo

The framework adapts classic classification backbones for regression tasks:

  • AlexNet/VGG: Modified to act as encoders with custom decoders (convolutional + up-sampling layers) to regress 1-channel density maps.
  • ResNet: Modified by changing the stride of specific layers to preserve spatial resolution for better density estimation.
The regression head used in the framework to produce the final density map.

Benchmarks and Results

The framework supports six mainstream crowd counting datasets out-of-the-box, including UCF_CC_50, ShanghaiTech (SHT) Part A & B, UCF-QNRF, WorldExpo’10, and the synthetic GCC dataset.

The authors demonstrate the framework's efficacy by reproducing several landmark models. A standard VGG-16 backbone achieved a Mean Absolute Error (MAE) of 10.3 on ShanghaiTech Part A. ResNet-101 proved to be a powerhouse, achieving an MAE of 7.6 and MSE of 12.2, rivaling state-of-the-art specialized models. Furthermore, the framework successfully improved upon original paper results in some cases; for instance, their reproduction of CMTL achieved an MAE of 14.0, significantly better than the original 20.0.

Conclusion

As a technical infrastructure report, the C³ Framework focuses on providing solid baselines and a powerful logging system to ensure reproducibility. While the field moves toward complex attention mechanisms, this framework serves as a relevant "one-stop shop" for crowd counting research, ensuring that performance gains are attributed to innovation rather than engineering variance.

Summary updated

Abstract

This technical report attempts to provide efficient and solid kits addressed on the field of crowd counting, which is denoted as Crowd Counting Code Framework (C$^3$F). The contributions of C$^3$F are in three folds: 1) Some solid baseline networks are presented, which have achieved the state-of-the-arts. 2) Some flexible parameter setting strategies are provided to further promote the performance. 3) A powerful log system is developed to record the experiment process, which can enhance the reproducibility of each experiment. Our code is made publicly available at \url{https://github.com/gjy3035/C-3-Framework}. Furthermore, we also post a Chinese blog\footnote{\url{https://zhuanlan.zhihu.com/p/65650998}} to describe the details and insights of crowd counting.
BibTeX
@misc{gao2019c,
  author = {Junyu Gao and Wei Lin and Bin Zhao and Dong Wang and Chenyu Gao and Jun Wen},
  title = {{C^3 Framework: An Open-source PyTorch Code for Crowd Counting}},
  year = {2019},
  eprint = {1907.02724},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1907.02724},
}
Figure