Lightweight insulator defect detection method based on improved YOLOv5 network

By improving the YOLOv5 network, the problems of difficult image acquisition, multiple defect recognition and complex environment recognition in insulator defect detection are solved, and high-precision and lightweight insulator defect detection is achieved.

CN118967550BActive Publication Date: 2025-09-19CHINA THREE GORGES UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410872115.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-01
Publication Date
2025-09-19
Estimated Expiration
2044-07-01

AI Technical Summary

Technical Problem

When detecting defects in transmission line insulators, existing technologies face problems such as difficulty in acquiring defect images, limited detection and identification methods for multiple defect types, low recognition accuracy in complex environments, and insufficient detection accuracy of lightweight models.

Method used

By improving the YOLOv5 network, adding a fusion branch, a CBAM attention module, and a multi-scale fusion module, and replacing the C3 module with the C3Ghost module, a lightweight insulator defect detection model was trained and verified to enhance the recognition capabilities of complex environments and small targets.

Benefits of technology

The accuracy and recall of insulator defect detection are improved, and the model size is reduced, making it suitable for actual deployment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118967550B_ABST
    Figure CN118967550B_ABST
Patent Text Reader

Abstract

A lightweight insulator defect detection method based on an improved YOLOv5 includes: obtaining an insulator image dataset and preprocessing the insulator images in the dataset to obtain an insulator image training set and an insulator image validation set; improving YOLOv5 by first adding a fusion branch between the backbone network and the neck network, mapping a three-level fusion module into the neck network, then adding a CBAM module to enhance effective features, then adding a small target enhancement module, and finally replacing the C3 module with a more lightweight C3Ghost module; selecting appropriate equipment and experimental parameters to train and verify the improved YOLOv5 network model to obtain an insulator detection network model; and evaluating the improved model of the present invention. This method solves the problems of low insulator detection accuracy and large detection models in complex environments.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of insulator defect detection, and in particular relates to a lightweight insulator defect detection method based on an improved YOLOv5 network. Background Art

[0002] Insulators in power transmission line systems are prone to breakage and flashover due to prolonged exposure to harsh natural environments. These problems can lead to regional power outages and catastrophic accidents. Regular insulator inspection is crucial for the proper operation of power systems. Manual insulator inspections are time-consuming and intensive, subject to environmental influences, lack flexibility, and pose risks. With the development of smart grids, intelligent devices such as drones and inspection robots can effectively replace manual inspections. These devices use cameras to capture images and visual algorithms to detect defective components, making them efficient and flexible, and have been widely researched and implemented.

[0003] In recent years, various methods have been introduced to detect component defects, such as traditional image processing and deep learning algorithms. Traditional image processing typically involves two steps: identifying the target component and detecting defects using mathematical models. This method can accurately detect component defects, but requires the establishment of corresponding feature extraction algorithms and defect discrimination models for each type of defect, making it less practical. Since the rise of deep learning, image semantic segmentation technology has been applied by many scholars to various fields. This technology performs pixel-level classification and greatly improves the accuracy of defect detection. Compared with traditional image processing methods and deep learning algorithms, one of the main advantages of deep learning is that it does not require manually designed feature extraction, making it effective for detection tasks with different target features and complex image backgrounds, while also having better robustness and stronger model generalization capabilities.

[0004] Although deep learning has made progress in detecting defective components, several challenges remain. First, due to the relatively small number of defective insulator components on transmission lines, defect images are scarce and difficult to acquire. Second, because most studies focus on only one type of insulator defect, there are few methods for detecting and identifying multiple defect types. Finally, transmission lines are located in complex environments, such as foggy days; the size of defective components appearing in images is small compared to the complex background, especially insulator flashover defects, which reduces the accuracy of defect identification. Furthermore, current deep learning algorithms have low detection accuracy for lightweight models, making them difficult to meet engineering requirements. While models with larger parameters have some detection accuracy, they are too large to be easily deployed in practice. Summary of the Invention

[0005] In view of the above-mentioned deficiencies in the prior art, the present invention provides a lightweight insulator defect detection method based on an improved YOLOv5 network. By acquiring accurate insulator images and performing data set augmentation, and improving the structure of YOLOv5, a lightweight network model that is more suitable for insulator defect detection is obtained through training and verification, thereby solving the problems of low efficiency and low accuracy of insulator defect detection in complex environments.

[0006] The technical solution adopted by the present invention is:

[0007] The lightweight insulator defect detection method based on the improved YOLOv5 network includes the following steps:

[0008] Step 1: Obtain an insulator image dataset and preprocess the insulator images in the insulator image dataset to obtain an insulator image training set and an insulator image verification set;

[0009] Step 2: Improve the YOLOv5 network to enhance the recognition of insulators in complex environments and small targets such as insulator flashover defects, while reducing the model size to facilitate practical deployment.

[0010] Step 3: Use the obtained insulator image training set and insulator image verification set to train and verify the improved YOLOv5 network model to obtain a network model capable of identifying insulators and insulator defects.

