# Research on an Insulator Defect Detection Method Based on Improved YOLOv5
## 4 Experimental Results and Analysis
### Model Training  
In the model training process, the weights used were YOLOv5s trained weights, file YOLOv5s.pt on the COCO dataset, as the initial weights of the YOLOv5s model. The small-batch stochastic gradient descent (SGD) method was used to train the model. The BatchSize of the model was set to 16, the epoch was set to 300, and the initial learning rate of the network was 0.01. According to the data shown in Table 2, a suitable base model was selected for the experiments. The data in the table are all measured in the same experimental environment. In Figure 8a-d are the results tested by the above four models, respectively. As can be seen from the figure, we selected three graphs for each of the above four YOLOv5 models to make predictions, and the results are precise, such that the YOLOv5s model is more accurate in terms of relative detection accuracy compared to the other three models, is faster, has fewer parameters, and has lower computational complexity. From the perspective of the data set selected in this paper, the data features are relatively single, the complexity is relatively low, and most of them are single-label. From the perspective of the actual project requirements, applicable to company projects, the demands for defect detection tend to be lightweight and balanced detection accuracy and detection speed. From the analysis of the data in the table, the spatial complexity (parameters), model size, number of parameters, and temporal complexity are noted. GFLOPs measure the complexity of the model while affecting the training time; after careful consideration, this paper uses the YOLOv5s model as the baseline. To verify the effectiveness of this paper based on the improved YOLOv5s algorithm, ablation experiments were conducted on the same training set and test set samples for this study algorithm with each improved content, and the results of the ablation experiments are shown in Table 3. The mAP value and class loss function of the optimal model in this paper are shown in Figure 9a,b. \begin{table}
\begin{tabular}{l c c c c c c} \hline
**Models** & **P** & **R** & **[EMAIL_ADDRESS]** & **[EMAIL_ADDRESS]-0.95** & **Parameters (M)** & **GFLOPs (B)** \\ \hline YOLOv5s & 0.956 & 0.907 & 0.927 & 0.626 & 7.0 & 15.8 \\ YOLOv5m & 0.904 & 0.823 & 0.873 & 0.536 & 20.1 & 47.9 \\ YOLOv51 & 0.96 & 0.88 & 0.924 & 0.613 & 46.1 & 107.7 \\ YOLOv5x & 0.924 & 0.884 & 0.925 & 0.591 & 86.2 & 203.8 \\ \hline \end{tabular}
\end{table} 
Table 2: Performance of insulator defect detection models with different YOLOv5 models. Figure 8: Comparison of the test results of four YOLOv5 models. (**a**) YOLOv5s test results; (**b**) YOLOv5m test results; (**c**) YOLOv5l test results; (**d**) YOLOv5x test results. The improvement effect of each module is analyzed qualitatively by controlling one or more variables in anchor, NAM, and g\({}^{n}\)Conv. With the addition of the NAM module, the attention mechanism assigns reasonable weights to channels and spaces, improves the network's attention to specific regions of objects, and improves target missing detection and omission to some extent. Adding g\({}^{n}\)Conv introduces a beneficial inductive bias in the current defect detection task and avoids the asymmetry caused by local attention. Furthermore, the features are further extracted by recursive gated convolution, which is a particular improvement compared with the original algorithm; the value of mAP is improved by 1%. In this paper, the selected YOLOv5s is compared with classical target detection algorithms: single-stage SSD, YOLOv3, YOLOv4, and two-stage Fast-RCNN, etc. The main comparisons are P, R, and mAP for each defect class, and the results are shown in Table 4 below.