Switching Convolutional Neural Network for Crowd Counting

# Switching Convolutional Neural Network for Crowd Counting

Deepak Babu Sam   Shiv Surya11footnotemark: 1   R. Venkatesh Babu
Indian Institute of Science
Bangalore, INDIA 560012
Equal contribution
###### Abstract

We propose a novel crowd counting model that maps a given crowd scene to its density. Crowd analysis is compounded by myriad of factors like inter-occlusion between people due to extreme crowding, high similarity of appearance between people and background elements, and large variability of camera view-points. Current state-of-the art approaches tackle these factors by using multi-scale CNN architectures, recurrent networks and late fusion of features from multi-column CNN with different receptive fields. We propose switching convolutional neural network that leverages variation of crowd density within an image to improve the accuracy and localization of the predicted crowd count. Patches from a grid within a crowd scene are relayed to independent CNN regressors based on crowd count prediction quality of the CNN established during training. The independent CNN regressors are designed to have different receptive fields and a switch classifier is trained to relay the crowd scene patch to the best CNN regressor. We perform extensive experiments on all major crowd counting datasets and evidence better performance compared to current state-of-the-art methods. We provide interpretable representations of the multichotomy of space of crowd scene patches inferred from the switch. It is observed that the switch relays an image patch to a particular CNN column based on density of crowd.

## 1 Introduction

Crowd analysis has important geo-political and civic applications. Massive crowd gatherings are commonplace at candle-light vigils, democratic protests, religious gatherings and presidential rallies. Civic agencies and planners rely on crowd estimates to regulate access points and plan disaster contingency for such events. Critical to such analysis is crowd count and density.

In principle, the key idea behind crowd counting is self-evident: density times area. However, crowds are not regular across the scene. They cluster in certain regions and are spread out in others. Typical static crowd scenes from the ShanghaiTech Dataset [22] are shown in Figure 1. We see extreme crowding, high visual resemblance between people and background elements (e.g. Urban facade) in these crowd scenes that factors in further complexity. Different camera view-points in various scenes create perspective effects resulting in large variability of scales of people.

Crowd counting as a computer vision problem has seen drastic changes in the approaches, from early HOG based head detections [8] to CNN regressors [21, 22, 11] predicting the crowd density. CNN based regressors have largely outperformed traditional crowd counting approaches based on weak representations from local features. We build on the performance of CNN based architectures for crowd counting and propose Switching Convolutional Neural Network (Switch-CNN) to map a given crowd scene to its density.

Switch-CNN leverages the variation of crowd density within an image to improve the quality and localization of the predicted crowd count. Independent CNN crowd density regressors are trained on patches sampled from a grid in a given crowd scene. The independent CNN regressors are chosen such that they have different receptive fields and field of view. This ensures that the features learned by each CNN regressor are adapted to a particular scale. This renders Switch-CNN robust to large scale and perspective variations of people observed in a typical crowd scene. A particular CNN regressor is trained on a crowd scene patch if the performance of the regressor on the patch is the best. A switch classifier is trained alternately with the training of multiple CNN regressors to correctly relay a patch to a particular regressor. The joint training of the switch and regressors helps augment the ability of the switch to learn the complex multichotomy of space of crowd scenes learnt in the differential training stage.

To summarize, in this paper we present:

• A novel generic CNN architecture, Switch-CNN trained end-to-end to predict crowd density for a crowd scene.

• Switch-CNN maps crowd patches from a crowd scene to independent CNN regressors to minimize count error and improve density localization exploiting the density variation within a scene.

• We evidence state-of-the-art performance on all major crowd counting datasets including ShanghaiTech dataset [22], UCF_CC_50 dataset [8] and WorldExpo’10 dataset [21].

## 2 Related Work

Crowd counting has been tackled in computer vision by a myriad of techniques. Crowd counting via head detections has been tackled by [20, 19, 17] using motion cues and appearance features to train detectors. Recurrent network framework has been used for head detections in crowd scenes by [15]. They use the deep features from Googlenet [16] in an LSTM framework to regress bounding boxes for heads in a crowd scene. However, crowd counting using head detections has limitations as it fails in dense crowds, which are characterized by high inter-occlusion between people.

