Channel Compression Optimization Oriented Bus Passenger Object Detection

Bus passenger flow information can facilitate scientific dispatching plans, which is essential to decision making and operation performance evaluation. Real-time acquisition of bus passenger flow information is an indispensable part for bus intellectualization. -e method of passenger flow statistics in bus video monitoring scene based on deep convolution neural network can provide rich information for passenger flow statistics. In order to adapt to the real scenario of mobile and embedded devices on buses, and to consider the bandwidth limitation, this paper uses a lightweight network model M7, which is suitable for the vehicle system. Based on the classic networkmodel tiny YOLO, the model is optimized by a depthwise separable convolutionmethod.-e optimized network model M7 reduces the number of parameters and improves the detection speed, while maintaining a low loss in detection accuracy. As such, the network model M7 is compressed and further optimized by removing redundant channels.-e experimental results show that the detection speed of the network model target recognition after channel compression is 40%, which is faster than the precious channel compression on the premise of ensuring detection.


Introduction
With the development of economy and society, urban traffic is increasingly subject to overcrowdedness. Public transport passenger flow has become the most important information about vehicle scheduling in the transport sector. Real-time collection of bus passengers flow data has become the key issue of the intelligent public transportation system. By carrying out statistical analysis on the passenger flow of each bus and each station, accurate reference data can be provided to schedule vehicles, to optimize the allocation of bus resources, to improve the overall running speed of the bus system, and to improve the travel experience of passengers.
Early counting methods are mostly manual, which is not only time-consuming and inefficient but also manpowerwasting and material-consuming, aggravating the operating cost of the transportation system. In recent years, with the continuous upgrading of processor performance, real-time statistical analysis of bus passenger flow based on images has been realized. e technology of feature extraction and matching recognition based on the two-dimensional image has been widely used in passenger flow statistics at home and abroad. e development of the deep convolutional neural network in feature extraction has brought amazing convenience to traffic control under video monitoring. It can train the crowd counting algorithm model under video monitoring scene of bus end-to-end, eliminating the steps of foreground segmentation, artificial design, and feature extraction. e high-level features obtained by multilayer convolution of the convolutional neural network can improve the crowd counting algorithm with higher credibility of population statistics.
Traditional convolutional neural network technology is difficult to deploy for mobile terminals due to its high computational complexity and large model size. In order to solve the above problems, researchers proposed the convolutional neural network should adapt to mobile terminals, with limited computing power and storage space through efficient convolution.
Aiming at the passenger flow statistics of bus mobile embedded system, this paper proposes a novel CNN based on compression optimization of the M 7 network model, which is based on the lightweight network model tiny YOLO optimized by a depthwise separable convolution method. e network model is studied and optimized from the perspective of channel compression.
Firstly, the amount of computation and parameters are used to determine the convolutional layer to be compressed. And then, the effect of removing channels on detection results is used to evaluate the contribution of channels to detection results. e priority removed channels are determined according to the contribution. Finally, the compression algorithm is used to compress the convolutional layer.

