# Automatic Detection of Construction Workers' Helmet Wear Based on Lightweight Deep Learning
## 3 Methodologies
### Improved Lightweight Residual Convolutional Attention Network  
In our previous work, we replaced the fully connected layer in the channel attention module of CBAM with 1D convolution. We added the residual structure to obtain the improved network LRCA-Net [28] ([PERSON] et al., 2022) so that the modified module can effectively capture the information of cross-channel interaction and reduce the overall number of parameters of the module to achieve overall efficiency. However, we find that there is still room for improvement by analyzing the spatial attention module part of LRCA-Net (whose structure is shown in Figure 5). The operation process is shown in Equation (1), i.e., maximum pooling and average pooling are used, respectively. Then, the two obtained features are connected and aggregated into a feature with the shape of H \(\times\) W \(\times\) 2. Then, it is directly convolved by a standard convolution layer of size \(7\times 7\), and then the spatial-refined feature \(F^{\prime}\) by sigmoid:  
\[F^{\prime}=A_{s}(F^{\prime})=\sigma\Big{(}k^{7\times 7}\big{(}\big{[}Maxpool \big{(}F^{\prime}\big{)};Avgpool\big{(}F^{\prime}\big{)}\big{]}\big{)}\Big{)} \tag{1}\]  
where \(A_{s}\) denotes the spatial attention module, \(F^{\prime}\) denotes the channel-refined feature, \(F^{\prime\prime}\) denotes the spatial-refined feature \(F^{\prime\prime}\), \(\sigma\) denotes the sigmoid function, and \(k^{7\times 7}\) represents the convolution kernel size of \(7\times 7\). It can be seen that the drawback of this spatial attention module is very obvious. The direct \(7\times 7\) standard convolution for the feature map cannot obtain the feature map with integrated global information. As shown in Figure 6, there is a lack of perceptual relationship between the two \(7\times 7\) convolutions for feature maps of size \(n\times n\). Figure 5: The structure of LRCA-Net’s spatial attention module. To solve this problem, we improved the spatial attention module, as shown in Figure 7. First, we averaged the pooling based on the \(X\) and \(Y\) axes, respectively, for the input feature map \(F^{\prime}\) with shape H \(\times\) W \(\times\) C as in Equations (2) and (3):  
\[X_{j}\big{(}F^{\prime}\big{)}=Avgpool(H)=\frac{\sum_{i=1}^{n}f_{ij}}{W} \tag{2}\]  
\[Y_{i}\big{(}F^{\prime}\big{)}=Avgpool(W)=\frac{\sum_{j=1}^{n}f_{ij}}{H}, \tag{3}\]  
where \(W\) is the width of the feature map, \(H\) is the height of the feature map, and \(f_{ij}\) is the feature map value within the feature map at \((i,j)\). The aggregated features obtained along the two directions are \(X(F^{\prime})\) with the shape \(H\times\) 1 \(\times\) C and \(Y(F^{\prime})\) with the shape \(1\times\)\(W\times\) C, respectively, and the two features are  
Figure 6: For feature maps of size \(n\times n\), there is an obvious lack of perceptual relationship between two 7 \(\times\) 7 convolutions at longer distances. Figure 7: The structure of the modified spatial attention module. concatenated and subjected to a \(1\times 1\) convolution operation to obtain the integrated feature \(f\) as in Equation (4). This perception capability can provide the correlation between features in the same space and accurately retain their location information, which helps to locate the object more accurately:  
\[f=ReLU\big{(}Conv2d\big{(}\big{[}X\big{(}F^{\prime}\big{)},Y\big{(}F^{\prime} \big{)}\big{]}\big{)}\big{)} \tag{4}\]  
where \([. ]\) represents the concatenate operation, \(ReLU\) is the normalization and activation function, and \(f\) is the integrated feature.