# Multi-Defect Detection Network for High-Voltage Insulators Based on Adaptive Multi-Attention Fusion
## 3 AC-YOLO Target Detection Network
### CBAM Attention Mechanism  
Adding the CBAM attention module after the backbone feature extraction network can avoid feature loss and filter out useful features in the neural network during the multi-layer operation iteration process. The CBAM [22] attention module is shown in Figure 8. Compared with attention modules such as SE and ECA, which can only screen out channel features, the CBAM attention module can simultaneously screen channel and spatial features. The CBAM attention module uses the channel attention mechanism and the spatial attention mechanism to perform weighting operations on the input feature map F, in turn. Multiplying the weight and the feature map can complete the screening of channel and spatial features and obtain the weighted adjusted selected feature map. It also strengthens the ability to express the characteristics of small target defects. \begin{table}
\begin{tabular}{c c} \hline \hline
**Activation Function** & **Accuracy (\%)** \\ \hline AMFDH+ SiLU & 90.1 \\ AMFDH+ HardSwish & 89.5 \\ AMFDH+ Meta-ACON & 91.2 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Accuracy of different activation functions. Figure 7: Structure of AMFDH. Within the channel attention module, the input feature map, denoted by F, undergoes a process of global aggregation. This operation combines the global channel information of the image through both global average and maximum pooling. This results in dimensions of 1 \(\times\) 1 \(\times\) C. Following this, a shared perceptron and a sigmoid function are employed. These tools assign high-weight values to channels that are significantly correlated with the target information, which aids in filtering out irrelevant channel details. Through this process, the channel-specific details are integrated to produce the channel attention weight coefficients, symbolized by M\({}_{\text{C}}\)\(\in\)\(R^{\text{C}\times 1\times 1}\). Finally, the feature map F\({}^{\prime}\) is obtained by performing element-wise multiplication with the original feature map. The calculation equation is as follows:  
\[\left\{ \begin{array}{l}\text{M}_{\text{C}}(\text{F})=\sigma(MLP(AvgPool(\text {F}))+MLP(MaxPool(\text{F})))\\ \text{F}^{\prime}=\text{M}_{\text{C}}(\text{F})\otimes\text{F}\end{array} \right., \tag{8}\]  
where F is the input feature map, M\({}_{\text{C}}\) is the channel weight coefficient, F\({}^{\prime}\) is the channel attention map of size \(C\times H\times W\), \(\sigma\) denotes the sigmoid function, and \(\otimes\) denotes matrix multiplication. Within the spatial attention module, the feature map is subjected to maximum pooling and average pooling processes. These generate two feature maps that carry comprehensive spatial information. These maps are subsequently concatenated along the channel dimension, which allows for the filtration of spatial information pertinent to the target. The output feature map from this process has dimensions of \(H\times W\times 2\). Thereafter, this map is processed through a 7 \(\times\) 7 convolutional layer, which produces a channel feature map with a dimension of 1. To derive the spatial weight, denoted as M\({}_{\text{S}}\), the sigmoid function is then applied. Finally, the CBAM attention output feature map F\({}_{\text{S}}\) is obtained through element-wise multiplication between the feature maps F\({}^{\prime}\) and F\({}_{\text{S}}\). The calculation equation is as follows:  
\[\left\{ \begin{array}{l}\text{M}_{\text{S}}(\text{F}^{\prime})=\sigma(f^{ \prime}\times\gamma([AvgPool\left(\text{F}^{\prime}\right);MaxPool\left(\text{ F}^{\prime}\right)]))\\ \text{F}_{\text{S}}=\text{M}_{\text{S}}(\text{F}^{\prime})\otimes\text{F}^{ \prime}\end{array} \right., \tag{9}\]  
where M\({}_{\text{S}}\) denotes the spatial weight matrix and F\({}_{\text{S}}\) is the final output feature map. To highlight the benefits of the CBAM attention mechanism in model validation, we visualized the AC-YOLO network and compared it with the original YOLOv5 network.