In crowd counting from videos, [3] use image features like Tomasi-Kanade features into a motion clustering framework. Video is processed by [12] into a set of trajectories using a KLT tracker. To prevent fragmentation of trajectories, they condition the signal temporally and spatially. Such tracking methods are unlikely to work for single image crowd counting due to lack of temporal information.

Early works in still image crowd counting like [8] employ a combination of handcrafted features, namely HOG based detections, interest points based counting and Fourier analysis. These weak representations based on local features are outperformed by modern deep representations. In [21], CNNs are trained to regress the crowd density map. They retrieve images from the training data similar to a test image using density and perspective information as the similarity metric. The retrieved images are used to fine-tune the trained network for a specific target test scene and the density map is predicted. However, the model’s applicability is limited by fine-tuning required for each test scene and perspective maps for train and test sequences which are not readily available. An Alexnet [9] style CNN model is trained by [18] to regress the crowd count. However, the application of such a model is limited for crowd analysis as it does not predict the distribution of the crowd. In [11], a multi-scale CNN architecture is used to tackle the large scale variations in crowd scenes. They use a custom CNN network, trained separately for each scale. Fully-connected layers are used to fuse the maps from each of the CNN trained at a particular scale, and regress the density map. However, the counting performance of this model is sensitive to the number of levels in the image pyramid as indicated by performance across datasets.

Multi-column CNN used by [2, 22] perform late fusion of features from different CNN columns to regress the density map for a crowd scene. In [22], shallow CNN columns with varied receptive fields are used to capture the large variation in scale and perspective in crowd scenes. Transfer learning is employed by [2] using a VGG network employing dilated layers complemented by a shallow network with different receptive field and field of view. Both the model fuse the feature maps from the CNN columns by weighted averaging via a 11 convolutional layer to predict the density map of the crowd. However, the weighted averaging technique is global in nature and does not take in to account the intra-scene density variation. We build on the performance of multi-column CNN and incorporate a patch based switching architecture in our proposed architecture, Switch-CNN to exploit local crowd density variation within a scene (see Sec 3.1 for more details of architecture).

While switching architectures have not been used for counting, expert classifiers have been used by [13] to improve single object image classification across depiction styles using a deep switching mechanism based on depiction style. However unlike [13], we do not have labels (For eg: Depiction styles like ”art” and ”photo”) to train the switch classifier. To overcome this challenge, we propose a training regime that exploits CNN regressor’s architectural differences (See Section 3.1)

## 3 Our Approach

Convolutional architectures like [21, 22, 11] have learnt effective image representations, which they leverage to perform crowd counting and density prediction in a regression framework. Traditional convolutional architectures have been modified to model the extreme variations in scale induced in dense crowds by using multi-column CNN architectures with feature fusion techniques to regress crowd density.

In this paper, we consider switching CNN architecture (Switch-CNN) that relays patches from a grid within a crowd scene to independent CNN regressors based on a switch classifier. The independent CNN regressors are chosen with different receptive fields and field-of-view as in multi-column CNN networks to augment the ability to model large scale variations. A particular CNN regressor is trained on a crowd scene patch if the performance of the regressor on the patch is the best. A switch classifier is trained alternately with the training of multiple CNN regressors to correctly relay a patch to a particular regressor. The salient properties that make this model excellent for crowd analysis are (1) the ability to model large scale variations (2) the facility to leverage local variations in density within a crowd scene. The ability to leverage local variations in density is important as the weighted averaging technique used in multi-column networks to fuse the features is global in nature.

### 3.1 Switch-CNN

Our proposed architecture, Switch-CNN consists of three CNN regressors with different architectures and a classifier (switch) to select the optimal regressor for an input crowd scene patch. Figure 2 shows the overall architecture of Switch-CNN. The input image is divided into 9 non-overlapping patches such that each patch is rd of the image. For such a division of the image, crowd characteristics like density, appearance etc. can be assumed to be consistent in a given patch for a crowd scene. Feeding patches as input to the network helps in regressing different regions of the image independently by a CNN regressor most suited to patch attributes like density, background, scale and perspective variations of crowd in the patch.