[0011] Step 4: Model comparison and evaluation, improvement effect evaluation.

[0012] The step 1 comprises the following steps:

[0013] S1.1. Collect the insulator images currently available for download and taken on-site to form the original dataset;

[0014] S1.2. Select the insulator images in the original data set one by one, remove the invalid insulator images, and leave the clear and visible valid images, including insulator damage defects, insulator flashover defects and normal insulator images.

[0015] S1.3. Randomly select some insulator images, add Gaussian blur to the selected insulator images, and change the saturation and brightness of the selected insulator images to expand the insulator image dataset;

[0016] S1.4. The dataset of the present invention contains 3,500 images. The LabelImg tool is then used to annotate the images. The labels are as follows: damaged insulators are labeled as damaged, flashover insulators are labeled as flashover, and normal insulators are labeled as insulator. Finally, the dataset is divided into a training set and a validation set in a ratio of 8:2.

[0017] In S1.3, the Gaussian blur calculation formula is as follows:

[0018]

[0019] Where: μ and ν represent the horizontal and vertical coordinates of the coordinate with the fuzzy center as the origin, μ 2 +ν 2 =r 2 represents the standard deviation, where r represents the blur radius and σ represents the standard deviation of the normal distribution.

[0020] In step 2, the YOLOv5 network is improved as follows:

[0021] 2.1: Add a fusion branch between the backbone network and the neck network, further extract features, and fuse them into the neck network to form a TriFusion module with a three-level fusion structure;

[0022] 2.2: Integrating CBAM attention module: A CBAM attention module is embedded at the end of the backbone network, a CBAM attention module is embedded after the three-level fusion module TriFusion, and a CBAM attention module is embedded after the last two-level fusion Cancat layer of the neck network;

[0023] 2.3: Add a multi-scale fusion module for reinforced insulator small targets;

[0024] 2.4: Replace the C3 module in the original YOLOv5 network model with the lighter C3Ghost module.

[0025] In step 2, the improved YOLOv5 network model includes a Conv module, which is used to extract features and downsample to reduce the dimension of the input feature map;

[0026] The function of the C3Ghost module in the improved YOLOv5 network model is to extract features, increase the receptive field, and increase the network depth. It has a smaller number of parameters than the C3 module in the original model. The bottleneck module in the C3 module is the Bottleneck module, and the bottleneck module in the C3Ghost module is the lighter Ghostbottleneck module. The convolution module in the Bottleneck module is the Conv module, and the convolution module in the Ghostbottleneck module is the GhostConv module. The computational formulas for the Conv module and the GhostConv module are as follows:

[0027] GFLOP (Conv) =nhwCk 2

[0028]

[0029]

[0030] Where: GFLOP (Conv) Indicates the amount of computation of the Conv module; GFLOP (GhostConv) Represents the amount of computation of the GhostConv module; n represents the number of feature maps, h represents the height of the feature map, w represents the width of the feature map, C represents the number of channels, k 2 and d 2 It represents linear operation, and s can be regarded as the compression ratio of the computational complexity of the two. Its value is greater than 1, which shows that the computational complexity of C3Ghost is smaller than that of the C3 module.

[0031] The GhostConv module first uses a small number of convolution kernels to extract features from the input feature map, then further performs simpler linear transformation operations on this part of the feature map, and finally generates the final feature map through Cancat splicing; this method reduces the learning cost of non-critical features: that is, by combining a small number of convolution kernels with simpler linear transformation operations instead of conventional convolution methods, it effectively reduces the demand for computing resources while not affecting the performance of the model.

[0032] In step 2, the improved YOLOv5 network model includes an SPPF module, which is used to solve the problem of large target differences;

[0033] In the improved YOLOv5 network model, the CBAM attention module includes a channel attention module and a spatial attention module, and its formula is:

[0034]

[0035] Where: F represents the feature map, M c represents channel-based attention, M S represents spatial-based attention, represents element-by-element multiplication, F′ represents the output feature map after channel attention, and F″ represents the output feature map after spatial attention;

[0036] Where M c (F) can be expressed as follows:

[0037]

[0038] Where: σ represents the sigmoid activation function, W0 and W1 represent two weight-sharing neural networks, represents the average pooling operation, Represents the maximum pooling operation; Indicates that an average pooling operation is performed on the input feature map, followed by a convolution operation; Indicates that the maximum pooling operation is performed on the input feature map, followed by a convolution operation; Indicates that the average pooling operation is performed on the input feature map, followed by two convolution operations; Indicates that the maximum pooling operation is performed on the input feature map, followed by two convolution operations;

[0039] The above formula means that the input is reduced in dimension using the global maximum pooling and global average pooling layers to obtain two two-dimensional feature maps, and then the channel attention coefficient is obtained through two fully connected layers, which is multiplied by the input to obtain the weighted output;

[0040] Where M s (F) can be expressed as follows:

[0041]

[0042] Where: Indicates splicing, f 7×7 represents a 7×7 convolution kernel,

