Skip to main content
QUICK REVIEW

[Paper Review] Joint CNN and Transformer Network via weakly supervised Learning for efficient crowd counting

Fusen Wang, Kai Liu|arXiv (Cornell University)|Mar 12, 2022
Video Surveillance and Tracking MethodsComputer Science10 citations
TL;DR

This paper proposes JCTNet, a joint CNN and Transformer network for weakly supervised crowd counting that uses only count-level annotations, avoiding costly location-level labeling. By combining CNNs for local semantic feature extraction with a modified Swin Transformer for global context modeling, JCTNet achieves state-of-the-art performance with 67–73% fewer parameters than pure Transformer models, while effectively focusing on crowd regions despite weak supervision.

ABSTRACT

Currently, for crowd counting, the fully supervised methods via density map estimation are the mainstream research directions. However, such methods need location-level annotation of persons in an image, which is time-consuming and laborious. Therefore, the weakly supervised method just relying upon the count-level annotation is urgently needed. Since CNN is not suitable for modeling the global context and the interactions between image patches, crowd counting with weakly supervised learning via CNN generally can not show good performance. The weakly supervised model via Transformer was sequentially proposed to model the global context and learn contrast features. However, the transformer directly partitions the crowd images into a series of tokens, which may not be a good choice due to each pedestrian being an independent individual, and the parameter number of the network is very large. Hence, we propose a Joint CNN and Transformer Network (JCTNet) via weakly supervised learning for crowd counting in this paper. JCTNet consists of three parts: CNN feature extraction module (CFM), Transformer feature extraction module (TFM), and counting regression module (CRM). In particular, the CFM extracts crowd semantic information features, then sends their patch partitions to TRM for modeling global context, and CRM is used to predict the number of people. Extensive experiments and visualizations demonstrate that JCTNet can effectively focus on the crowd regions and obtain superior weakly supervised counting performance on five mainstream datasets. The number of parameters of the model can be reduced by about 67%~73% compared with the pure Transformer works. We also tried to explain the phenomenon that a model constrained only by count-level annotations can still focus on the crowd regions. We believe our work can promote further research in this field.

Motivation & Objective

  • To address the high annotation cost of fully supervised crowd counting methods that require location-level bounding boxes for each person.
  • To overcome the limitations of CNNs in modeling long-range dependencies and global context in crowd scenes.
  • To mitigate the drawbacks of pure Transformer models, including excessive parameters and unreasonable patch partitioning that splits individuals across tokens.
  • To develop a weakly supervised crowd counting framework that achieves high accuracy using only image-level count annotations.
  • To explain how a model trained solely on count-level supervision can still attend to crowd regions through complementary CNN and Transformer learning.

Proposed method

  • JCTNet integrates a CNN feature extraction module (CFM) based on VGG16-BN's first ten layers to extract local semantic features from input images.
  • The feature maps from CFM are partitioned into patches and fed into a modified Swin Transformer block (MSTB) for global context modeling and long-range dependency learning.
  • The Transformer module uses local self-attention and cross-window interaction to preserve spatial relationships and improve feature representation.
  • A counting regression module (CRM) processes the final token features from the Transformer to predict the total number of people in the image.
  • The model is trained end-to-end using a Smooth L1 loss function to minimize prediction error on count-level supervision.
  • The architecture is designed to reduce parameter count by leveraging CNN’s inductive bias while retaining the global modeling strength of Transformers.

Experimental results

Research questions

  • RQ1Can a weakly supervised crowd counting model trained only on image-level counts still attend to actual crowd regions?
  • RQ2How can CNN and Transformer be jointly optimized to improve performance while reducing model complexity?
  • RQ3Does the self-attention mechanism in Transformers enable better distinction between crowd and background regions compared to CNNs alone?
  • RQ4What is the optimal trade-off between embedding dimension and number of Swin Transformer blocks in the proposed architecture?
  • RQ5Why does the model generalize well despite lacking location-level supervision?

Key findings

  • JCTNet achieves a mean absolute error (MAE) of 62.8 on the ShanghaiTech Part A dataset, outperforming previous weakly supervised methods.
  • The model reduces parameter count by 67–73% compared to pure Transformer-based approaches, with 28.8M parameters in the best configuration.
  • The ablation study confirms that each component—CFM, TFM, and CRM—contributes progressively to performance improvement.
  • Using Smooth L1 loss instead of L1 loss reduces MAE from 63.7 to 62.8 and MSE from 98.1 to 95.6 on ShanghaiTech Part A.
  • Visualization shows that the model still focuses on crowd regions (red rectangles) even without location-level supervision, indicating effective attention learning.
  • The combination of CNN’s inductive bias and Transformer’s global modeling enables the model to learn contrastive features between foreground and background, explaining its robustness under weak supervision.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.