# SC-YOLOv8 Network with Soft-Pooling and Attention for Elevator Passenger Detection
## 3 Method
### Soft-Pooling and Multi-Scale Convolution CBAM  
The visual attention mechanism has significant advantages in the elevator passenger detection task, which can dynamically weight the features of the input image, and, therefore, can help to localize and identify the objects in the image in the object detection task. The CBAM attention mechanism is a typical hybrid attention mechanism that sequentially applies channel attention mechanism (CAM) and spatial attention mechanism (SAM) modules. Compared to using channel attention or spatial attention independently, CBAM can achieve better results [26]. As illustrated in Figure 10, the CBAM attention mechanism takes a given intermediate feature map \(F\in R^{\mathbb{C}\times H\times W}\) as input. First, the CAM module aggregates the spatial information of the feature map through operations like average-pooling and max-pooling. Subsequently, the spatial information is processed through a shared multilayer perceptron (Share MLP) to generate a one-dimensional channel attention map \(CA(F)\). \(CA(F)\) is then element-wise multiplied with the input feature map \(F\), and the channel attention values are broadcast along the spatial dimension to obtain refined features \(F_{\mathbb{C}}\in R^{\mathbb{C}\times H\times W}\) with channel attention. The SAM module processes \(F_{\mathbb{C}}\) to generate a spatial attention map \(SA(F)\). The final output feature \(\hat{F}\in R^{\mathbb{C}\times H\times W}\) is obtained by element-wise multiplication of \(SA(F)\) and \(F_{\mathbb{C}}\). The convolutional module receives the spatial attention map for channel mixing. Finally, the refined features are obtained as output by element-wise multiplication of the channel mixing result with channel priors, as detailed in Equations (15) and (16). \[F_{\mathbb{C}}=CA(F)\otimes F \tag{15}\]  
\[\hat{F}=SA(F_{\mathbb{C}})\otimes F_{\mathbb{C}} \tag{16}\]  
In the CAM module, the processing of the feature map involves the use of average-pooling and max-pooling operations to aggregate spatial information. However, the max-pooling operation overlooks the influence of other elements in the pooling region on the result and, thus, may result in the loss of useful information. On the other hand, the average-pooling operation, while capable of preserving more information of the feature map, can result in the loss of discriminative information due to mutual cancellation of positive and negative activation values. To retain more useful information from the feature map, as shown in Figure 11, this paper introduces soft-pooling operations into the CAM module. This addition aims to preserve more useful information. Assuming the input feature map to the CAM module proposed in this paper is denoted as \(F\in R^{\mathbb{C}\times H\times W}\), the expression for the channel attention feature vector \(\mathbb{C}\times 1\times 1\) of dimension \(CA(F)\) generated by the CAM module is as Equation (17). \[CA(F)=\sigma(MLP(MaxPool(F))+MLP(SoftPool(F))+MLP(AvgPool(F))), \tag{17}\]  
where \(MaxPool\) represents the max-pooling operation, \(SoftPool\) represents the soft-pooling operation, \(AvgPool\) stands for the average-pooling operation, \(\sigma\) stands for the sigmoid activation function, and \(MLP\) stands for the Share MLP operation. Figure 10: CBAM attention. As depicted in Figure 12, in the SAM module, this paper also incorporates soft-pooling operations. Considering that the SAM module employs a \(7\times 7\) convolutional kernel for feature map processing, which may lead to a uniform spatial attention weight distribution among channels, this paper addresses this by using multi-scale depth-wise separable convolutions instead of the \(7\times 7\) convolutional kernel in the SAM module. The calculation of spatial attention can be described as Equation (18).