[0043] The above formula represents the average pooling operation and the maximum pooling operation on the input feature map, and then the feature maps of the two operations are spliced ​​together, and then convolution operation is performed through a 7×7 convolution kernel, and finally the final output is obtained through the sigmoid activation function;

[0044] Furthermore, the calculation formula of the above sigmoid activation function is:

[0045]

[0046] Where: e represents a natural constant, whose value is approximately 2.718; x represents the input feature map.

[0047] In step 2, the improved YOLOv5 network model includes an Upsample module, which is an upsampling module that expands the dimension of the image. The height and width of the feature map after the Upsample module are expanded to twice the original size.

[0048] In the step 2, the TriFusion module in the improved YOLOv5 network model is a three-level fusion structure with three input ends, two of which come from the backbone network and one from the previous upsampling layer; the feature maps of the three input ends have the same dimension, the two feature maps from the backbone network have the same number of channels, and the number of feature map channels from the previous upsampling layer is twice that of the other two.

[0049] In step 2, the improved YOLOv5 network model includes a Cancat module, which is a two-stage fusion module with two input channels. The Cancat in the enhanced small target module has one input layer from the previous upsampling layer and the other from the backbone network, and the feature map dimensions and channel numbers in the two input layers are the same. The other two Cancat input layers, one from the previous downsampling layer and the other from the upsampling part of the neck network, have the same feature map dimensions and channel numbers.

[0050] The beneficial effects of the improved method in S2 are as follows:

[0051] The addition of the fusion branch in 2.1 can effectively improve the accuracy of the information fused from the backbone network to the neck network. The three-level fusion structure can fuse the information in the shallow network of the backbone network with the information in the neck network, deepen the location information of the features in the neck network, and more accurately locate the target, effectively improving the detection accuracy.

[0052] In the above 2.2, a CBAM attention module is finally embedded in the backbone network. The CBAM module uses the characteristics of focusing on relevant features and filtering irrelevant features to effectively improve the effective information entering the neck network, filter invalid information, and effectively improve the final detection accuracy. A CBAM attention module is embedded after the three-level fusion module TriFusion. This is because the fusion of three feature maps increases the noise information. In addition, in S1.3, the present invention explains that Gaussian blur is added to some pictures, which increases the noise signal and further aggravates the superposition of the three-level fusion noise information. Therefore, the present invention embeds a CBAM attention module after the three-level fusion module TriFusion to effectively filter the noise signal. In the above S23, a CBAM attention module is embedded after the last secondary fusion Cancat layer of the neck network. Since the Cancat module here fuses the information of the shallower convolutional layer, there are more noise signals, so a CBAM attention module is embedded to filter the noise signal.

[0053] The multi-scale fusion module for enhancing small insulator targets mentioned in 2.3 aims to enhance the recognition of small defects such as insulator flashover defects by adding a 160×160-dimensional multi-level fusion structure. Its input comes from the shallow network part of the backbone network. The feature map here has strong position information, which can better locate the insulator position. The other part comes from the 160×160-dimensional part generated by upsampling in the previous layer. Because this part is deeper in the network, it has strong semantic information and can enhance the recognition of flashover defects.

[0054] The C3 module in the original model in 2.4 is replaced with a lighter C3Ghost module to reduce the model size. Through the improvements in 2.1 to 2.3, the model size is larger than the original model. By replacing C3 with C3Ghost, the model size can be effectively reduced while the detection accuracy does not change much, which is beneficial for future actual deployment.

[0055] The step 3 comprises the following steps:

[0056] S3.1. Select appropriate equipment for model training and select appropriate experimental parameters before training. The model training equipment selected in this invention is: the hardware environment uses Windows 11 64-bit, the CPU is AMD Ryzen 7 7745HX, the running memory is 16GB, and the GPU is NVIDIA GeForce RTX 4060 8GB; the software environment uses Python programming language, the deep learning framework is Pytorch, and the training platform is PyCharm.

[0057] The experimental parameters are: batch size is 8, initial learning rate is set to 0.01, momentum is set to 0.937, optimizer is SGD, and the number of training rounds is set to 200 rounds;

[0058] S3.2 Model training: As the number of training rounds increases, the total loss gradually decreases. When it reaches 200 rounds, the total loss fluctuates steadily, indicating that the model has achieved optimal detection results for insulator defects.

[0059] S3.3. Evaluation indicators:

[0060] The evaluation indicators of the present invention are precision (P), recall (R), mean average precision of all classes (mAP0.5), number of parameters (Params) and amount of computation GFLOPs. Precision, recall and mean average precision of all classes evaluate the detection effect of the model, while number of parameters and amount of computation evaluate the model size. Their formulas are as follows:

[0061]

[0062] Params=IK 2 C+C;

[0063] Where: T P is the defect sample that can be correctly detected, F P is the defect sample that is detected incorrectly, F N are defect samples that are not detected, AP is the integral of the PR curve for a certain type of defect, and mAP is the average AP of all types of defects; I is the input size, K is the convolution kernel size, and C is the output size.