We use three CNN regressors introduced in [22], through , in Switch-CNN to predict the density of crowd. These CNN regressors have varying receptive fields that can capture people at different scales. The architecture of each of the shallow CNN regressor is similar: four convolutional layers with two pooling layers. has a large initial filter size of 99 which can capture high level abstractions within the scene like faces, urban facade etc. and with initial filter sizes 77 and 55 capture crowds at lower scales detecting blob like abstractions.

Patches are relayed to a regressor using a switch. The switch consists of a switch classifier and a switch layer. The switch classifier infers the label of the regressor to which the patch is to be relayed to. A switch layer takes the label inferred from the switch classifier and relays it to the correct regressor. For example, in Figure 2, the switch classifier relays the patch highlighted in red to regressor . The patch has a very high crowd density. Switch relays it to regressor which has smaller receptive field: ideal for detecting blob like abstractions characteristic of patches with high crowd density. We use an adaptation of VGG16 [14] network as the switch classifier to perform 3-way classification. The fully-connected layers in VGG16 are removed. We use global average pool (GAP) on Conv5 features to remove the spatial information and aggregate discriminative features. GAP is followed by a smaller fully connected layer and 3-class softmax classifier corresponding to the three regressor networks in Switch-CNN.

Training of Switch-CNN is done in three stages, namely pretraining, differential training and coupled training described in Sec 5.43.5.

### 3.2 Pretraining

The three CNN regressors through are pretrained separately to regress density maps. Pretraining helps in learning good initial features which improves later fine-tuning stages. Individual CNN regressors are trained to minimize the Euclidean distance between the estimated density map and ground truth. Let represent the output of a CNN regressor with parameters for an input image . The loss function is given by

 Ll2(Θ)=12NN∑i=1∥DXi(\raisebox0.0pt[11.199829pt][3.199951pt]$⋅$;Θ)−DGTXi(\raisebox0.0pt[11.199829pt][3.199951pt]$⋅$)∥22, (1)

where is the number of training samples and indicates ground truth density map for image . The loss is optimized by backpropagating the CNN via stochastic gradient descent (SGD). Here, loss function acts as a proxy for count error between the regressor estimated count and true count. It indirectly minimizes count error. The regressors are pretrained until the validation accuracy plateaus.

### 3.3 Differential Training

CNN regressors are pretrained with the entire training data. The count prediction performance varies due to the inherent difference in network structure of like receptive field and effective field-of-view. Though we optimize the -loss between the estimated and ground truth density maps for training CNN regressor, factoring in count error during training leads to better crowd counting performance. Hence, we measure CNN performance using count error. Let the count estimated by th regressor for th image be . Let the reference count inferred from ground truth be . Then count error for th sample evaluated by is

 ECi(k)=|Cki−CGTi|, (2)

the absolute count difference between prediction and true count. Patches with particular crowd attributes give lower count error with a regressor having complementary network structure. For example, a CNN regressor with large receptive field capture high level abstractions like background elements and faces. To amplify the network differences, differential training is proposed (shown in blue in Algorithm 1). The key idea in differential training is to backpropagate the regressor with minimum count error for a given training crowd scene patch. For every training patch , we choose the regressor such that is lowest across all regressors . This amounts to greedily choosing the regressor that predicts the most accurate count amongst regressors. Formally, we define the label of chosen regressor as:

 lbesti=argmink|Cki−CGTi| (3)

The count error for th sample is

 ECi=mink|Cki−CGTi|. (4)

This training regime encourages a regressor to prefer a particular set of the training data patches with particular patch attribute so as to minimize the loss. While the backpropagation of independent regressor is still done with -loss, the choice of CNN regressor for backpropagation is based on the count error. Differential training indirectly minimizes the mean absolute count error (MAE) over the training images. For images, MAE in this case is given by

 EC=1NN∑i=1mink|Cki−CGTi|, (5)

which can be thought as the minimum count error achievable if each sample is relayed correctly to the right CNN. However during testing, achieving this full accuracy may not be possible as the switch classifier is not ideal. To summarize, differential training generates three disjoint groups of training patches and each network is finetuned on its own group. The regressors are differentially trained until the validation accuracy plateaus.