Related Works
Early methods of bus passenger flow statistics include technologies such as pressure sensor, infrared sensor, and thermal imager. However, these passenger flow statistics methods have many shortcomings, which cannot effectively adapt to complex and crowded bus occasions. For example, the pressure sensor counts the number of passengers by the size and change of the pedal pressure, which has the problems of easily damaged equipment and high daily maintenance cost. e infrared product cannot solve the ambient occlusion problem and distinguish passengers' movement direction under crowded conditions. at is, it cannot count the passenger flow on and off at the same time.
e thermal imager is easily affected by ambient temperature and its price is too high to be widely used in the domestic public transport system. Due to its simplistic description of passenger characteristics, the bus passenger flow statistics system of the above technologies cannot achieve satisfactory results in terms of the crowded and chaotic situation in dealing with the crowded and chaotic situation during the peak period of bus passenger flow, with only an accuracy rate of 60-70%.
In the statistical method of bus passenger flow, some achievements have been made by using the traditional image processing method combined with the feature extracted by manual methods. However, due to the influence of the target's shape, background complexity, illumination, and shadow, it is difficult to design a robust feature artificially while adapting to the complex target detection environment. With the continuous development of computer vision technology, the use of video image processing method for target detection, recognition, and tracking is increasingly mature, with great research achievements made so far. In recent years, with the rapid development of deep learning, compared with traditional image processing and machine learning algorithms, deep learning shows great advantages in big datasets and gradually becomes a research hotspot in the field of intelligent transportation.
Deep learning with the help of convolutional neural network grasps the characteristics of objects autonomously from a large number of data samples, which makes continuous breakthroughs in the field of target detection and brings new solutions to target detection. In the condition of actual bus passenger target detection, the space is narrow and the problem of mutual occlusion between passengers during the peak time is very serious. erefore, it is impossible to take the passenger as the whole detection object. Compared with the passenger body, the head area of the person is in the highest position, and the head area occupies the most important position when looking down from the top view. It can transform the problem of detecting the passenger target into the problem of detecting the head target. It is as shown in Figure 1.
A large number of passenger head target samples are extracted from bus video, and a model of passenger head target is obtained by using deep network training, and then the target detection algorithm is used to detect and identify the bus passenger head target.
e convolutional neural network model is superior in many area experiments, but it is still subject to time and space constraints in practical applications. Deep and large convolutional neural networks models are computationally intensive but still not able to meet the needs of many application occasions in time. In addition, large-scale model parameters also take up a large amount of memory space, which is not applicable for mobile embedded terminals. erefore, the compression network model is an important research issue on the premise of not affecting the accuracy of the convolutional neural network model.
In recent years, compression methods of convolutional neural network based on structured pruning have been proposed successively, overcoming the unaccelerated problem caused by unstructured sparse connections [1][2][3]. Its core idea relies on the filter significance criterion (i.e., identify the least important filtering criteria), thereby directly removes the significant filter, and accelerates the network calculation. In 2016, Ref. [4] proposed to add an architectural sparse loss function to the loss function of the traditional depth model and assign 0 to the filter less than a given threshold, to directly remove the entire convolution filter with a value of 0 in the test stage.
As a large number of ReLU nonlinear activation functions exist in the mainstream deep network, the output feature map is highly sparse. Reference [5] takes full advantage of this feature to calculate the nonzero ratio of the output feature map corresponding to each filter, as a criterion to judge whether the filter is important. Reference [6] added the constraints of structured sparseness to the objective function and used forward-backward splitting method to solve the optimization problem of sparse structural restriction and directly decided the number of network nodes and redundant nodes in the training process. Reference [7] added regularization restrictions on filtering channels, filter shapes, and layer depth of deep neural networks into the loss function and learned structured convolution filtering by using structured sparse learning. Besides, the norm value of direct measurement filtering is used to judge the significance of filtering [8]. For example, the least L1 norm of the current layer is removed directly, that is, the feature map of the response is removed, and then the channel number of the convolutional filter of the next layer is reduced responsively. Finally, the recognition accuracy of the removed model is improved through retraining. Taking advantage of this property, Ref. [9] explores the importance of the input channel of the next layer convolution kernels, instead of considering the current layer filter directly, and establishes an effective channel selection optimization function to remove redundant channels and the corresponding current layer filter. Reference [10] dynamically prunes computation on subset of input channels to reduce the computation cost for CNN. Channel gating identifies regions in the features that contribute less to the classification result and skips the computation on a subset of the input channels for these ineffective regions. Unlike static network pruning, channel gating optimizes CNN inference at runtime by exploiting input-specific characteristics, which allows substantially reducing the computation cost with almost no accuracy loss. Existing pruning methods either train from scratch with sparsity constraints on channels, or minimize the reconstruction error between the pretrained feature maps and the compressed ones. Both strategies suffer from some limitations: the former kind is computationally expensive and difficult to converge, whilst the latter kind optimizes the reconstruction error but ignores the discriminative power of channels. Reference [11] investigates a simple-yet-effective method called discrimination-aware channel pruning (DCP) to choose those channels that really contribute to discriminative power. Reference [12] proposes a new filter pruning strategy based on the geometric median, named FPGM, to accelerate the deep CNNs. is article deems the filter is also a point in Euclidean space and could be calculated according to geometric median to get the "center" of the filter, which is their common properties. If a filter is close to this geometric median, the information of the filter can be considered to overlap with (or even redundant with) other filters, so that the filter can be removed without much impact on the network. After removing it, its function can be replaced by other filters. us, a filter evaluation method FPGM independent of norm is obtained, which breaks the limitation of norm evaluation index. e compression method of deep network based on structured pruning can directly compress the network and accelerate the calculation of the whole network by removing the whole filtering of convolutional layer without introducing additional data type storage.