[0064] In step 4, after completing the above steps, the model is evaluated. The specific steps are as follows:

[0065] S41. Comparison between the improved YOLOv5 network model and the original model YOLOv5;

[0066] S42, ablation experiment comparison;

[0067] Specific analysis results of S41 and S42 are given in subsequent examples.

[0068] The present invention provides a lightweight insulator defect detection method based on an improved YOLOv5 network, which has the following advantages:

[0069] It strengthens feature fusion, reduces the interference of noise signals, improves the detection of insulators in complex environments, and the added small target detection module effectively improves the detection accuracy of flashover defects. In addition, the size of the model is also reduced to a certain extent, which is conducive to future actual deployment. BRIEF DESCRIPTION OF THE DRAWINGS

[0070] Figure 1 The figure is a flowchart of the steps of a lightweight insulator defect detection method based on improved YOLOv5 in an embodiment of the present invention.

[0071] Figure 2(a) is a schematic diagram of the structure of the original model YOLOv5 in an embodiment of the present invention;

[0072] FIG2( b ) is a schematic diagram of the structure of the improved YOLOv5 network model in an embodiment of the present invention.

[0073] Figure 3 Schematic diagram of the Conv module structure in an embodiment of the present invention.

[0074] FIG4( a ) is a schematic diagram of the C3Ghost module structure in an embodiment of the present invention;

[0075] FIG4( b ) is a schematic diagram of the C3 module structure in an embodiment of the present invention.

[0076] Figure 5 Schematic diagram of the Ghostbottleneck module and Bottleneck module structure in an embodiment of the present invention.

[0077] Figure 6 Schematic diagram of the GhostConv module structure in an embodiment of the present invention.

[0078] Figure 7 Schematic diagram of the SPPF module structure in an embodiment of the present invention.

[0079] Figure 8 Schematic diagram of the CBAM module structure in an embodiment of the present invention.

[0080] Figure 9 Schematic diagram of the TriFusion structure in an embodiment of the present invention.

[0081] Figure 10 This is the training result of the original model in the embodiment of the present invention.

[0082] Figure 11 This is the training result of improving the YOLOv5 network model in the embodiment of the present invention. DETAILED DESCRIPTION

[0083] Example:

[0084] like Figure 1 As shown in FIG, a process of a lightweight insulator defect detection method based on improved YOLOv5 provided by the present invention includes the following steps:

[0085] S1. Obtain an insulator image dataset and preprocess the insulator images in the insulator image dataset to obtain an insulator image training set and an insulator image verification set;

[0086] S2. Improve the YOLOv5 network to enhance the recognition of insulators in complex environments and small targets such as insulator flashover defects, while reducing the model size to facilitate actual deployment.

[0087] S3. Using the obtained insulator image training set and insulator image verification set, the improved YOLOv5 network model is trained and verified to obtain a network model capable of identifying insulators and insulator defects;

[0088] S4. Model comparison and evaluation, improvement effect evaluation.

[0089] The step S1 includes the following steps:

[0090] S11. Collect the insulator images currently available for download and taken on-site to form the original dataset;

[0091] S12, selecting insulator images in the original data set one by one, removing invalid insulator images, and leaving clear and visible valid images, including insulator damage defects, insulator flashover defects, and normal insulator images;

[0092] S13. Randomly select some images, add Gaussian blur to the selected insulator images, and change the saturation and brightness of the selected insulator images to expand the insulator image dataset;

[0093] The beneficial effects of the above two-step solution S12 and S13 are as follows: while ensuring that the insulators in the image can be identified, the saturation and brightness of the image are changed and a noise signal is added to simulate the low visibility conditions of foggy days in real scenes. In this case, the trained model has strong robustness;

[0094] Furthermore, the calculation expression of Gaussian blur in S13 is as follows:

[0095]

[0096] Where: μ and ν represent the horizontal and vertical coordinates of the coordinates with the fuzzy center as the origin, μ 2 +ν 2 =r 2 represents the standard deviation, where r represents the blur radius and σ represents the standard deviation of the normal distribution;

[0097] S14. The dataset of the present invention consists of 3376 images. The images were then labeled using the LabelImg tool, with the following labels: damaged insulators are labeled as damaged, flashover insulators are labeled as flashover, and normal insulators are labeled as insulator. Finally, the dataset was divided into a training set and a validation set in an 8:2 ratio.

[0098] Furthermore, the S2 improves the YOLOv5 network to make it more suitable for insulator detection in complex environments, more conducive to detecting small targets, and with fewer model parameters;

[0099] As shown in Figure 2(a) and Figure 2(b), compared with the original model in Figure 2(a), the improvement of the improved model in Figure 2(b) is as follows:

[0100] S21, adding a fusion branch between the backbone network and the neck network, further extracting features and fusing them into the neck network to form a three-level fusion structure TriFusion;