### 3.4 Switch Training

Once the multichotomy of space of patches is inferred via differential training, a patch classifier (switch) is trained to relay a patch to the correct regressor . The manifold that separates the space of crowd scene patches is complex and hence a deep classifier is required to infer the group of patches in the multichotomy. We use VGG16 [14] network as the switch classifier to perform 3-way classification. The classifier is trained on the labels of multichotomy generated from differential training. The number of training patches in each group can be highly skewed, with the majority of patches being relayed to a single regressor depending on the attributes of crowd scene. To alleviate class imbalance during switch classifier training, the labels collected from the differential training are equalized so that the number of samples in each group is the same. This is done by randomly sampling from the smaller group to balance the training set of switch classifier.

### 3.5 Coupled Training

Differential training on the CNN regressors through generates a multichotomy that minimizes the predicted count by choosing the best regressor for a given crowd scene patch. However, the trained switch is not ideal and the manifold separating the space of patches is complex to learn. To mitigate the effect of switch inaccuracy and inherent complexity of task, we co-adapt the patch classifier and the CNN regressors by training the switch and regressors in an alternating fashion. We refer to this stage of training as Coupled training (shown in green in Algorithm 1).

The switch classifier is first trained with labels from the multichotomy inferred in differential training for one epoch (shown in red in Algorithm 1). In, the next stage, the three CNN regressors are made to co-adapt with switch classifier (shown in blue in Algorithm 1). We refer to this stage of training enforcing co-adaption of switch and regressor as Switched differential training.

In switched differential training, the individual CNN regressors are trained using crowd scene patches relayed by switch for one epoch. For a given training crowd scene patch , switch is forward propagated on to infer the choice of regressor . The switch layer then relays to the particular regressor and backpropagates using the loss defined in Equation 1 and is updated. This training regime is executed for an epoch.

In the next epoch, the labels for training the switch classifier are recomputed using criterion in Equation 3 and the switch is again trained as described above. This process of alternating switch training and switched training of CNN regressors is repeated every epoch until the validation accuracy plateaus.

## 4 Experiments

### 4.1 Testing

We evaluate the performance of our proposed architecture, Switch-CNN on four major crowd counting datasets At test time, the image patches are fed to the switch classifier which relays the patch to the best CNN regressor . The selected CNN regressor predicts a crowd density map for the relayed crowd scene patch. The generated density maps are assembled into an image to get the final density map for the entire scene. Because of the two pooling layers in the CNN regressors, the predicted density maps are th size of the input.

Evaluation Metric We use Mean Absolute Error (MAE) and Mean Squared Error (MSE) as the metric for comparing the performance of Switch-CNN against the state-of-the-art crowd counting methods. For a test sequence with images, MAE is defined as follows:

 MAE=1NN∑i=1|Ci−CGTi|, (6)

where is the crowd count predicted by the model being evaluated, and is the crowd count from human labelled annotations. MAE is an indicator of the accuracy of the predicted crowd count across the test sequence. MSE is a metric complementary to MAE and indicates the robustness of the predicted count. For a test sequence, MSE is defined as follows:

 MSE= ⎷1NN∑i=1(Ci−CGTi)2. (7)

### 4.2 ShanghaiTech dataset

We perform extensive experiments on the ShanghaiTech crowd counting dataset [22] that consists of 1198 annotated images. The dataset is divided into two parts named Part A and Part B. The former contains dense crowd scenes parsed from the internet and the latter is relatively sparse crowd scenes captured in urban surface streets. We use the train-test splits provided by the authors for both parts in our experiments. We train Switch-CNN as elucidated by Algorithm 1 on both parts of the dataset. Ground truth is generated using geometry-adaptive kernels method as the variance in crowd density within a scene due to perspective effects is high (See Sec 3.1 for details about ground truth generation). With an ideal switch (100% switching accuracy), Switch-CNN performs with an MAE of 51.4. However, the accuracy of the switch is 73.2% in Part A and 76.3% in Part B of the dataset resulting in a lower MAE.

