# Research on an Insulator Defect Detection Method Based on Improved YOLOv5
## 1 Introduction
[21] proposed a CenterNet-based insulator defect detection method, which simplified the backbone network and applied an attention mechanism in the model to suppress useless information, improving the accuracy of network detection. However, the detection speed is not high, and when two different defect classes share the same centroid, CenterNet can only detect one of the defect types. [PERSON] et al. [22] proposed an improved YOLOv4-based algorithm for defect detection of insulators. A GraphCut image enhancement method was used, and then the images were processed by sharpening to recreate a dataset. A MobileNet lightweight network is used to fuse with the YOLOv4 model structure. [PERSON] et al. [23] proposed a new convolutional neural network cascade architecture for performing defect localization and detection of insulators. This network uses a CNN based on a region suggestion network to transform defect detection into a two-level object detection problem. [PERSON] et al. [24] proposed an insulator defect detection method based on the improved ResNeSt and region proposal network (RPN). A new network based on ResNeSt was first built, and then the improved RPN was added to the improved network for feature extraction to better detect minor defects on insulators. Insulators are diverse and complex, and traditional manual inspection is inefficient and prone to leakage and misdetection. Therefore, it is especially important to research a method for insulator defect detection. This article focuses on the problem of insulator defects in power systems. It applies deep learning-based target detection to insulator defect detection, which is significant in improving the inspection intelligence of power systems. The YOLO series algorithm is a deep learning neural network image recognition algorithm. The YOLOv5 algorithm, as a representative of a single-stage detection algorithm, has the advantages of a small amount of code, simple procedure, fast detection speed, and high detection accuracy. It is the closest image recognition algorithm to engineering technology. In this paper, the YOLOv5 algorithm is improved for insulator image and defective insulator detection. Firstly, the insulator defect image samples are re-clustered using the k-means clustering algorithm to obtain different-sized a priori frame parameters; the attention mechanism NAM is added to the feature extraction module of the YOLOv5 algorithm, and the NAM attention is redesigned for the channel and space attention submodule. The contribution factor in weights is used to improve the attention mechanism. Furthermore, batch-normalized scale factors are used, and the standard deviation is used to indicate the weight importance; a g\({}^{\text{n}}\)Conv recursive gated convolution is used instead of the typical convolution module of the neck network in the YOLOv5 model. g\({}^{\text{n}}\)Conv achieves the modeling of higher-order spatial interactions. It has the features of high performance, scalability, and translation invariance. The improved algorithm is used to enhance the network feature extraction capability, as well as the efficiency of feature fusion, to improve YOLOv5s detection performance. The proposed method achieves a good balance between accuracy and speed, and the performance fully meets the demand of power inspection for insulator online localization.