[0101] S22: A CBAM attention module is embedded at the end of the backbone network. A CBAM attention module is embedded after the three-level fusion module TriFusion in S21. At the same time, a CBAM attention module is embedded after the last two-level fusion Cancat layer in the neck network.

[0102] S23, add a multi-scale fusion module for reinforced insulator small targets;

[0103] S24. Replace the C3 module in the original model with the lighter C3Ghost module.

[0104] Further, if Figure 3The figure shows the Conv module in the improved YOLOv5 network model in S2. In this module, the input feature map first undergoes a convolution operation, then a BN neural network, and finally a SiLU activation module. The function of the Conv module is to extract features and downsample to reduce the dimension of the input feature map.

[0105] Furthermore, the formula of the SiLU activation function is as follows:

[0106]

[0107] Furthermore, in Figure 2(b), Conv(6,2) represents a Conv convolution block with a convolution kernel of 6 and a stride of 2. Its main purpose is to extract features while reducing the dimension of the input feature map, and the height and width of the feature map are both halved; in Figure 2(b), Conv(3,2) represents a Conv convolution block with a convolution kernel of 3 and a stride of 2. Its main purpose is to extract features while reducing the dimension of the feature map, and the height and width of the feature map are both halved; in Figure 2(b), Conv(1,1) represents a Conv convolution block with a convolution kernel of 1 and a stride of 1. Its main purpose is to extract features without changing the input feature map.

[0108] Furthermore, as shown in FIG4(a), the C3Ghost module in the improved YOLOv5 network model described in S2 is used to extract features, increase the receptive field, and increase the network depth. Compared with the C3 module in the original model, it has a smaller number of parameters. The schematic diagram of the C3 module structure is shown in FIG4(b). The bottleneck module in the C3 module is the Bottleneck module, and the bottleneck module in the C3Ghost module is a lighter Ghostbottleneck module. Figure 5 It can be seen that the convolution module in the Bottleneck module is the Conv module, and the convolution module in the Ghostbottleneck module is the GhostConv module. The calculation formula of the Conv module and the GhostConv module is as follows:

[0109] GFLOP (Conv) =nhwCk 2 ;

[0110]

[0111] Where: n represents the number of feature maps, h represents the height of the feature map, w represents the width of the feature map, C represents the number of channels, k 2 and d 2 Represents linear operation, and s can be regarded as the compression ratio of the two operations. Its value is greater than 1. It can be seen that the operation amount of the GhostConv module is smaller than that of the Conv module, so the operation amount of the C3Ghost module is smaller than that of the C3 module.

[0112] Further, if Figure 6 The GhostConv module structure first uses a small number of convolution kernels to extract features from the input feature map, then further performs a cheaper linear transformation operation on this part of the feature map, and finally generates the final feature map through Cancat splicing; this method reduces the learning cost of non-critical features: that is, by combining a small number of convolution kernels with cheaper linear transformation operations instead of conventional convolution methods, it effectively reduces the demand for computing resources while not affecting the performance of the model.

[0113] Further, if Figure 7 The figure shows the SPPF module structure in the improved YOLOv5 network model in S2. The function of this module is to solve the problem of large target differences. It undergoes one convolution operation and three maximum pooling operations, and splices the feature maps after each operation, effectively reducing the situation where the feature maps have large differences.

[0114] Further, if Figure 8 The figure shows the CBAM module in the improved YOLOv5 network model in S2. The module includes a channel attention module and a spatial attention module, and its formula is:

[0115]

[0116] Where: F represents the feature map, M c represents channel-based attention, M s represents spatial-based attention, represents element-by-element multiplication, F′ represents the output feature map after channel attention, and F″ represents the output feature map after spatial attention;

[0117] M in c (F) can be expressed as follows:

[0118]

[0119] Where: σ represents the sigmoid activation function, W0 and W1 represent two weight-sharing neural networks, represents the average pooling operation, Represents the maximum pooling operation; this formula means using the global maximum pooling and global average pooling layers to reduce the dimensionality of the input to obtain two two-dimensional feature maps, and then obtain the channel attention coefficient through two fully connected layers, which is multiplied by the input to obtain the weighted output.

[0120] M in s (F′) can be expressed as follows:

[0121]

[0122] Where: Indicates splicing, f 7×7 Represents a 7×7 convolution kernel. This formula indicates that the average pooling operation and the maximum pooling operation are performed on the input feature map, and then the feature maps of the two operations are spliced ​​together. Then, a convolution operation is performed through a 7×7 convolution kernel, and finally the final output is obtained through the sigmoid activation function.

[0123] Furthermore, the Upsample module in the improved YOLOv5 network model in S2 is an upsampling module, which is used to expand the dimension of the image. The height and width of the feature map after the Upsample module are expanded to twice the original ones.

[0124] Furthermore, the calculation formula of the above sigmoid activation function is:

[0125]