Table 1 shows that Switch-CNN outperforms all other state-of-the art methods by a significant margin on both the MAE and MSE metric. Switch-CNN shows a 19.8 point improvement in MAE on Part A and 4.8 point improvement in Part B of the dataset over MCNN [22]. Switch-CNN also outperforms all other models on MSE metric indicating that the predictions have a lower variance than MCNN across the dataset. This is an indicator of the robustness of Switch-CNN’s predicted crowd count.

We show sample predictions of Switch-CNN for sample test scenes from the ShanghaiTech dataset along with the ground truth in Figure 3. The predicted density maps closely follow the crowd distribution visually. This indicates that Switch-CNN is able to localize the spatial distribution of crowd within a scene accurately.

### 4.3 UCF_CC_50 dataset

UCF_CC_50 [8] is a 50 image collection of annotated crowd scenes. The dataset exhibits a large variance in the crowd count with counts varying between 94 and 4543. The small size of the dataset and large variance in crowd count makes it a very challenging dataset. We follow the approach of other state-of-the-art models [21, 2, 11, 22] and use 5-fold cross-validation to validate the performance of Switch-CNN on UCF_CC_50.

In Table 2, we compare the performance of Switch-CNN with other methods using MAE and MSE as metrics. Switch-CNN outperforms all other methods and evidences a 15.7 point improvement in MAE over Hydra2s [11]. Switch-CNN also gets a competitive MSE score compared to Hydra2s indicating the robustness of the predicted count. The accuracy of the switch is 54.3%. The switch accuracy is relatively low as the dataset has very few training examples and a large variation in crowd density. This limits the ability of the switch to learn the multichotomy of space of crowd scene patches.

### 4.4 The UCSD dataset

The UCSD dataset crowd counting dataset consists of 2000 frames from a single scene. The scenes are characterized by sparse crowd with the number of people ranging from 11 to 46 per frame. A region of interest (ROI) is provided for the scene in the dataset. We use the train-test splits used by [4]. Of the 2000 frames, frames 601 through 1400 are used for training while the remaining frames are held out for testing. Following the setting used in [22], we prune the feature maps of the last layer with the ROI provided. Hence, error is backpropagated during training for areas inside the ROI. We use a fixed spread Gaussian to generate ground truth density maps for training Switch-CNN as the crowd is relatively sparse. At test time, MAE is computed only for the specified ROI in test images for benchmarking Switch-CNN against other approaches.

Table 3 reports the MAE and MSE results for Switch-CNN and other state-of-the-art approaches. Switch-CNN performs competitively compared to other approaches with an MAE of 1.62. The switch accuracy in relaying the patches to regressors through is 60.9%. However, the dataset is characterized by low variability of crowd density set in a single scene. This limits the performance gain achieved by Switch-CNN from leveraging intra-scene crowd density variation.

### 4.5 The WorldExpo’10 dataset

The WorldExpo’10 dateset consists of 1132 video sequences captured with 108 surveillance cameras. Five different video sequence, each from a different scene, are held out for testing. Every test scene sequence has 120 frames. The crowds are relatively sparse in comparison to other datasets with average number of 50 people per image. Region of interest (ROI) is provided for both training and test scenes. In addition, perspective maps are provided for all scenes. The maps specify the number of pixels in the image that cover one square meter at every location in the frame. These maps are used by [22, 21] to adaptively choose the spread of the Gaussian while generating ground truth density maps. We evaluate performance of the Switch-CNN using ground truth generated with and without perspective maps.

We prune the feature maps of the last layer with the ROI provided. Hence, error is backpropagated during training for areas inside the ROI. Similarly at test time, MAE is computed only for the specified ROI in test images for benchmarking Switch-CNN against other approaches.

MAE is computed separately for each test scene and averaged to determine the overall performance of Switch-CNN across test scenes. Table 4 shows that the average MAE of Switch-CNN across scenes is better by a margin of 2.2 point over the performance obtained by the state-of-the-art approach MCNN [22]. The switch accuracy is 52.72%.

## 5 Analysis

### 5.1 Effect of number of regressors on Switch-CNN

