# Multi-Scale Safety Helmet Detection Based on SAS-YOLOv3-Tiny
## 3 SAS-YOLOv3-Tiny Algorithm
### Sandglass-Residual Module Based on Channel Attention Mechanism  
The inverted residual module of MobileNetv2 [23] places the shortcut on the low-dimensional representations. Feature compression will cause some problems that optimization is complicated, and the gradient is easy to shake, affecting the convergence of the model. MobileNext [24] proposes a new sandglass bottleneck module to solve the inverted residual module problem, which puts the shortcut on the high-dimensional representations. The above operations can retain the advantages of high-speed convergence and training on the high-dimensional network and take advantage of the computational advantages of depthwise separable convolution. In general, the parameters and calculation amount of traditional convolution increase significantly with the increase of convolution layers. So the conventional convolution is replaced with depthwise separable convolution to reduce model complexity, which is transformed into two parts: depthwise convolution and point convolution. We assume that the size of input feature map is \(D_{F}\times D_{F}\times M\), the size of output feature map is \(D_{F}\times D_{F}\times N\) and the size of standard convolution kernel is \(D_{K}\times D_{k}\times M\). The computation amount of standard convolution is \(D_{K}\times D_{K}\times M\times N\times D_{F}\times D_{F}\). In the depthwise convolution operation, the size of convolution kernel is \(D_{k}\times D_{k}\times 1\) and its number is M. In the point convolution operation, the size of convolution kernel is \(1\times 1\times M\) and its number is N. so the computation amount of depthwise separable convolution is \(D_{K}\times D_{K}\times M\times D_{F}\times D_{F}+M\times N\times D_{F}\times D _{F}\). By comparing the computational amount of the two, the computational amount of depthwise separable convolution can be reduced to \(1/N+1/D_{K}^{2}\) of the standard convolution. In our work, the Sandglass-Residual module based on the lightweight idea is constructed in the feature extraction process, ensuring that more information is passed from the bottom to the top and gradient propagation is facilitated. The Specific operations are as follows. In the high-dimensional space, two depthwise convolutions with kernel size of \(3\times 3\) are performed, which can encode more spatial information. The point convolution with kernel size of \(1\times 1\) is utilized to reduce and increase channels' dimensions and encode information between channels. The first depthwise convolution and the last point convolution use nonlinear activation functions. In contrast, the first point convolution and the final depthwise convolution directly perform linear output to avoid information loss. The parameters of the Sandglass-Residual module are shown in Table 1.  
The YOLOv3-tiny algorithm is applied to a real-world scenario dataset, objects in the image are treated equally. If the weight is assigned to the features of the object area, the weighted feature maps will be conducive to detecting far-distance and small-scale safety helmets, which can improve detection accuracy without introducing too many parameters. The Squeeze-Excitation (SE) channel attention module in SENet [25] gives different weights to different channels in the feature map of the convolutional neural network, making the network pay more attention to the channels with higher weights. \begin{table}
\begin{tabular}{c c c} \hline
**Input** & **Operation** & **Output** \\ \hline \(h\times w\times n\) & \(3\times 3\) Dwise conv, leaky & \(h\times w\times n\) \\ \(h\times w\times n\) & \(1\times 1\) conv, linear & \(h\times w\times\frac{n}{2}\) \\ \(h\times w\times\frac{n}{2}\) & \(1\times 1\) conv, leaky & \(h\times w\times n\) \\ \(h\times w\times n\) & \(3\times 3\) Dwise conv, linear & \(h\times w\times n\) \\ \hline \end{tabular}
\end{table} 
Table 1: The parameters of Sandglass-Residual module. Thus, it can enhance the learning ability of the network, and its specific operations are as follows.