[0126] Further, if Figure 9 As shown, the TriFusion module in the improved YOLOv5 network model in S2 is a three-level fusion module with three input ends, two of which come from the backbone network and one from the upper upsampling layer. The feature maps of the three input ends have the same dimension, the two feature maps from the backbone network have the same number of channels, and the feature map from the upper upsampling layer is twice the size of the other two.

[0127] Furthermore, the Cancat module in the improved YOLOv5 network model in S2 is a two-level fusion module with two input channels; the Cancat in the enhanced small target module has one input layer from the previous upsampling layer and the other from the backbone network, and the feature map dimensions and channel numbers in the two input layers are the same; the other two Cancat input layers, one from the previous downsampling layer and the other from the upsampling part of the neck network, and the feature map dimensions and channel numbers in the two input layers are the same.

[0128] The reasons for the improvement of the improved method in S2 and its advantages over the original model are as follows:

[0129] The addition of a fusion branch in S21 can effectively improve the accuracy of the information fused from the backbone network to the neck network. The three-level fusion structure can fuse the information in the shallow network of the backbone network with the information in the deep network of the neck network, thereby enhancing the location information of the features in the deep network and effectively improving the detection accuracy.

[0130] In the S22, a CBAM attention module is finally embedded in the backbone network. The CBAM module uses the characteristics of focusing on relevant features and filtering irrelevant features to effectively improve the effective information entering the neck network, filter invalid information, and effectively improve the final detection accuracy; a CBAM attention module is embedded after the three-level fusion module TriFusion. This is because the three-level feature map fusion increases the noise information. In addition, in S13, the present invention explains that Gaussian blur is added to some pictures, which increases the noise signal and further aggravates the superposition of the three-level fusion noise information. Therefore, the present invention embeds a CBAM attention module after the three-level fusion module TriFusion to effectively filter the noise signal; in the S23, a CBAM attention module is embedded after the last secondary fusion Cancat layer of the neck network. Since the Cancat module here fuses the information of the shallower convolutional layer, there are more noise signals, so a CBAM attention module is embedded to filter the noise signal;

[0131] The multi-scale fusion module for enhancing small insulator targets mentioned in S23 aims to add a 160×160-dimensional multi-level fusion structure to enhance the recognition capability of small defects such as insulator flashover defects. Its inputs come from the shallow network part of the backbone network. The feature map here has strong position information, which can better locate the insulator position; the other part comes from the 160×160-dimensional part generated by upsampling in the previous layer. Since this part is in the deeper part of the network, it has strong semantic information and can enhance the recognition of flashover defects.

[0132] The C3 module in the original model in S24 is replaced with a lighter C3Ghost module to reduce the model size. Through the improvements of S21-S23, the model is larger than the original model. By replacing C3 with C3Ghost, the model size can be effectively reduced while the detection accuracy does not change much, which is beneficial for future actual deployment.

[0133] Furthermore, the steps of S3 are as follows:

[0134] S31. Select appropriate equipment for model training and select appropriate experimental parameters before training. The model training equipment selected in the present invention is: the hardware environment uses Window11 64-bit, the CPU is AMD Ryzen 7 7745HX, the running memory is 16G, and the GPU is NVIDIA GeForce RTX 4060 8G; the software environment uses Python programming language, the deep learning framework is Pytorch, and the training platform is PyCharm.

[0135] The experimental parameters are: batch size is 8, initial learning rate is set to 0.01, momentum is set to 0.937, optimizer is SGD, and the number of training rounds is set to 200 rounds.

[0136] S32, model training. As the number of training rounds increases, the total loss gradually decreases. When it reaches 200 rounds, the total loss fluctuates steadily, indicating that the model has achieved the best detection effect on insulator defects.

[0137] S33, evaluation indicators:

[0138] The evaluation indicators of the present invention are precision (P), recall (R), mean average precision of all classes (mAP0.5), number of parameters (Params) and amount of computation GFLOPs. Precision, recall and mean average precision of all classes evaluate the detection effect of the model, while number of parameters and amount of computation evaluate the model size. Their formulas are as follows:

[0139]

[0140] Params=IK 2 C+C

[0141] Where: T P is the defect sample that can be correctly detected, F P is the defect sample that is detected incorrectly, F N are defect samples that are not detected, AP is the integral of the PR curve for a certain type of defect, and mAP is the average AP of all types of defects; I is the input size, K is the convolution kernel size, and C is the output size.

[0142] Furthermore, the S4 evaluates the model after completing steps S1-S3. The specific steps are as follows:

[0143] S41, improved YOLOv5 model compared with the original model YOLOv5;

[0144] As shown in Table 1 below, by comparing the original YOLOv5 model and the improved model in this embodiment, it can be seen that the improved model has a significant improvement over the original model. The accuracy of insulator defect detection is improved by 3.9% compared with the original model; the recall rate of insulator defect detection is improved by 3.4% compared with the original model; the average precision of all categories of insulator detection is improved by 3.2% compared with the original model. The improved model has a significantly improved effect on insulator defect detection compared with the original model.