Differential training makes use of the structural variations across the individual regressors to learn a multichotomy of the training data. To investigate the effect of structural variations of the regressors through , we train Switch-CNN with combinations of regressors (,), (,), (,) and (,,) on Part A of ShanghaiTech dataset. Table 5 shows the MAE performance of Switch-CNN for different combinations of regressors . Switch-CNN with CNN regressors and has lower MAE than Switch-CNN with regressors and . This can be attributed to the former model having a higher switching accuracy than the latter. Switch-CNN with all three regressors outperforms both the models as it is able to model the scale and perspective variations better with three independent CNN regressors , and that are structurally distinct. Switch-CNN leverages multiple independent CNN regressors with different receptive fields. In Table 5, we also compare the performance of individual CNN regressors with Switch-CNN. Here each of the individual regressors are trained on the full training data from Part A of Shanghaitech dataset. The higher MAE of the individual CNN regressor is attributed to the inability of a single regressor to model the scale and perspective variations in the crowd scene.

### 5.2 Switch Multichotomy Characteristics

The principal idea of Switch-CNN is to divide the training patches into disjoint groups to train individual CNN regressors so that overall count accuracy is maximized. This multichotomy in space of crowd scene patches is created automatically through differential training. We examine the underlying structure of the patches to understand the correlation between the learnt multichotomy and attributes of the patch like crowd count and density. However, the unavailability of perspective maps renders computation of actual density intractable. We believe inter-head distance between people is a candidate measure of crowd density. In a highly dense crowd, the separation between people is low and hence density is high. On the other hand, for low density scenes, people are far away and mean inter-head distance is large. Thus mean inter-head distance is a proxy for crowd density. This measure of density is robust to scale variations as the inter-head distance naturally subsumes the scale variations.

To analyze the multichotomy in space of patches, we compute the average inter-head distance of each patch in Part A of ShanghaiTech test set. For each head annotation, the average distance to its 10 nearest neighbors is calculated. These distances are averaged over the entire patch representing the density of the patch. We plot a histogram of these distances in Figure 4 and group the patches by color on the basis of the regressor used to infer the count of the patch. A separation of patch space based on crowd density is observed in Figure 4. , which has the largest receptive field of 99, evaluates patches of low crowd density (corresponding to large mean inter-head distance). An interesting observation is that patches from the crowd scene that have no people in them (patches in Figure 4 with zero average inter-head distance) are relayed to by the switch. We believe that the patches with no people are relayed to as it has a large receptive field that helps capture background attributes in such patches like urban facade and foliage. Figure 5 displays some sample patches that are relayed to each of the CNN regressors through . The density of crowd in the patches increases from CNN regressor through .

### 5.3 Attribute Clustering Vs Differential Training

We saw in Sec 5.2 that differential training approximately divides training set patches into a multichotomy based on density. We investigate the effect of manually clustering the patches based on patch attribute like crowd count or density. We use patch count as metric to cluster patches. Training patches are divided into three groups based on the patch count such that the total number of training patches are equally distributed amongst the three CNN regressors . , having a large receptive field, is trained on patches with low crowd count. is trained on medium count patches while high count patches are relayed to . The training procedure for this experiment is identical to Switch-CNN, except for the differential training stage. We repeat this experiment with average inter-head distance of the patches as a metric for grouping the patches. Patches with high mean inter-head distance are relayed to . is relayed patches with low inter-head distance by the switch while the remaining patches are relayed to .

Table 6 reports MAE performance for the two clustering methods. Both crowd count and average inter-head distance based clustering give a higher MAE than Switch-CNN. Average inter-head distance based clustering performs comparably with Switch-CNN. This evidence reinforces the fact that Switch-CNN learns a multichotomy in the space of patches that is highly correlated with mean inter-head distance of the crowd scene. The differential training regime employed by Switch-CNN is able to infer this grouping automatically, independent of the dataset.

### 5.4 Effect of Coupled Training

Differential training on the CNN regressors through generates a multichotomy that minimizes the predicted count by choosing the best regressor for a given crowd scene patch. However, the trained switch is not ideal and the manifold separating the space of patches is complex to learn (see Section 5.2 of the main paper). To mitigate the effect of switch inaccuracy and inherent complexity of task, we perform coupled training of switch and CNN regressors. We ablate the effect of coupled training by training the switch classifier in a stand-alone fashion. For training the switch in a stand-alone fashion, the labels from differential training are held fixed throughout the switch classifier training.

