# MCA-YOLOV5-Light: A Faster, Stronger and Lighter Algorithm for Helmet-Wearing Detection
## 3 Method
### Mca-YOLOv5
#### 3.1.2 MCA Attention Mechanism  
Due to the limited computational overhead, the weight function requires a scalar for each channel, and the Global Average Pooling (GAP) becomes a standard choice in the deep learning field due to its simplicity and efficiency. Although this choice is simple and efficient, the GAP cannot capture the diverse pattern information very well, so the feature generalization is missing in response to different inputs. [PERSON] et al. (2019) proposed the Multispectral Channel Attention (MCA) module to solve the above problems.  
GAP is the lowest frequency of Discrete Cosine Transform (DCT), and only taking GAP is equivalent to not using the remaining frequency components containing much available information in the feature channel. 2 DDCT is shown in Equation (1):  
\[\begin{array}{c}f_{h,w}^{2d}=2 DDCT(x_{i})=\sum_{i=0}^{H-1}\cos(\frac{(2i+1) \pi h}{2H})\Big{\{}\sum_{j=0}^{-W-1}x_{i,j}^{2d}\cos(\frac{(2j+1)\pi w}{2W}) \Big{\}}\\ \qquad\qquad\qquad i,h\in\{0,1,\ldots,H-1\},\quad j,w\in\{0,1,\ldots,W-1\}\end{array} \tag{1}\]  
in which \(x\in\mathbb{R}^{H\times W}\) is the input and \(H\) and \(W\) represent the height and width of the input components.  
Although the multispectral channel attention module has the same starting point as other attention modules, the multispectral channel attention module not only retains the global average pool but also uses the frequency component besides the global average pooling, which can solve the problem of missing information caused by only a single frequency, make the network model pay more attention to important features and filter redundant features. The multispectral channel attention module is improved based on the SE (Squeeze and Excitation) module. The specific structure diagram is shown in Figure 3.  
Figure 2: The MCA-YOLOV5 network model structure.  
In order to integrate more frequency component information, including the lowest frequency component GAP, the multispectral channel attention module uses two-dimensional discrete cosine variables to operate. As can be seen from Figure 3, the specific execution steps are as follows: First, the input \(X\) is divided into \(n\) parts according to the channel dimension, which should be able to be divided by the number of channels. For each part, its corresponding two-dimensional discrete cosine variable frequency component is uniformly assigned, and its final output can be used as a preprocessing result of channel attention (e.g., GAP), as shown in Equation (2):  
\[Freq^{i}=2 DDCT^{u,v}\Big{(}X^{i}\Big{)}=\sum_{h=0}^{H-1}\sum_{w=0}^{W-1}X^{i}_ {j,h,w}B^{u,v}_{h,w} \tag{2}\]  
_Freq\(R^{C}\)_ is the preprocessed multispectral vector, \(2 DDCT\) expressed as the \(2\)-\(DDCT\) frequency component, \([u,v]\) is corresponding to the frequency component 2D index, \(H\) is the height of input \(X\), \(W\) is the width of input \(X\), \(X^{1}\), \(X^{2},\ldots,X^{n-1}\) represents the divided parts, \(X^{i}\in R^{C^{\prime}\times H\times W}\), \(C^{\prime}=\frac{C}{n^{\prime}}\), \(C\) can be divisible by \(n\) and \(B^{u,v}_{h,w}\) is the basis function of the 2D discrete cosine transformation.  
Then, the frequency components of each part are combined, which is the multispectral vector, as shown in Equation (3): \(Freq\in R^{C}\)  
\[Freq=cat\Big{(}\Big{[}Freq^{0},Freq^{1},\ldots,Freq^{n-1}\Big{]}\Big{)} \tag{3}\]  
Among them: \(Freq\in R^{C}\) is the preprocessed multispectral vector.  
\[att=sigmoid(fc(Freq)) \tag{4}\]  
_sigmoid_ representing the sigmoid function, \(fc\) representing the mapping function, such as a fully connected layer or a one-dimensional convolution. \(att\) represents the entire MCA attention mechanism.