[0145] The improved model reduces the model parameters by 1.7×10 compared with the original model. 6, reducing the number of parameters by 24.2%; in terms of computational complexity, the improved model reduces 1.6 and 10.1% of the original model. Compared with the original model, the improved model has a significantly reduced model size, which is conducive to the deployment of later embedded platforms;

[0146] Table 1 Comparison table of YOLOv5 original model and improved YOLOv5 network model

[0147]

[0148] Further, if Figure 10 This is the PR curve obtained by training the original model, such as Figure 11 To improve the PR curve obtained by model training, from the comparison of the two curves, the improved model has no obvious change in the accuracy of normal insulator detection compared with the original model, but the detection accuracy has reached more than 95%, which is of little significance for improving the accuracy of normal insulator detection; the improved model has an accuracy of 5.4% higher than the original model for damaged insulator detection from 70.6% to 76%; the improved model has an accuracy of 4.1% higher than the original model for flashover insulator detection from 78.4% to 82.5%; the improved model has an average accuracy of 3.2% higher than the original model for all categories from 82.2% to 85.4%; the improved model has a significantly improved effect on insulator defect detection in complex environments, and a significant improvement for small target defects such as flashover.

[0149] S42, ablation experiment comparison;

[0150] As shown in Table 2 below, in order to verify the improvement effect of the YOLOv5 algorithm in the present invention, this embodiment uses ablation experiments to verify various improved aspects. First, the first group is the unimproved original model YOLOv5. The second group adds a fusion branch between the backbone network and the neck network to the original model to form a three-level fusion structure; the third group embeds the CBAM attention module on the basis of the second group, and is respectively at the end of the backbone network, after the three-level fusion module, and after the last two-level fusion module; the fourth group introduces the enhanced small target module on the basis of the third group; the fifth group lightweights the model on the basis of the fourth group, and replaces the C3 module in the fourth group model with a lighter C3Ghost module; the experimental data are shown in Table 2 below;

[0151] Table 2 Experimental data table

[0152]

[0153] As shown in Table 2, after adding the fusion branch between the backbone network and the neck network, the detection accuracy only increased by 0.9% compared with the original model. However, after adding the CBAM attention module, the detection accuracy increased by 2.9% compared with the original model, which shows the importance of the CBAM attention module in filtering noise signals. After the fourth group added the enhanced small target module, the detection accuracy was further improved by 0.9%, and the detection accuracy increased by 3.8% compared with the original model, but the number of parameters increased by 4.6×10 5 The YOLOv5 model itself is relatively large and not conducive to deployment, so the fifth group made the model lightweight. The detection accuracy of the lightweight model only decreased by 0.6%, but the number of model parameters decreased by 2.16×10 6 , a decrease of 28.9%, which is beneficial to the later deployment while ensuring that the accuracy does not change much; from the above experimental results, it can be concluded that each step of improvement has achieved the expected effect, and the final improved model has also achieved the improvement of detection accuracy and the lightweight model.

[0154] The present invention provides a lightweight insulator defect detection method based on improved YOLOv5. The principle of the method is as follows: improvements are made on the basic framework of YOLOv5. The improvements mainly include: 1. adding a fusion branch between the backbone network and the neck network, and forming a three-level fusion structure in the neck network; 2. embedding a layer of CBAM module at the connection point between the backbone network and the neck network, and adding a CBAM attention module after the three-level fusion structure and the last two-level fusion structure; 3. adding a module to enhance small target detection; 4. replacing all C3 modules in the improved model with C3Ghost modules.

[0155] The improved method provided by the present invention strengthens feature fusion, reduces the interference of noise signals, and improves the detection of insulators in complex environments. The added small target detection module effectively improves the detection accuracy of flashover defects. In addition, the size of the model is also reduced to a certain extent, which is beneficial to future practical deployment.

Claims

1. A lightweight insulator defect detection method based on an improved YOLOv5 network is characterized by The following steps are involved: Step 1: Obtain an insulator image dataset and preprocess the insulator images in the insulator image dataset to obtain an insulator image training set and an insulator image verification set; Step 2: Improve the YOLOv5 network to enhance the recognition of insulators in complex environments and improve the recognition of small targets such as insulator flashover defects. Step 3: Use the obtained insulator image training set and insulator image verification set to train and verify the improved YOLOv5 network model to obtain a network model capable of identifying insulators and insulator defects; In step 2, the YOLOv5 network is improved as follows: 2.1: Add a fusion branch between the backbone network and the neck network, further extract features, and fuse them into the neck network to form a TriFusion module with a three-level fusion structure; 2.2: Integrating CBAM attention module: A CBAM attention module is embedded at the end of the backbone network, a CBAM attention module is embedded after the three-level fusion module TriFusion, and a CBAM attention module is embedded after the last two-level fusion Cancat layer of the neck network; 2.3: Add a multi-scale fusion module for reinforced insulator small targets; 2.4: Replace the C3 module in the original YOLOv5 network model with the lighter C3Ghost module.