The results of the ablation are reported in Table 7. We see that training the switch classifier in a stand-alone fashion results in a deterioration of Switch-CNN crowd counting performance. While Switch-CNN with the switch trained in a stand-alone manner performs better than MCNN, it performs significantly worse than Switch-CNN with coupled training. This is reflected in the 13 point higher count MAE. Coupled training allows the patch labels to change in order to adapt to the ability of the switch classifier to relay a patch to the optimal regressor correctly. This co-adaption is absent when training switch alone leading to deterioration of crowd counting performance.

### 5.5 Ablations on UCF_CC_50 dataset

We perform ablations referenced in Section 5.1 and 5.3 of the main paper on the UCF_CC_50 dataset [8]. The results of these ablations are tabulated in Table 8. The results follow the trend on ShanghaiTech dataset and reinforce the superiority of Switch-CNN (See Section 5.1 and 5.3 of the main paper for more details).

### 5.6 Choice of Switch Classifier

The switch classifier is used to infer the multichotomy of crowd patches learnt from differential training. The accuracy of the predicted count in Switch-CNN is critically dependent on the choice of the switch classifier. We repurpose different classifier architectures, from shallow CNN classifiers to state-of-the art object classifiers to choose the best classifier that strikes a balance between classification accuracy and computational complexity.

Figure 6 shows the different architectures of switch classifier that we evaluate. CNN-small is a shallow classifier derived from VGG-16 [14]. We retain the first three convolutional layers from VGG-16 and add a 512 dimensional fully-connected layer along with a 3-way classifier. The convolutional layers in CNN-small are initialized from VGG-16. We also repurpose VGG-16 and VGG-19 [14] by global average pooling the Conv 5 features and using a 512 dimensional fully-connected layer along with a 3-way classifier. All the convolutional layers in VGG-16 and VGG-19 are initialized from VGG models trained on Imagenet [6]. The state-of-the-art object recognition classifiers, Resnet-50 and Resnet-101 [7] are also evaluated. We replace the final 1000-way classifier layer with a 3-way classifier. For ResNet training, we do not update the Batch Normalization (BN) layers. The BN statistics from ResNet model trained for ILSCVRC challenge [6] are retained during fine-tuning for crowd-counting. The BN layers behave as a linear activation function with constant scaling and offset. We do not update the BN layers as we use a batch size of during SGD and the BN parameter update becomes noisy.

We train each of the classifier on image patch-label pairs, with labels generated from the differential training stage (see Section 3.3 of the main paper). The classifiers are trained using SGD in a stand-alone manner similar to Section 5.4. Table 9 shows the performance of the different switch classifiers on Part A of the ShanghaiTech dataset [22]. CNN-small shows a 10% drop in classification accuracy over the other classifiers as it is unable to model the complex multichotomy inferred from differential training. We observe that the performance plateaus for the other classifiers despite using more powerful classifiers like ResNet. This can be attributed to complexity of manifold inferred from differential training. Hence, we choose the repurposed VGG-16 model for all our Switch-CNN experiments as it gives classification accuracy competitive with deeper models like ResNet, but with a lower computational cost. A lower computational cost is critical as it allows faster training during coupled training of the switch-classifier and CNN regressors .

## 6 Conclusion

In this paper, we propose switching convolutional neural network that leverages intra-image crowd density variation to improve the accuracy and localization of the predicted crowd count. We utilize the inherent structural and functional differences in multiple CNN regressors capable of tackling large scale and perspective variations by enforcing a differential training regime. Extensive experiments on multiple datasets show that our model exhibits state-of-the-art performance on major datasets. Further, we show that our model learns to group crowd patches based on latent factors correlated with crowd density.

## 7 Acknowledgements

This work was supported by SERB, Department of Science and Technology (DST), Government of India (Proj No. SB/S3/EECE/0127/2015).

## References