Convolutional Neural Network Model Optimization
In this chapter, the tiny YOLO network convolution structure model is employed as the basis for optimization. Tiny YOLO is a smaller version of YOLO [13], which is more suitable for mobile machine learning and IoT devices. Although the convolutional network model structure based on tiny YOLO can achieve good detection results in target detection of bus passengers, it is still too complex to be used in practical applications for embedded devices with limited resource performance. A depthwise separable convolution method is used to optimize the network structure at first in this chapter. On the premise of guaranteeing the detection accuracy, parameters of the network model are reduced and the detection speed increased. And then, based on this optimized network model, channels are compressed, and the network model is optimized again by removing redundant channels to further improve the detection speed.

e Basis of Convolutional Network Model Optimization:
Tiny YOLO. Tiny YOLO is a lightweight network model based on the Darknet reference network. e whole network consists of nine convolutional layers, six maximum pooling layers, and one detection layer. e network convolution structure is shown in Table 1 [14]. e performance of tiny YOLO convolution neural network in target detection is tested by using a bus passenger test set containing 12,749 pictures. e selected test samples contain various objective natural factors, such as the brightness of light [15] and the influence of different head shapes of bus passengers on target detection. e detected image is shown as Figure 2.
In this test set, the detection accuracy of tiny YOLO is 0.945 during rush hour. e GNU profiler tool is used to get the function call relationship of the program at the time of  detection. e function call relationship diagram is shown as Figure 3.
It can be seen from Figure 3 that the gemm_nn function responsible for matrix multiplication takes up 86% of the entire program runtime. is function is called nine times, corresponding to each convolution operation of 9 convolutional layers in the network structure. It can be seen that the excessive number of parameters leads to excessive calculation, which is the main reason for time consumption for the detection model of tiny YOLO.

Depthwise Separable Convolution.
Depthwise separable convolution [16] is a lightweight convolution computing technology, which separates conventional convolution in the spatial dimension. is technique not only reduces the computational complexity of convolution operation but also reduces the number of parameters. erefore, it is a highly efficient convolution method. In this section, the lightweight network model tiny YOLO is taken as the research object to optimize with depth separable convolution method.