2. The lightweight insulator defect detection method based on the improved YOLOv5 network according to claim 1 is characterized in that: It also includes step 4: model comparison and evaluation, and improvement effect evaluation.

3. The lightweight insulator defect detection method based on the improved YOLOv5 network according to claim 1 is characterized in that: The step 1 comprises the following steps: S1.

1. Collect insulator images to form the original dataset; S1.

2. Select the insulator images in the original data set one by one, remove the invalid insulator images, and leave the clear and visible valid images, including insulator damage defects, insulator flashover defects and normal insulator images. S1.

3. Randomly select some insulator images, add Gaussian blur to the selected insulator images, and change the saturation and brightness of the selected insulator images to expand the insulator image dataset; S1.

4. Use the LabelImg tool to label the images with the following labels: damaged insulators are labeled as damaged, flashover insulators are labeled as flashover, and normal insulators are labeled as insulator. Finally, divide the dataset into a training set and a validation set in a ratio of 8:

2.

4. The lightweight insulator defect detection method based on the improved YOLOv5 network according to claim 3 is characterized in that: In S1.3, the Gaussian blur calculation formula is as follows: ; Where: 、 Respectively represent the horizontal and vertical coordinates of the coordinates with the blur center as the origin, represents the standard deviation, where represents the blur radius, Represents the standard deviation of the normal distribution.

5. The lightweight insulator defect detection method based on the improved YOLOv5 network according to claim 1 is characterized in that: In step 2, the improved YOLOv5 network model includes a Conv module, which is used to extract features and downsample to reduce the dimension of the input feature map; The function of the C3Ghost module in the improved YOLOv5 network model is to extract features, increase the receptive field, and increase the network depth. The bottleneck module in the C3Ghost module is the lighter Ghostbottleneck module, and the convolution module in the Ghostbottleneck module is the GhostConv module. The computational formulas for the Conv module and the GhostConv module are as follows: ; ; ; Where: Indicates the amount of computation of the Conv module; Represents the computational complexity of the GhostConv module; represents the number of feature maps, represents the feature map height, represents the feature map width, Indicates the number of channels, and represents linear operations, It can be regarded as the compression ratio of the two operations, and its value is greater than 1; The GhostConv module first uses a small number of convolution kernels to extract features from the input feature map, then further performs simpler linear transformation operations on this part of the feature map, and finally generates the final feature map through Cancat splicing.

6. The lightweight insulator defect detection method based on the improved YOLOv5 network according to claim 5 is characterized in that: The improved YOLOv5 network model includes the SPPF module, which is used to solve the problem of large target differences; In the improved YOLOv5 network model, the CBAM attention module includes a channel attention module and a spatial attention module, and its formula is: ; Where: represents the feature map, represents channel-based attention, represents spatial-based attention, represents element-wise multiplication, represents the output feature map after channel attention, Represents the output feature map after spatial attention; Where, It can be expressed as the following formula: ; Where: represents the sigmoid activation function, and represents two neural networks with shared weights, represents the average pooling operation, Represents the maximum pooling operation; Indicates that an average pooling operation is performed on the input feature map, followed by a convolution operation; Indicates that the maximum pooling operation is performed on the input feature map, followed by a convolution operation; Indicates that the average pooling operation is performed on the input feature map, followed by two convolution operations; Indicates that the maximum pooling operation is performed on the input feature map, followed by two convolution operations; The above formula means that the input is reduced in dimension using the global maximum pooling and global average pooling layers to obtain two two-dimensional feature maps, and then the channel attention coefficient is obtained through two fully connected layers, which is multiplied by the input to obtain the weighted output; Where, It is expressed as the following formula: ; Where: Indicates splicing, represents a 7×7 convolution kernel, The above formula represents the average pooling operation and the maximum pooling operation on the input feature map, and then the feature maps of the two operations are spliced ​​together, and then convolution operation is performed through a 7×7 convolution kernel, and finally the final output is obtained through the sigmoid activation function; Furthermore, the calculation formula of the above sigmoid activation function is: ; Where: represents a natural constant; Represents the input feature map.

7. The lightweight insulator defect detection method based on the improved YOLOv5 network according to claim 6 is characterized in that: The improved YOLOv5 network model includes the Upsample module, which is an upsampling module that expands the dimension of the image. The feature map of the Upsample module is expanded to twice its original height and width respectively. The TriFusion module in the improved YOLOv5 network model is a three-level fusion structure with three inputs, two of which come from the backbone network and one from the previous upsampling layer. The feature maps of the three inputs have the same dimensions, the two feature maps from the backbone network have the same number of channels, and the feature map from the previous upsampling layer has twice the number of channels of the other two. The improved YOLOv5 network model includes the Cancat module, which is a two-stage fusion module with two input channels. The Cancat module in the enhanced small target module has one input layer from the previous upsampling layer and the other from the backbone network. The feature map dimensions and number of channels in the two input layers are the same. The other two Cancat input layers, one from the previous downsampling layer and the other from the upsampling part of the neck network, have the same feature map dimensions and number of channels.