• [1] S. An, W. Liu, and S. Venkatesh. Face recognition using kernel ridge regression. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 1–7, 2007.
• [2] L. Boominathan, S. S. Kruthiventi, and R. V. Babu. Crowdnet: A deep convolutional network for dense crowd counting. In Proceedings of the 2016 ACM on Multimedia Conference, pages 640–644, 2016.
• [3] G. J. Brostow and R. Cipolla. Unsupervised bayesian detection of independent motion in crowds. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, volume 1, pages 594–601, 2006.
• [4] A. B. Chan, Z.-S. J. Liang, and N. Vasconcelos. Privacy preserving crowd monitoring: Counting people without people models or tracking. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 1–7, 2008.
• [5] K. Chen, C. C. Loy, S. Gong, and T. Xiang. Feature mining for localised crowd counting. In BMVC, 2012.
• [6] J. Deng, W. Dong, R. Socher, L.-J. Li, K. Li, and L. Fei-Fei. Imagenet: A large-scale hierarchical image database. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 248–255, 2009.
• [7] K. He, X. Zhang, S. Ren, and J. Sun. Deep residual learning for image recognition. arXiv preprint arXiv:1512.03385, 2015.
• [8] H. Idrees, I. Saleemi, C. Seibert, and M. Shah. Multi-source multi-scale counting in extremely dense crowd images. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 2547–2554, 2013.
• [9] A. Krizhevsky, I. Sutskever, and G. E. Hinton. Imagenet classification with deep convolutional neural networks. In Advances in Neural Information Processing Systems, pages 1097–1105, 2012.
• [10] V. Lempitsky and A. Zisserman. Learning to count objects in images. In Advances in Neural Information Processing Systems, pages 1324–1332, 2010.
• [11] D. Onoro-Rubio and R. J. López-Sastre. Towards perspective-free object counting with deep learning. In European Conference on Computer Vision, pages 615–629. Springer, 2016.
• [12] V. Rabaud and S. Belongie. Counting crowded moving objects. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, volume 1, pages 705–711, 2006.
• [13] R. K. Sarvadevabhatla, S. Surya, S. S. Kruthiventi, et al. Swiden: Convolutional neural networks for depiction invariant object recognition. In Proceedings of the 2016 ACM on Multimedia Conference, pages 187–191. ACM, 2016.
• [14] K. Simonyan and A. Zisserman. Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556, 2014.
• [15] R. Stewart and M. Andriluka. End-to-end people detection in crowded scenes. arXiv preprint arXiv:1506.04878, 2015.
• [16] C. Szegedy, W. Liu, Y. Jia, P. Sermanet, S. Reed, D. Anguelov, D. Erhan, V. Vanhoucke, and A. Rabinovich. Going deeper with convolutions. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 1–9, 2015.
• [17] P. Viola, M. J. Jones, and D. Snow. Detecting pedestrians using patterns of motion and appearance. International Journal of Computer Vision, 63(2):153–161, 2005.
• [18] C. Wang, H. Zhang, L. Yang, S. Liu, and X. Cao. Deep people counting in extremely dense crowds. In Proceedings of the 2015 ACM on Multimedia Conference, pages 1299–1302, 2015.
• [19] M. Wang and X. Wang. Automatic adaptation of a generic pedestrian detector to a specific traffic scene. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 3401–3408, 2011.
• [20] B. Wu and R. Nevatia. Detection of multiple, partially occluded humans in a single image by bayesian combination of edgelet part detectors. In IEEE International Conference on Computer Vision, volume 1, pages 90–97, 2005.
• [21] C. Zhang, H. Li, X. Wang, and X. Yang. Cross-scene crowd counting via deep convolutional neural networks. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 833–841, 2015.
• [22] Y. Zhang, D. Zhou, S. Chen, S. Gao, and Y. Ma. Single-image crowd counting via multi-column convolutional neural network. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 589–597, 2016.
You are adding the first comment!
How to quickly get a good reply:
• Give credit where it’s due by listing out the positive aspects of a paper before getting into which changes should be made.
• Be specific in your critique, and provide supporting evidence with appropriate references to substantiate general statements.
• Your comment should inspire ideas to flow and help the author improves the paper.

The better we are at sharing our knowledge with each other, the faster we move forward.
The feedback must be of minimum 40 characters and the title a minimum of 5 characters