CSRNet: Dilated Convolutional Neural Networks for Understanding the Highly Congested Scenes
Yuhong Li Xiaofan Zhang Deming Chen











CSRNet: Dilated Convolutional Neural Networks for Understanding the Highly Congested Scenes

    Yuhong Li^1,2, Xiaofan Zhang^1, Deming Chen^1 

        ^1University of Illinois at Urbana-Champaign

        ^2Beijing University of Posts and Telecommunications

        {leeyh,xiaofan3,dchen}@illinois.edu 


    December 30, 2023
======================================================================================================================================================================================================================

empty










We propose a network for Congested Scene Recognition called CSRNet to provide a data-driven and deep learning method that can understand highly congested scenes and perform accurate count estimation as well as present high-quality density maps. The proposed CSRNet is composed of two major components: a convolutional neural network (CNN) as the front-end for 2D feature extraction and a dilated CNN for the back-end, which uses dilated kernels to deliver larger reception fields and to replace pooling operations. CSRNet is an easy-trained model because of its pure convolutional structure. We demonstrate CSRNet on four datasets (ShanghaiTech dataset, the UCF_CC_50 dataset, the WorldEXPO'10 dataset, and the UCSD dataset) and we deliver the state-of-the-art performance. In the ShanghaiTech Part_B dataset, CSRNet achieves  47.3% lower Mean Absolute Error (MAE) than the previous state-of-the-art method. We extend the targeted applications for counting other objects, such as the vehicle in TRANCOS dataset. Results show that CSRNet significantly improves the output quality with 15.4% lower MAE than the previous state-of-the-art approach. 







§ INTRODUCTION




Growing number of network models have been developed <cit.> to deliver promising solutions for crowd flows monitoring, assembly controlling, and other security services. 


Current methods for congested scenes analysis are developed from simple crowd counting (which outputs the number of people in the targeted image) to density map presenting (which displays characteristics of crowd distribution)  <cit.>. This development follows the demand of real-life applications since the same number of people could have completely different crowd distributions (as shown in Fig. <ref>), so that just counting the number of crowds is not enough. The distribution map helps us for getting more accurate and comprehensive information, which could be critical for making correct decisions in high-risk environments, such as stampede and riot. 

However, it is challenging to generate accurate distribution patterns. One major difficulty comes from the prediction manner: since the generated density values follow the pixel-by-pixel prediction, output density maps must include spatial coherence so that they can present the smooth transition between nearest pixels.

Also, the diversified scenes, e.g., irregular crowd clusters and different camera perspectives, would make the task difficult, especially for using traditional methods without deep neural networks (DNNs). 

The recent development of congested scene analysis relays on DNN-based methods because of the high accuracy they have achieved in semantic segmentation tasks <cit.> and the significant progress they have made in visual saliency <cit.>. The additional bonus of using DNNs comes from the enthusiastic hardware community where DNNs are rapidly investigated and implemented on GPUs <cit.>, FPGAs <cit.>, and ASICs <cit.>. Among them, the low-power, small-size schemes are especially suitable for deploying congested scene analysis in surveillance devices. 






Previous works for congested scene analysis are mostly based on multi-scale architectures <cit.>. They have achieved high performance in this field but the designs they used also introduce two significant disadvantages when networks go deeper: large amount of training time and non-effective branch structure (e.g., multi-column CNN (MCNN) in <cit.>).
We design an experiment to demonstrate that the MCNN does not perform better compared to a deeper, regular network in Table  <ref>. The main reason of using MCNN in  <cit.> is the flexible receptive fields provided by convolutional filters with different sizes across the column. Intuitively, each column of MCNN is dedicated to a certain level of congested scene. However, the effectiveness of using MCNN may not be prominent. We present Fig. <ref> to illustrate the features learned by three separated columns (representing large, medium, and small receptive fields) in MCNN and evaluate them with ShanghaiTech Part_A <cit.> dataset. The three curves in this figure share very similar patterns (estimated error rate) for 50 test cases with different congest densities meaning that each column in such branch structure learn nearly identical features. It performs against the original intention of the MCNN design for learning different features for each column. 

In this paper, we design a deeper network called CSRNet for counting crowd and generating high-quality density maps. Unlike the latest works such as <cit.> which use the deep CNN for ancillary, we focus on designing a CNN-based density map generator. Our model uses pure convolutional layers as the backbone to support input images with flexible resolutions. To limit the network complexity, we use the small size of convolution filters (like 3×3) in all layers. We deploy the first 10 layers from VGG-16 <cit.> as the front-end and dilated convolution layers as the back-end to enlarge receptive fields and extract deeper features without losing resolutions (since pooling layers are not used). 

By taking advantage of such innovative structure, we outperform the state-of-the-art crowd counting solutions (a MCNN based solution called CP-CNN <cit.>) with 7%, 47.3%, 10.0%, and 2.9% lower Mean Absolute Error (MAE) in ShanghaiTech <cit.> Part_A, Part_B, UCF_CC_50 <cit.>, and WorldExpo'10 <cit.> datasets respectively. Also, we achieve high performance on the UCSD dataset <cit.> with 1.16 MAE. After extending this work to vehicle counting on TRANCOS dataset <cit.>, we achieve 15.4% lower MAE than the current best approach, called FCN-HA <cit.>.

The rest of the paper is structured as follows. Sec. <ref> presents the previous works for crowd counting and density map generation. Sec. <ref> introduces the architecture and configuration of our model while Sec. <ref> presents the experimental results on several datasets. In Sec. <ref>, we conclude the paper.








§ RELATED WORK


Following the idea proposed by Loy . <cit.>, the potential solutions for crowd scenes analysis can be classified into three categories:  detection-based methods, regression-based methods, and density estimation-based methods. By combining the deep learning, the CNN-based solutions show even stronger ability in this task and outperform the traditional methods.



 §.§ Detection-based approaches

Most of the early researches focus on detection-based approaches using a moving-window-like detector to detect people and count their number <cit.>. These methods require well-trained classifiers to extract low-level features from the whole human body (like Haar wavelets <cit.> and HOG (histogram oriented gradients) <cit.>). However, they perform poorly on highly congested scenes since most of the targeted objects are obscured. To tackle this problem, researchers detect particular body parts instead of the whole body to complete crowd scenes analysis <cit.>.



 §.§ Regression-based approaches

Since detection-based approaches can not be adapted to highly congested scenes, researchers try to deploy regression-based approaches to learn the relations among extracted features from cropped image patches, and then calculate the number of particular objects. More features, such as foreground and texture features, have been used for generating low-level information <cit.>. Following similar approaches, Idrees . <cit.> propose a model to extract features by employing Fourier analysis and SIFT (Scale-invariant feature transform) <cit.> interest-point based counting.



 §.§ Density estimation-based approaches

When executing the regression-based solution, one critical feature, called saliency, is overlooked which causes inaccurate results in local regions. 
Lempitsky . <cit.> propose a method to solve this problem by learning a linear mapping between features in the local region and its object density maps. It integrates the information of saliency during the learning process. Since the ideal linear mapping is hard to obtain, Pham . <cit.> use random forest regression to learn a non-linear mapping instead of the linear one.




 §.§ CNN-based approaches

Literature also focuses on the CNN-based approaches to predict the density map because of its success in classification and recognition <cit.>. 
In the work presented by Walach and Wolf <cit.>, a method is demonstrated with selective sampling and layered boosting. Instead of using patch-based training, Shang . <cit.> try an end-to-end regression method using CNNs which takes the entire image as input and directly outputs the final crowd count.
Boominathan . <cit.> present the first work purely using convolutional networks and dual-column architecture for generating density map. Marsden . <cit.> explore single-column fully convolutional networks while Sindagi . <cit.> propose a CNN which uses the high-level prior information to boost the density prediction performance. An improved structure is proposed by Zhang . <cit.> who introduce a multi-column based architecture (MCNN) for crowd counting. Similar idea is shown in Onoro and Sastre <cit.> where a scale-aware, multi-column counting model called Hydra CNN is presented for object density estimation. It is clear that the CNN-based solutions outperform the previous works mentioned in Sec. 2.1 to 2.3.





 §.§ Limitations of the state-of-the-art approaches


Most recently, Sam . <cit.> propose the Switch-CNN using a density level classifier to choose different regressors for particular input patches. Sindagi . <cit.> present a Contextual Pyramid CNN, which uses CNN networks to estimate context at various levels for achieving lower count error and better quality density maps. 
These two solutions achieve the state-of-the-art performance, and both of them used multi-column based architecture (MCNN) and density level classifier. However, we observe several disadvantages in these approaches: (1) Multi-column CNNs are hard to train according to the training method described in work <cit.>. Such bloated network structure requires more time to train.  (2) Multi-column CNNs introduce redundant structure as we mentioned in Sec. <ref>. Different columns seem to perform similarly without obvious differences. (3) Both solutions require density level classifier before sending pictures in the MCNN. However, the granularity of density level is hard to define in real-time congested scene analysis since the number of objects keeps changing with a large range. Also, using a fine-grained classifier means more columns need to be implemented which makes the design more complicated and causes more redundancy. 
(4) These works spend a large portion of parameters for density level classification to label the input regions instead of allocating parameters to the final density map generation. Since the branch structure in MCNN is not efficient, the lack of parameters for generating density map lowers the final accuracy. Taking all above disadvantages into consideration, we propose a novel approach to concentrate on encoding the deeper features in congested scenes and generating high-quality density map. 



§ PROPOSED SOLUTION



The fundamental idea of the proposed design is to deploy a deeper CNN for capturing high-level features with larger receptive fields and generating high-quality density maps without brutally expanding network complexity. In this section, we first introduce the architecture we proposed, and then we present the corresponding training methods.



 §.§ CSRNet architecture

Following the similar idea in  <cit.>, we choose VGG-16 <cit.> as the front-end of CSRNet because of its strong transfer learning ability and its flexible architecture for easily concatenating the back-end for density map generation.   

In CrowdNet <cit.>, the authors directly carve the first 13 layers from VGG-16 and add a 1×1 convolutional layer as output layer. The absence of modifications results in very weak performance. Other architectures, such as  <cit.>, uses VGG-16 as the density level classifier for labeling input images before sending them to the most suitable column of the MCNN, while the CP-CNN <cit.> incorporates the result of classification with the features from density map generator. In these cases, the VGG-16 performs as an ancillary without significantly boosting the final accuracy. 

In this paper, we first remove the classification part of VGG-16 (fully-connected layers) and build the proposed CSRNet with convolutional layers in VGG-16. The output size of this front-end network is 1/8 of the original input size. If we continue to stack more convolutional layers and pooling layers (basic components in VGG-16), output size would be further shrunken, and it is hard to generate high-quality density maps. Inspired by the works <cit.>, we try to deploy dilated convolutional layers as the back-end for extracting deeper information of saliency as well as maintaining the output resolution. 




  §.§.§ Dilated convolution


One of the critical components of our design is the dilated convolutional layer. A 2-D dilated convolution can be defined as follow:


    y(m,n)=∑_i=1^M∑_j=1^Nx(m+r× i,n+r× j)w(i,j)


y(m,n) is the output of dilated convolution from input x(m,n) and a filter w(i,j)  with the length and the width of M and N respectively. The parameter r is the dilation rate. If r=1, a dilated convolution turns into a normal convolution.


Dilated convolutional layers have been demonstrated in segmentation tasks with significant improvement of accuracy <cit.> and it is a good alternative of pooling layer.
Although pooling layers (e.g., max and average pooling) are widely used for maintaining invariance and controlling overfitting, they also dramatically reduce the spatial resolution meaning the spatial information of feature map is lost. Deconvolutional layers <cit.> can alleviate the loss of information, but the additional complexity and execution latency may not be suitable for all cases. Dilated convolution is a better choice, which uses sparse kernels (as shown in Fig. <ref>) to alternate the pooling and convolutional layer. 

This character enlarges the receptive field without increasing the number of parameters or the amount of computation (e.g., adding more convolutional layers can make larger receptive fields but introduce more operations). In dilated convolution, a small-size kernel with k×k filter is enlarged to k+(k-1)(r-1) with dilated stride r. Thus it allows flexible aggregation of the multi-scale contextual information while keeping the same resolution. Examples can be found in Fig. <ref> where normal convolution gets 3×3 receptive field and two dilated convolutions deliver 5×5 and 7×7 receptive fields respectively.

For maintaining the resolution of feature map, the dilated convolution shows distinct advantages compared to the scheme of using convolution + pooling + deconvolution. We pick one example for illustration in Fig. <ref>. The input is an image of crowds, and it is processed by two approaches separately for generating output with the same size. In the first approach, input is downsampled by a max pooling layer with factor 2, and then it is passed to a convolutional layer with a 3×3 Sobel kernel. Since the generated feature map is only 1/2 of the original input, it needs to be upsampled by the deconvolutional layer (bilinear interpolation). In the other approach, we try dilated convolution and adapt the same 3×3 Sobel kernel to a dilated kernel with a factor =2 stride. The output is shared the same dimension as the input (meaning pooling and deconvolutional layers are not required). Most importantly, the output from dilated convolution contains more detailed information (referring to the portions we zoom in).









  §.§.§ Network Configuration

We propose four network configurations of CSRNet in Table <ref> which have the same front-end structure but different dilation rate in the back-end. 
Regarding the front-end, we adapt a VGG-16 network <cit.> (except fully-connected layers) and only use 
3×3 kernels. According to  <cit.>, using more convolutional layers with small kernels is more efficient than using fewer layers with larger kernels when targeting the same size of receptive field .

By removing the fully-connected layers, we try to determine the number of layers we need to use from VGG-16. The most critical part relays on the tradeoff between accuracy and the resource overhead (including training time, memory consumption, and the number of parameters). Experiment shows a best tradeoff can be achieved when keeping the first ten layers of VGG-16 <cit.> with only three pooling layers instead of five to suppress the detrimental effects on output accuracy caused by the pooling operation.
Since the output (density maps) of CSRNet is smaller (1/8 of input size), we choose bilinear interpolation with the factor of 8 for scaling and make sure the output shares the same resolution as the input image. With the same size, CSRNet generated results are comparable with the ground truth results using the PSNR (Peak Signal-to-Noise Ratio) and SSIM (Structural Similarity in Image <cit.>). 



 §.§ Training method


In this section, we provide specific details of CSRNet training. By taking advantage of the regular CNN network (without branch structures), CSRNet is easy to implement and fast to deploy.



  §.§.§ Ground truth generation



Following the method of generating density maps in  <cit.>, we use the geometry-adaptive kernels to tackle the highly congested scenes. By blurring each head annotation using a Gaussian kernel (which is normalized to 1), we generate the ground truth considering the spatial distribution of all images from each dataset. The geometry-adaptive kernel is defined as:


    F(x)=∑_i=1^Nδ(x-x_i)× G_σ_i(x), with σ_i=βd_i


For each targeted object x_i in the ground truth δ, we use d_i to indicate the average distance of k nearest neighbors. To generate the density map, we convolve δ(x-x_i) with a Gaussian kernel with parameter σ_i (standard deviation), where x is the position of pixel in the image. In experiment, we follow the configuration in  <cit.> where β=0.3 and k=3. For input with sparse crowd, we adapt the Gaussian kernel to the average head size to blur all the annotations. The setups for different datasets are shown in Table  <ref>.








  §.§.§ Data augmentation

We crop 9 patches from each image at different locations with 1/4 size of the original image. The first four patches contain four quarters of the image without overlapping while the other five patches are randomly cropped from the input image. After that, we mirror the patches so that we double the training set.



  §.§.§ Training details


We use a straightforward way to train the CSRNet as an end-to-end structure. The first 10 convolutional layers are fine-tuned from a well-trained VGG-16 <cit.>. For the other layers, the initial values come from a Gaussian initialization with 0.01 standard deviation. Stochastic gradient descent (SGD) is applied with fixed learning rate at 1e-6 during training. Also, we choose the Euclidean distance to measure the difference between the ground truth and the  estimated density map we generated which is similar to other works <cit.>. The loss function is given as follow:


    L(Θ)=1/2N∑_i=1^N∥ Z(X_i;Θ)-Z_i^GT∥_2^2


 where N is the size of training batch and Z(X_i;Θ) is the output generated by CSRNet with parameters shown as Θ. X_i represents the input image while Z_i^GT is the ground truth result of the input image X_i.
 

 




§ EXPERIMENTS


We demonstrate our approach in five different public datasets <cit.>. Compared to the previous state-of-the-art methods <cit.>, our model is smaller, more accurate, and easier to train and deploy. In this section, the evaluation metrics are introduced, and then an ablation study of ShanghaiTech Part_A dataset is conducted to analyze the configuration of our model (shown in Table <ref>). Along with the ablation study, we evaluate and compare our proposed method to the previous state-of-the-art methods in all these five datasets. 
The implementation of our model is based on the Caffe framework <cit.>.



 §.§ Evaluation metrics



The MAE and the MSE are used for evaluation which are defined as:

    MAE=1/N∑_i=1^N| C_i-C_i^GT|


    MSE=√(1/N∑_i=1^N| C_i-C_i^GT|^2)


where N is the number of images in one test sequence and C_i^GT  is the ground truth of counting. C_i represents the estimated count which is defined as follows:

    C_i=∑_l=1^L∑_w=1^Wz_l,w


L and W show the length and width of the density map respectively while z_l,w is the pixel at (l,w) of the generated density map. C_i means the estimated counting number for image X_i.

We also use the PSNR and SSIM to evaluate the quality of the output density map on ShanghaiTech Part_A dataset. To calculate the PSNR and SSIM, we follow the preprocess given by <cit.>, which includes the density map resizing (same size with the original input) with interpolation and normalization for both ground truth and predicted density map. 





 §.§ Ablations on ShanghaiTech Part_A



In this subsection, we perform an ablation study to analyze the four configurations of the CSRNet on ShanghaiTech Part_A dataset <cit.> which is a new large-scale crowd counting dataset including 482 images for congested scenes with 241,667 annotated persons. It is challenging to count from these images because of the extremely congested scenes, the varied perspective, and the unfixed resolution. 
These four configurations are shown in Table <ref>. CSRNet A is the network with all the dilation rate of 1. CSRNet B and D maintain the dilation rate of 2 and 4 in their back-end respectively while CSRNet C combines the dilated rate of 2 and 4. The number of parameters of these four models are the same as 16.26M. We intend to compare the results by using different dilation rates.

After training on Shanghai Part_A dataset using the method mentioned in Sec. <ref>, we perform the evaluation metrics defined in Sec. <ref>. We try  dropout <cit.> for preventing the potential overfitting problem but there is no significant improvement. So we do not include dropout in our model. The detailed evaluation results are shown in Table <ref>, where CSRNet B achieves the lowest error (the highest accuracy). Therefore, we use CSRNet B as the proposed CSRNet for the following experiments.







 §.§ Evaluation and comparison




  §.§.§ ShanghaiTech dataset


ShanghaiTech crowd counting dataset contains 1198 annotated images with a total amount of 330,165 persons <cit.>. This dataset consists of two parts as Part_A containing 482 images with highly congested scenes randomly downloaded from the Internet while Part_B includes 716 images with relatively sparse crowd scenes taken from streets in Shanghai. Our method is evaluated and compared to other six recent works and results are shown in Table <ref>.
It indicates that our method achieves the lowest MAE (the highest accuracy) in Part_A compared to other methods and we get 7% lower MAE than the state-of-the-art solution called CP-CNN. CSRNet also delivers 47.3% lower MAE in Part_B compared to the CP-CNN. To evaluate the quality of generated density map, we compare our method to the MCNN and the CP-CNN using Part_A dataset and we follow the evaluation metrics in Sec. <ref>. Samples of the test cases can be found in Fig <ref>. Results are shown in Table <ref> which indicates CSRNet achieves the highest SSIM and PSNR. We also report the quality result of ShanghaiTech dataset in Table <ref>.










  §.§.§ UCF_CC_50 dataset

UCF_CC_50 dataset includes 50 images with different perspective and resolutions <cit.>. The number of annotated persons per image ranges from 94 to 4543 with an average number of 1280. 5-fold cross-validation is performed following the standard setting in <cit.>. Result comparisons of MAE and MSE are listed in Table <ref> while the quality of generated density map can be found in Table <ref>.






  §.§.§ The WorldExpo'10 dataset

The WorldExpo'10 dataset <cit.> consists of 3980 annotated frames from 1132 video sequences captured by 108 different surveillance cameras. This dataset is divided into a training set (3380 frames) and a testing set (600 frames) from five different scenes. The region of interest (ROI) is provided for the whole dataset. Each frame and its dot maps are masked with ROI during preprocessing, and we train our model following the instructions given in Sec. <ref>. Results are shown in Table <ref>. The proposed CSRNet delivers the best accuracy in 4 out of 5 scenes and it achieves the best accuracy on average. 





  §.§.§ The UCSD dataset

The UCSD dataset <cit.> has 2000 frames captured by surveillance cameras. These scenes contain sparse crowd varying from 11 to 46 persons per image. The region of interest (ROI) is also provided. Because the resolution of each frame is fixed and small (238× 158), it is difficult to generate a high-quality density map after frequent pooling operations. So we preprocess the frames by using bilinear interpolation to resize them into 952× 632. Among the 2000 frames, we use frames 601 through 1400 as training set and the rest of them as testing set according to  <cit.>. Before blurring the annotation as we mentioned in Sec. <ref>, all the frames and the corresponding dot maps are masked with ROI. The accuracy of running UCSD dataset is shown in Table <ref> and we outperform most of the previous methods except MCNN in the MAE category.
Results indicate that our method can perform not only counting tasks for extremely dense crowds but also tasks for relative sparse scenes. Also, we provides the quality of generated density map in Table <ref>.






  §.§.§ TRANCOS dataset

Beyond the crowd counting, we setup an experiment on the TRANCOS dataset <cit.> for vehicle counting to demonstrate the robustness and generalization of our approach. TRANCOS is a public traffic dataset containing 1244 images of different congested traffic scenes captured by surveillance cameras with 46796 annotated vehicles. Also, the region of interest (ROI) is provided for the evaluation. The perspectives of images are not fixed and the images are collected from very different scenarios. 
The Grid Average Mean Absolute Error (GAME) <cit.> is used for evaluation in this test. The GAME is defined as follow:


    GAME(L)=1/N∑_n=1^N(∑_l=1^^4^L | D_I_n^l -D_I_n^gt^l |)


where  
N
 is the number of images in testing set, and 
 D_I_n^l
 is the estimated result of the input image 
n
 within region 
l
. 
D_I_n^gt^l
 is the corresponding ground truth result. For a specific level 
L
, the GAME(
L
) subdivides the image using a grid of 
4^L
 non-overlapping regions which cover the full image, and the error is computed as the sum of the MAE in each of these regions. When 
L=0
, the GAME is equivalent to the MAE metric.

We compare our approach with the previous state-of-the-art methods <cit.>. The method in <cit.> uses the MCNN-like network to generate the density map while the model in <cit.> deploys a combination of fully convolutional neural networks (FCN) and a long short-term memory network (LSTM). Results are shown in Table <ref> with three examples shown in Fig. <ref>. Our model achieves a significant improvement on four different GAME metrics. Compared to the result from  <cit.>, CSRNet delivers 67.7% lower GAME(0), 60.1% lower GAME(1), 48.7% lower GAME(2), and 22.2% lower GAME(3), which is the best solution. We also present the quality of generated density map in Table <ref>. 































§ CONCLUSION


In this paper, we proposed a novel architecture called CSRNet for crowd counting and high-quality density map generation with an easy-trained end-to-end approach. We used the dilated convolutional layers to aggregate the multi-scale contextual information  in the congested scenes. By taking advantage of the dilated convolutional layers, CSRNet can expand the receptive field without losing resolution. We demonstrated our model in four crowd counting datasets with the state-of-the-art performance. 
We also extended our model to vehicle counting task and our model achieved the best accuracy as well.






§ ACKNOWLEDGEMENT


This work was supported by the IBM-Illinois Center for Cognitive Computing System Research (C3SR) - a research collaboration as part of the IBM AI Horizons Network.


unsrt








§ 
APPENDIX: SUPPLEMENTARY MATERIAL

In this appendix, additional results generated by CSRNet from five datasets (ShanghaiTech <cit.>, UCF_CC_50 <cit.>, WorldExpo'10 <cit.>, UCSD <cit.>, and TRANCOS <cit.>) are presented to demonstrate the validity of our design. Two criteria are used as the PSNR (Peak Signal-to-Noise Ratio) and the SSIM (Structural Similarity in Image <cit.> to evaluate our design's quality of generated density maps. Samples from these 5 datasets are shown in Fig. <ref> to Fig. <ref>, which represent a variety of density levels.


