Mathematical Problems in Engineering
Usually, a conventional convolution operation is a threedimensional convolution kernel that convolves with an input feature map. Each convolution kernel simultaneously operates each channel of the input feature map, and the channel number of the input feature map is consistent with that of the convolution kernel. If the input tensor of the convolution layer l is x l ∈ R H l ×W l ×D l , the convolution kernel number of the layer is f l ∈ R H×W×D t . e three-dimensional input convolution operation simply extends the two-dimensional convolution to all the channels of the corresponding position, (i.e., D l ) and finally sums all the HWD l elements processed by once convolution operation as the result of convolution operation in this position. e specific process is shown in Figure 4.
Depthwise separable convolution is a factorized convolutions operation, which can be decomposed into two smaller operations: depthwise convolution and pointwise convolution. e specific process is shown in Figure 5. e depthwise separable convolution method divides the original convolutional layer into two convolutional layers. In the depthwise convolution operation, each convolution kernel is convolved with each channel of the input only. e pointwise convolution operation is responsible for feature fusion that combines the results of the previous convolution. e original three-dimensional convolution kernel is a convolution operation between multiple input channels and convolution kernels to get an output channel. After the improvement, only one channel is required to obtain an output channel, and then a 1 × 1 convolution is used for channel feature fusion. e advantage of this method is the reduction of parameters and their calculation. e number of parameters of depthwise separable convolution is about 1/ 3 of the conventional convolution, which can reduce the calculation by about 8 to 9 times.     Mathematical Problems in Engineering e M 7 network model studied in this paper replaces the original tiny YOLO network structure with a depthwise convolution and pointwise convolution network structure, except for the first and last layer convolution. e network model structure is shown in Table 2.

Channel Compression Principle.
In the convolutional neural network, channels (also known as feature graphs) are the output results obtained by the convolution operation of the input layer. Figure 6 is a schematic diagram for channel compression in a single convolutional layer. In the figure, A, B, and C contain multiple channels, and W 1 and W 2 contain multiple standard convolution kernels. After convolution operation of A and W 1 , the output result B is obtained. According to the characteristics of the convolutional neural network, it can be known that the number of channels in B is consistent with the number of convolutional kernels in W 1 and is also related to the size of all convolutional kernels in W 2 . If channels in B are removed (the gap blank part in B), part of the convolution kernel in the previous convolutional layer (the convolution kernel at the dotted line in W 1 ) shall be removed at the same time, and the size of all the convolution kernel in the latter convolutional layer (the gap blank part of the convolution kernel in W 2 ) shall be reduced accordingly.
Briefly, in the standard convolutional neural network model, compression channels will affect the number of convolution kernels in the former convolutional layer and the size of the convolution kernels in the latter convolutional layer.
In the lightweight network model M 7 , which is based on the tiny YOLO model, the channel compression process is slightly different. Figure 7 is a schematic diagram for channel compression in a single convolutional layer. In the figure, A, B, C, and D contain multiple channels. W 1 is the standard convolution core, W 2 is the depthwise convolution kernel, and W 3 is the pointwise convolution kernel. e number of channels in B is consistent with the number of convolution kernels in W 1 and is also related to the size of convolution kernels in W 2 and W 3 . erefore, when the channels in B are compressed (the blank part of the gap in B), part of the convolution kernels in W 1 are removed due to the influence of channel compression (the convolution kernels of the dotted line in W 1 ), and the size of the convolution kernels in   Figure 6: Channels removed diagram. W 2 and W 3 is reduced due to the influence of channel compression (the blank part of the convolution kernel in W 2 and W 3 ). Briefly, in M 7 network model, compression channel will affect the number of convolution kernels in the former convolutional layer and the size of depthwise convolution kernels and pointwise convolution kernels in the latter convolutional layer.

Channel Compression Process.
e process of channel compression in a convolutional neural network is divided into the following five steps to calculate each convolutional layer compressible space, to assess importance of each channel in the convolutional layer, to remove some unimportant channels, to train the compressed channel, and to judge whether to continue the compression. e channel compression flow chart is shown in Figure 8.
(1) Calculating Each Convolutional Layer Compressible Space. Each convolutional layer is selected with more parameters and floating-point calculations. In the network model M 7 , the amount of floating-point computation is related to the number of convolution kernels and the width and height of input channels. Because in the basic operations, the operation time of addition and the number of addition operations are much less than those of multiplication. Only approximate floating-point multiplication computations that need to be performed at this level are considered when computing floating-point computations.
Equation (1) shown as follows is the floating-point computations equation. (1) In the equation, N multi is the floating-point multiplication computation, W out is the width of the output channel, H out is the height of the output channel, N filters is the number of the convolution kernel, s is the width (height) of the convolution kernel, and C in is number of input channels.
Equation (2) shown as follows is the convolution kernel parameter computations equation.
In the equation, N is the amount of convolution kernel parameters, N filters is the floating-point multiplication computation, s is the width (height) of the convolution kernel, and C in is the number of input channels (in the case of 3 × 3 depth convolution, C in � 1).
For example, calculate floating-point computations and convolution kernel parameters of 20th layer in M 7 network model. e floating-point computing can be calculated by equation (1): N multi �13×13×1024×1×1×1024�177209344. According to equation (2), the number of convolution kernel parameters is N�1024×1×1×1024�1048576. e number of convolution kernel parameters and floating-point multiplication computation of each layer in network model M 7 are shown in Figure 9.
From Figure 9, it can be seen that, in the M 7 , floating-point computation and the number of convolution parameters in convolutional layers 2nd, 5th, 8th, 11th, 14th, 17th, 19th, and 21st account for a very low proportion in their respective total. All of these convolutional layers belong to depthwise convolution. Relatively, floating-point computations and the number of convolution parameters in the remaining convolutional Mathematical Problems in Engineering layers 0th, 3rd, 6th, 9th, 12th, 15th, 18th, and 20th account for large shares of their total. Most of these convolutional layers fall into the type of pointwise convolutional layer.
Since the operation of the 0th convolutional layer is to input color images of three channels, channel compression cannot be carried out on this layer. erefore, the pointwise convolutional layer of the 3rd, 6th, 9th, 12th, 15th, 18th, and 20th layer is selected for channel compression analysis, so as to achieve a more obvious optimization effect. rough comprehensive consideration of convolution kernel parameters, floating-point multiplication calculation, together with other factors, channel compression is carried out to the pointwise convolutional layer 20th.
(2) Assessing the Importance of Each Channel in the Convolutional Layer.After the selection of the convolutional layer that must be compressed, the importance of each channel in the layer is evaluated. e detection accuracy difference is used to measure the contribution of the channel to the network model and is the main basis to evaluate the importance of the channel. e difference of detection accuracy refers to the discrepancy between the accurate value of detection output when the input channel number of a convolutional layer is compressed and that of detection when the channel number is not compressed. e difference equation of detection accuracy is shown in equation (3): In the equation, AP is the number of convolution kernel parameters, P is the detection accuracy before channel compression, and P′ is the detection accuracy after channel compression.
en, the channels with a small difference of detection accuracy, that is, those with a small contribution to the network model, are sorted in an ascending order.
(3) Channel Compression Algorithm. After obtaining the influence of each channel compression on the detection accuracy, the channel compression is carried out. According to the contribution of each channel to the network model, it is removed in order from small to large. At the same time, it monitors whether the current detection accuracy is lower than the set threshold. When the detection accuracy is less than the set value, the compression will stop immediately and the channel compression algorithm ends. e channel compression algorithm is shown in Algorithm 1.
θ p represents detection accuracy decreasing threshold. s represents the percentage of removed channels in the total number of channels in the convolutional layer. D p represents the difference value array of detection accuracy.
In Algorithm 1, the compressed channel index I channel and the number of channels N are computed through compression ratio s and detection accuracy array D p . en, the new network configuration file C is generated from N, and the new weight file W compressed is obtained by using the original network weight W original and I channel . Since channel compression changes the original network structure, the compressed network model is then trained to convergence (1) Initialize:

Experiment
is section involves the experiments designed to investigate the optimization performance index of M 7 network model. On this basis, an iterative compression experiment is carried out for the proposed channel compression algorithm. By analyzing the relevant experimental data of each compression, the optimization effectiveness of the channel compression algorithm is verified by measuring the detection speed and accuracy. Table 3 shows the detailed information of the operating system, CPU, and RAM used in this experiment. e passenger dataset in this paper consists of 12,749 images captured by bus videos from the camera photographing bus passengers vertically. e ratio of the training set and test set in these images is approximately 4 : 1. e datasets are about different weathers in our bus videos, including sunny day, rainy day, snowy day, and so on. As a result of driving the bus in day and night, light condition is a factor that cannot be ignored and often causes errors in the bus passenger object detection. e experiment has prepared enough datasets to take everything into account to ensure the reliability of our data. e hyperparameters of the network structure (excluding the number of convolution kernels) were taken consistent default settings in the experiments. Some hyperparameters are shown in Table 4.

Analysis of Experimental Results.
In the channel compression algorithm, the values of the θ p and s are set to 2% and 5%, respectively. e number of channels calculated by the channel compression algorithm N is rounded downward. e network compression iterative experimental results are obtained by the channel compression algorithm.
e experimental results are shown in Table 5.
As can be seen from Table 5, in the process of gradually increasing compression ratio, the detection accuracy is always floating around 0.93, while the detection time is gradually decreasing and the detection speed is constantly improving. When the compression ratio of the network model is 65%, the detection accuracy drops sharply and exceeds the threshold value of the detection accuracy difference set by 0.02, stopping the network compression. e total execution time of the program is 0.225 s in the M 7 network model measured by the GNU profiler tool. Among them, the execution time of the gemm_nn function is 0.129 s, accounting for 57.14% of the total execution time of the program. After optimization by the channel compression algorithm, the deletion parameters account for 62% of the total parameters, and the total execution time of the program is 0.162 s. Among them, the execution time of the gemm_nn function is 0.061 s, accounting for 37.84% of the total execution time of the program. After channel compression, the convolution operation is no longer the bottleneck of time-consuming of the detection program. e number of parameters decreased from 7 MB in M 7 network model to 3.3 MB. Compared with the M 7 network model, the detection speed of the network optimized by the channel compression algorithm is increased by nearly 40% times, while the detection accuracy is only reduced by 5%.  In three sets of contrast experiments, this section measures the original network model tiny YOLO, improved network model M 7 , and compressed M 7 from the aspects of average precision (AP), time-consuming, frames per second (FPS), and model weight size, as shown in Table 6.
In terms of AP, the values of each network model differ slightly, and the value that varies greatly is just declining by about one percent. In terms of time-consuming detection, the time for detecting an image in the improved network model is reduced from 0.915 s to 0.162 s, compared with the original network model. In terms of FPS, the detection speed increases from 1.093 frames to 6.217 frames, with an obvious improvement in the detection speed. In terms of weight file size, it is reduced from the original 60.5 MB to 3.3 MB.
Analyzed from the perspective of the recall rate accuracy, Figure 10 reveals the precision and recall figure of the tiny YOLO, M 7 , and compressed M 7 network structures. In Figure 10, the abscissa is the recall rate and the ordinate is the detection accuracy. From the figure, the detection accuracy of each network model drops significantly when the recall rate exceeds 0.93.
Based on the indicators above, the compressed M 7 model significantly improves the detection speed while reducing the detection time as well as weight file size. In particular, there is little sacrifice in detection accuracy.

Conclusion
In this paper, the convolution network model optimization of bus passenger target detection is studied by means of video observation on the basis of a lightweight network model M 7 optimized by depthwise separable convolution method. Firstly, the influence of channel compression on network model is analyzed, and then the channel compression process is described. Secondly, the network parameters and theoretical calculation quantity are analyzed to determine the convolutional layer which needs channel compression. And then the importance of each channel to the whole network model is evaluated according to the difference of its influence on detection accuracy. Finally, combined with the channel compression algorithm, the lightweight network model M 7 is compressed. e experimental results show that when 62% of parameters of the convolutional network are removed by channel compression, the time consumption of convolution operation is reduced by one time, the size of weight file is reduced by nearly one time, and the detection speed is increased by 40%. To sum up, channel compression achieves better compression effect.

Data Availability
e data used to support the findings of this study are included within the article.