Insulator defect detection method based on improved YOLOv8 model

By improving the YOLOv8 model and combining the PSA attention mechanism and the HAT hybrid attention transformer, the problem of low insulator detection accuracy and slow efficiency is solved, and efficient and accurate insulator defect detection is achieved.

CN118822985APending Publication Date: 2024-10-22CHANGZHOU UNIV

Patent Information

Application Number
CN202410900956.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-05
Publication Date
2024-10-22

AI Technical Summary

Technical Problem

The existing technology has low accuracy and slow detection efficiency for insulator defect detection. Traditional manual inspection is time-consuming and labor-intensive and has safety risks. Methods based on computer vision algorithms have low recognition accuracy and cannot accurately extract insulator features in complex backgrounds.

Method used

Using the improved YOLOv8 model, by adding the PSA attention mechanism in the BackBone module, and using the HAT hybrid attention transformer to improve the Head module, combined with the SOATA lightweight downsampling operation and the CSPNet structure, an efficient insulator defect detection method is formed.

Benefits of technology

Without significantly increasing the computational cost, the detection efficiency and accuracy are improved, and the aging, defect gaps and contamination types of insulators can be quickly and accurately identified.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118822985A_ABST
    Figure CN118822985A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of insulator devices, in particular to an insulator defect detection method based on an improved YOLOv8 model. The method comprises the following steps: acquiring an original image of an insulator, and preprocessing the original image to obtain a data set; an original YOLOv8 model is constructed, the original YOLOv8 model comprises a BackBone module, a Neck module and a Head module, the BackBone module is used for extracting multi-scale features, the Neck module is used for fusing the multi-scale features extracted by the BackBone module, the Head module is used for carrying out regression prediction on the multi-scale features fused by the Neck module, the BackBone module and the Head module are improved, and the improved YOLOv8 model is obtained; inputting the data set into the improved YOLOv8 model, training the improved YOLOv8 model until the loss function is converged, and obtaining a trained improved YOLOv8 model; and performing defect detection on the insulator by using the trained improved YOLOv8 model to obtain a defect type. According to the insulator defect detection method based on the improved YOLOv8 model, the detection efficiency and the detection precision are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of insulator devices, and in particular to an insulator defect detection method based on an improved YOLOv8 model. Background Art

[0002] The insulator device is a special insulating control component, which consists of two parts: an insulating part and a connecting metal. Its importance in the power system is self-evident. It can play a key role in supporting the conductor and preventing the current from grounding in the overhead line. Since the insulator is exposed to the external environment for a long time, it is easily affected by weather and natural factors, resulting in defects such as aging, breakage, and dirt. Once these defects occur, they are likely to cause power grid failures, resulting in power outages and inconvenience to people's daily lives. Therefore, regular maintenance and inspection of insulators are crucial to ensure the stability of the power system and people's electricity needs.

[0003] At present, defect detection of insulators includes manual inspection. Since there are many insulator inspection points and a wide coverage area, they are usually located in complex and changeable operating environments such as roads, rivers and forests. The traditional manual inspection of insulators is not only time-consuming and labor-intensive, inefficient, but also has safety hazards, and the inspection quality is difficult to guarantee. In this case, a method based on computer vision algorithm is proposed to automatically analyze and detect defects in insulator images to replace the traditional manual inspection method. Computer vision algorithm requires manual setting of target features, and different features need to be set for different targets. The recognition accuracy is low, which is easy to cause false detection or missed detection. The method based on traditional image processing cannot automatically extract the features of insulators, so it can only accurately identify defective insulators in specific environments. However, insulators are usually in complex background environments such as rivers, farmlands, construction sites and forests. This method cannot accurately extract and identify insulators. The existing technology has low defect detection accuracy and slow detection efficiency for insulators. Summary of the invention

[0004] The technical problem to be solved by the present invention is: in order to solve the technical problem of low defect detection accuracy and low detection efficiency of insulators in the prior art, the present invention provides an insulator defect detection method based on an improved YOLOv8 model, which improves the detection efficiency and detection accuracy.

[0005] The technical solution adopted by the present invention to solve the technical problem is: an insulator defect detection method based on an improved YOLOv8 model, the method comprising the following steps:

[0006] S1, obtaining an original image of an insulator, and preprocessing the original image to obtain a data set;

[0007] S2, constructing an original YOLOv8 model, the original YOLOv8 model includes: a BackBone module, a Neck module and a Head module, the Backbone module is used to extract multi-scale features, the Neck module is used to fuse the multi-scale features extracted by the Backbone module, the Head module is used to perform regression prediction on the multi-scale features fused by the Neck module, a PSA attention mechanism is added to the BackBone module, and a HAT hybrid attention transformer is used to improve the Head module to obtain an improved YOLOv8 model;

[0008] Wherein, the BackBone module includes a Conv unit, a C2f unit and a SPPF unit;

[0009] S3, inputting the data set into the improved YOLOv8 model, training the improved YOLOv8 model until the loss function converges, and obtaining a trained improved YOLOv8 model;

[0010] S4, use the trained improved YOLOv8 model to detect defects on insulators and obtain the defect type.

[0011] Further, specifically, in the step S1, the preprocessing step includes cropping, mirror reversal and labeling steps;

[0012] The data set includes a training set, a validation set and a test set.

[0013] Further, specifically, the Conv unit is improved by using the SOATA lightweight downsampling operation Adown unit, and is used as the Conv for feature extraction on the BackBone module backbone;

[0014] Further, specifically, a CSPNet structure is introduced on ELAN to form a GELAN unit to improve the C2f unit.

[0015] Further, specifically, the step S3 specifically includes the following steps:

[0016] S31. Use the training set to train the improved YOLOv8 model;

[0017] S32. Using the validation set to test the improved YOLOv8 model, so as to test whether the improved YOLOv8 model is trained accurately;

[0018] S33. Use the trained improved YOLOv8 model to detect the image samples in the test set, and evaluate the detection accuracy of the detection results of the test set.

[0019] Further, specifically, in step S33, the detection accuracy evaluation includes the calculation of precision and recall;

[0020] The calculation formula of the accuracy is:

[0021]

[0022] The calculation formula of the recall rate is:

[0023]

[0024] Among them, TP represents the prediction of positive targets as positive, FP represents the wrong prediction of negative targets as positive, FN represents the judgment of negative targets as negative, and TN represents the correct prediction of negative samples as negative.

[0025] Further, specifically, the HAT hybrid attention transformer fuses the self-attention mechanism and the channel attention mechanism;

[0026] The self-attention mechanism is based on a multi-target search algorithm that integrates a self-attention module and a channel attention module, wherein the self-attention module includes:

[0027] The first convolutional layer is used to reduce the feature dimension and reduce the computational load of self-attention;

[0028] Multi-head self-attention layer, used to capture long-distance dependencies between features after reducing feature dimensions;

[0029] The second convolutional layer is used to restore the feature dimension;

[0030] The first batch normalization layer is used for normalization in YOLOv8 model training and adds the output of the self-attention module to the initial input to form a residual connection;

[0031] The first activation function layer is used to map the input to the output;

[0032] The channel attention module includes:

[0033] The pooling layer performs global maximum pooling and global average pooling on an input feature map of size h*w*c in the spatial dimension to obtain two 1*1*c feature maps. Pooling is performed in the spatial dimension to compress the spatial size and obtain the results of global maximum pooling and global average pooling.

[0034] Shared learning layer, input the results of the pooling layer into the shared multi-layer perceptron for learning, and obtain two 1*1*c feature maps. The number of neurons in the first layer of the multi-layer perceptron is c / r, the activation function is RELU, and the number of neurons in the second layer of the multi-layer perceptron is c. The result output by the multi-layer perceptron is added, and then mapped by the Sigmoid activation function to finally obtain the channel attention weight matrix Mc.

[0035] Further, specifically, the types of defect detection include: aging, defect gap and / or dirtiness-dirtiness.

[0036] A computer device comprising:

[0037] processor;

[0038] A memory for storing executable instructions;

[0039] Wherein, the processor is used to read the executable instructions from the memory and execute the executable instructions to implement the insulator defect detection method based on the improved YOLOv8 model as described above.

[0040] A computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the processor implements the insulator defect detection method based on the improved YOLOv8 model as described above.

[0041] The beneficial effect of the present invention is that the insulator defect detection method based on the improved YOLOv8 model of the present invention can improve the performance of the YOLO model without significantly increasing the computational cost by adding an efficient partial PSA attention mechanism and improving the Head module using a HAT hybrid attention transformer, and has fast detection efficiency and high detection accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] The present invention is further described below in conjunction with the accompanying drawings and embodiments.

[0043] Figure 1 It is a flow chart of the method of embodiment 1 of the present invention.

[0044] Figure 2 This is a network structure diagram of the PSA attention mechanism of Example 1 of the present invention.

[0045] Figure 3 4 is a schematic diagram of the structure of the down sampling operation Adown unit according to the first embodiment of the present invention.

[0046] Figure 4 It is a schematic diagram of the three structures of CSPNet, ELAN and GELAN according to the first embodiment of the present invention.

[0047] Figure 5 It is a schematic diagram of the structure of a GELAN unit according to the first embodiment of the present invention.

[0048] Figure 6 It is a schematic diagram of the structure of the self-attention module and the channel attention module of Example 1 of the present invention.

[0049] Figure 7 This is a schematic diagram of an improved YOLOv8 model structure of the first embodiment of the present invention.

[0050] Figure 8 This is a schematic diagram of the training results of the improved YOLOv8 model of Example 1 of the present invention.

[0051] Fig. 9 Schematic diagram of insulator defect detection effect of embodiment 1 of the present invention

[0052] Fig.10 This is a schematic diagram of the computer device structure of the first embodiment of the present invention.

[0053] In the figure, 10 is a computer device; 1002 is a processor; 1004 is a memory; and 1006 is a transmission device. DETAILED DESCRIPTION

[0054] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, which only illustrate the basic structure of the present invention in a schematic manner, and therefore only show the components related to the present invention.

[0055] In the description of the present invention, it should be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", "clockwise", "counterclockwise", "axial", "radial", "circumferential" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention. In addition, features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, unless otherwise specified, "multiple" means two or more.

[0056] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0057] Example 1

[0058] The present application embodiment provides an insulator defect detection method based on an improved YOLOv8 model, such as Figure 1 As shown, the method comprises the following steps:

[0059] S1, obtaining the original image of the insulator and preprocessing the original image to obtain a data set;

[0060] S2, construct the original YOLOv8 model, which includes: BackBone module, Neck module and Head module. The Backbone module is used to extract multi-scale features, the Neck module is used to fuse the multi-scale features extracted by the Backbone module, and the Head module is used to perform regression prediction on the multi-scale features fused by the Neck module. The PSA attention mechanism is added to the BackBone module, and the HAT hybrid attention transformer is used to improve the Head module to obtain the improved YOLOv8 model.

[0061] S3, inputting the data set into the improved YOLOv8 model, training the improved YOLOv8 model until the loss function converges, and obtaining a trained improved YOLOv8 model;

[0062] S4, use the trained improved YOLOv8 model to detect defects on insulators and obtain the defect type.

[0063] In an embodiment, the preprocessing step in step S1 includes cropping, mirror reversal and labeling steps; the data set includes a training set, a validation set and a test set, such as dividing the data set into a training set, a validation set and a test set in a ratio of 8:1:1,

[0064] It should be noted that after labeling, the original images are divided into three categories, namely, aging, defective gaps, and dirty-filthy.

[0065] In an embodiment, Figure 2As shown in the figure, the PSA attention mechanism first regards the original image as a three-dimensional tensor, which is expressed as h*w*c, where h is the height, w is the bandwidth, and c is the number of channels. The features on the channel are evenly divided into two parts through 1×1 convolution. Then, only one part is input into the NPSA block composed of a multi-head self-attention module (MHSA) and a feed-forward network (FFN), that is, the transformer block is introduced. The two parts of the features are then connected and fused through 1×1 convolution. In addition, the dimensions of the query and key are assigned to half of the MHSA value of the multi-head self-attention module. Although both BatchNorm and LayerNorm can complete the normalization task, LayerNorm retains the size relationship between different features within a sample, which is crucial for NLP tasks, so RNN or Transformer uses LayerNorm and replaces LayerNorm with BatchNorm. To speed up the inference speed. And to avoid excessive overhead caused by the quadratic complexity of self-attention, the PSA attention mechanism is only placed after Stage 4 with the lowest resolution. In this way, the global representation learning capability can be introduced into the YOLOv8 model at a low computational cost, thereby enhancing the model capability and improving performance and detection efficiency.

[0066] In an embodiment, the BackBone module in step S2 includes a Conv unit, a C2f unit, and an SPPF unit; the Conv unit is improved by using the SOATA lightweight downsampling operation Adown unit, and is used as the Conv for feature extraction on the BackBone module backbone; the ADown unit reduces the complexity of the model by reducing the number of parameters, which helps to improve the operating efficiency of the model, especially in resource-constrained environments; although the ADown unit is intended to reduce the spatial resolution of the feature map, its design also focuses on retaining as much image information as possible so that the model can detect targets more accurately. The ADown unit is designed to have a certain degree of learnability and can be adjusted according to different data scenarios to optimize its performance. Using the ADown unit can not only reduce the size of the model, but also further improve the accuracy of target detection.

[0067] Furthermore, the SOATA lightweight downsampling operation Adown unit is used to improve the data processing process of the Conv unit, see Figure 3As shown in the figure, it includes: first, the input layer inputs the sample, then two-dimensional average pooling, and then it is divided into blocks, and the input variable is divided into two tensors x1 and x2 according to half the number of channels, followed by a convolution operation: the convolution layer is used to extract useful information from the feature map. x1 performs a transposed convolution operation, the size of the convolution kernel k is 3, the number of steps s for each movement is 2, and the number of 0s p filled on both sides is 0; x2 first performs a two-dimensional maximum pooling, and then a transposed convolution operation, the size of the convolution kernel k is 1, the number of steps s for each movement is 1, and the number of 0s p filled on both sides is 0.

[0068] It should be noted that in this embodiment, the stride of the convolution layer is adjusted to reduce the spatial dimension of the feature map. The above two tensors are the same except for the connection dimension. Concatention is performed to connect multiple tensors in a certain dimension. The features extracted by different branches are fused through the connection operation to form a larger tensor, and finally the data is output. Furthermore, the number of parameters in the convolution layer is optimized to reduce the complexity of the YOLOv8 model and further improve the performance of the improved model.

[0069] In some embodiments, the GELAN unit can also be used to improve the C2f unit. Specifically, on the basis of ELAN (EfficientLayer Aggregation Network), the CSPNet (Cross Stage Partial Network) structure is introduced to form the GELAN unit to improve the C2f unit. Both CSPNet and ELAN are designed with gradient path planning. It should be noted that in the architecture of CSPNet, the input is divided into two parts through a conversion layer, and then passes through any computing block respectively. After that, these branches are re-merged through concatenation and pass through the conversion layer again. ELAN uses stacked convolutional layers, in which the output of each layer is combined with the input of the next layer, and then undergoes convolution processing. ELAN adopts the concept of segmentation and reorganization of CSPNet, and introduces ELAN's hierarchical convolution processing method in each part. ELAN originally only used stacking of convolutional layers, but with a new architecture, any computing block can be used, which generalizes the capabilities of ELAN. The difference is that GELAN not only uses convolutional layers, but also any computing blocks, making the network more flexible and customizable according to different application requirements. The three structures of CSPNet, ELAN, and GELAN are as follows Figure 4 shown.

[0070] The GELAN unit can use any computational block. The GELAN unit is the main branch of YOLOv8. The processing flow is shown in Figure 5As shown, the GELAN unit is responsible for extracting features from the input image, generating a multi-scale feature map, and then integrating the multi-scale feature map into the detection head to obtain a prediction result, which includes the category and location information of the predicted target. In addition, in order to improve the accuracy of the results, the prediction results are post-processed, including but not limited to non-maximum suppression (NMS), to obtain the final detection result.

[0071] It should be noted that when splicing, it is necessary to ensure that the dimensions other than the connection dimension are consistent, so as to ensure the correctness of the splicing operation. In addition, the Concat operation also needs to pay attention to the order and alignment of the connection dimension to ensure that the tensors are correctly connected together. GELAN is designed with lightweight, inference speed and accuracy in mind to improve the overall performance of the model. The optionality of modules and partitions shown in the figure further increases the adaptability and customizability of the network. This structure of GELAN allows it to support multiple types of computing blocks, which makes it better adaptable to a variety of different computing needs and hardware constraints. GELAN's architecture provides a more general and efficient network for insulator defect detection that can adapt to tasks ranging from lightweight to complex deep learning while maintaining or enhancing computational efficiency and performance.

[0072] In the embodiment, the HAT hybrid attention transformer is set to improve the performance of single image super-resolution reconstruction. The HAT hybrid attention transformer integrates the self-attention mechanism and the channel attention mechanism to effectively integrate the global pixel information. Among them, the self-attention mechanism focuses on the relationship between each position inside the image, and the channel attention mechanism is used to focus on identifying more important channels. Further, the self-attention mechanism is used to focus on the relationship between each position inside the image to analyze each pixel in the photo and understand the relationship between these pixels to capture a wider range of contextual information while maximizing efficiency. While minimizing the computational cost of the receptive field, methods such as scaling convolution and dilated convolution use bilinear sampling to adjust the size of the input feature map, which inevitably leads to information loss. Channel attention is used for global information to solve the limitations of CNN in processing images, especially in terms of representation capabilities and processing long-distance dependencies. The self-attention mechanism enhances the information interaction between windows and reduces blocking artifacts in intermediate features.

[0073] like Figure 6As shown in the figure, the HAT hybrid attention transformer integrates the self-attention module and the channel attention module based on the multi-target search algorithm, where the self-attention module includes: the first convolution layer, which is used to reduce the feature dimension and reduce the computational load of the self-attention; the multi-head self-attention layer, which is used to capture the long-distance dependency between features after reducing the feature dimension; the second convolution layer, which is used to restore the feature dimension; the first batch normalization layer, which is used for normalization processing in YOLOv8 model training, and adds the output of the self-attention module to the initial input to form a residual connection; the first activation function layer, which is used to map the input to the output end, uses the activation function RELU, and provides a nonlinear network

[0074] The channel attention module includes:

[0075] The pooling layer performs global maximum pooling and global average pooling on an input feature map of size h*w*c in the spatial dimension to obtain two 1*1*c feature maps. When performing pooling in the spatial dimension, the spatial size is compressed to obtain the results of global maximum pooling and global average pooling. The obtained results can facilitate the subsequent learning of channel features.

[0076] Shared learning layer, input the results of the pooling layer into the shared multi-layer perceptron (MLP) for learning, and obtain two 1*1*c feature maps. The number of neurons in the first layer of MLP is c / r, the activation function is RELU, and the number of neurons in the second layer is c; (based on the characteristics of the MLP learning channel dimension and the importance of each channel), the result of the MLP output is added, and then mapped by the Sigmoid activation function to finally obtain the channel attention weight matrix Mc.

[0077] It should be noted that different attention modules may focus on different aspects of the input data. The self-attention module focuses on the spatial dimension, and it is most important to identify multiple target areas in the image; while the convolution focuses on the channel dimension, and it is most critical to determine the channel of the target feature. By integrating the self-attention module and convolution, the improved YOLOv8 model can simultaneously identify and utilize key information in the input data from multiple angles, thereby activating more input pixels to improve the accuracy of the detection results.

[0078] The search for the optimal architecture α is adopted based on a multi-objective search algorithm, wherein the search for the optimal architecture α is formulated as a two-stage optimization problem.

[0079] The first stage is supernet training. The architecture search space A is encoded in the supernet and represented as N(A,W). Each candidate architecture a∈A shares its weight in W. In the first stage, the supernet weight W is optimized by:

[0080] W = arg w minl train(N(A,W))

[0081] Where L represents the training loss.

[0082] The prior distribution of Г(A) is important. In order to achieve the goal of searching for architectures with arbitrary branches of different resolutions, this prior is predefined during the training process of the supernet. Since subnets with more branches contain subnets with fewer branches, subnets with more branches are empirically set to have a higher sampling probability.

[0083] ρ<ρ i+1 ,i∈1,2,3

[0084] Where ρ represents the sampling of the architecture probability containing i branches. The other components in subnet α are sampled from a uniform distribution.

[0085] After the supernet training is completed, the second stage is to search for the architecture by ranking the accuracy and latency of each subnet α∈A. The architecture search problem is converted into a standard multi-objective optimization (MOP) problem. The formulation consists of decision variables, objective functions, and constraints. The optimization goal is as follows:

[0086] maximize y=f(a)=(f 1 (a),f 2 (a),...,f k (a))

[0087] Ste(x)=(e 1 (a),e 2 (a),...,e m (a))≤0

[0088] among x=(a 1 ,a 2 ,...,a n )∈A

[0089] y=(y 1 ,y 2 ,...y k )∈Y

[0090] Where a represents the decision vector, that is, the searched network architecture, and y represents the target vector, that is, mioU and delay. A represents the search space formed by the decision vector a, and Y represents the target space formed by the target vector y. The constraint e(x)≤0 determines the feasible value range of the decision vector. In order to ensure that the searched architecture is valid, the following constraints are set: the number of paths in each subnet needs to be greater than 0; for subnets containing multiple paths, the downsampling positions should be different; at the downsampling position, jump connections cannot be selected; the memory usage of the subnet during training cannot exceed the hardware limit.

[0091] The search for the optimal architecture α is optimized for multiple objectives (e.g., latency and mioU), and is able to find the Pareto optimal architecture with any number of branches in a single search. These models search for the best mixture of lightweight convolutional layers and memory-efficient self-attention layers between branches of different resolution libraries, and fuse them into high resolution, which can achieve a dual improvement in efficiency and effect, significantly improving detection efficiency and detection accuracy.

[0092] In an embodiment, step S3 specifically includes the following steps:

[0093] S31. Use the training set to train the improved YOLOv8 model;

[0094] S32. Using the validation set to test the improved YOLOv8 model, so as to test whether the improved YOLOv8 model is trained accurately;

[0095] S33. Use the trained improved YOLOv8 model to detect the image samples in the test set, and evaluate the detection accuracy of the detection results of the test set.

[0096] In an embodiment, the detection accuracy evaluation in step S33 includes calculation of precision and recall;

[0097] The calculation formula for accuracy is:

[0098]

[0099] The calculation formula for recall is:

[0100]

[0101] Among them, TP represents the prediction of positive targets as positive, FP represents the wrong prediction of negative targets as positive, FN represents the judgment of negative targets as negative, and TN represents the correct prediction of negative samples as negative.

[0102] It should be noted that the accuracy rate is used to evaluate the precision of the network, which reflects the ability of the network model to correctly classify positive samples. The recall rate is used to evaluate the recall ability of the network, which reflects whether the network model can detect all positive samples.

[0103] In an embodiment, the types of defects detected include: aging, defect gaps, and / or dirty-dirty.

[0104] Test verification:

[0105] Build the experimental environment: The experimental platform uses the PyTorch2.3.1 framework, the GPU used is Nvidia GeForceRTX4060, and the Python version is 3.9.19.

[0106] Take the Conv unit improved by SOATA lightweight downsampling operation Adown unit as an example, and use it as the Conv unit for feature extraction on the BackBone module backbone. The improved YOLOv8 model is shown in Figure 7 As shown in the figure, set the training parameters: batch size = 32, initial setting of learning rate lr = 0.001, and number of training rounds epoch = 500.

[0107] The sample data in the test set is used as input, and the improved model performs target detection and outputs the results to objectively evaluate the performance of the improved YOLOv8 model. The calculation of the mAP value is based on the precision-recall curve. For each detection target category, AP is the calculated value of the area under the precision-recall curve. The AP values ​​of all categories are averaged to get the mAP value. mAP comprehensively considers the performance of the model in different categories and provides a comprehensive metric that can intuitively reflect the overall performance of the model. Calculation of precision P and recall R

[0108] During the training of the improved YOLOv8 model, the P, R and mAP curves are as follows: Figure 8 As shown in the figure, the P curve and the R curve gradually rise during the training process. The slight fluctuation may be due to the imbalance of training data, and then it tends to be flat. The loss of the model also converges in this process. The P value is finally 0.926, the R value is 0.788, and the mAP of the model reaches 0.85. Both values ​​have been significantly improved.

[0109] Precision Recall MAP Original YOLOv8 model 0.912 0.767 0.835 Improved YOLO v8 model 0.926 0.788 0.85

[0110] After multiple training verifications, the network model improved based on the YOLOv8 algorithm has achieved good results in insulator detection. Fig. 9 As shown, it is possible to successfully detect types of aging, damage, and contamination with high detection efficiency and accuracy.

[0111] In summary, the insulator defect detection method based on the improved YOLOv8 model of the present invention, by adding an efficient partial PSA attention mechanism and improving the Head module using the HAT hybrid attention transformer, can improve the performance of the YOLO model without significantly increasing the computational cost, and has fast detection efficiency and high detection accuracy.

[0112] Example 2

[0113] An embodiment of the present application provides a computer device, which includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by the processor to implement an insulator defect detection method based on an improved YOLOv8 model as provided in the above method embodiment.

[0114] Fig.10 The hardware structure diagram of a device for implementing an insulator defect detection method based on an improved YOLOv8 model provided in an embodiment of the present application is shown. The device may participate in constituting or include the apparatus or system provided in an embodiment of the present application. Fig.10 As shown, the computer device 10 may include one or more processors 1002 (the processor may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 1004 for storing data, and a transmission device 1006 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Fig.10 The structure shown is only for illustration and does not limit the structure of the above electronic device. Fig.10 More or fewer components as shown, or with Fig.10 Different configurations are shown.

[0115] It should be noted that the one or more processors and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the computer device 10 (or mobile device). As described in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).

[0116] The memory 1004 can be used to store software programs and modules of application software, such as a program instruction / data storage device corresponding to an insulator defect detection method based on an improved YOLOv8 model in an embodiment of the present application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory 1004, that is, implementing the above-mentioned method. The memory 1004 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 1004 may further include a memory remotely arranged relative to the processor, and these remote memories may be connected to the computer device 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0117] The transmission device 1006 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the computer device 10. In one example, the transmission device 1006 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 1006 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0118] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer device 10 (or mobile device).

[0119] Example 3

[0120] An embodiment of the present application also provides a computer-readable storage medium, which can be set in a server to store at least one instruction or at least one program related to an insulator defect detection method based on an improved YOLOv8 model in a method embodiment. The at least one instruction or the at least one program is loaded and executed by the processor to implement an insulator defect detection method based on an improved YOLOv8 model provided in the above method embodiment.

[0121] Optionally, in this embodiment, the storage medium may be located in at least one of the multiple network servers of the computer network. Optionally, in this embodiment, the storage medium may include, but is not limited to, various media that can store program codes, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.

[0122] Example 4

[0123] The embodiment of the present invention also provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. The processor of the computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes an insulator defect detection method based on an improved YOLOv8 model provided in the above various optional embodiments.

[0124] It should be noted that the above-mentioned sequence of the embodiments of the present application is for description only and does not represent the advantages and disadvantages of the embodiments. The above-mentioned specific embodiments of the present application are described. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0125] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, equipment and storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0126] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.

[0127] Based on the above ideal embodiments of the present invention, the relevant staff can make various changes and modifications without departing from the technical concept of the present invention through the above description. The technical scope of the present invention is not limited to the contents of the specification, and its technical scope must be determined according to the scope of the claims.

Claims

1. An insulator defect detection method based on an improved YOLOv8 model, It is characterized in that The method comprises the following steps: S1, obtaining an original image of an insulator, and preprocessing the original image to obtain a data set; S2, constructing an original YOLOv8 model, the original YOLOv8 model includes: a BackBone module, a Neck module and a Head module, the Backbone module is used to extract multi-scale features, the Neck module is used to fuse the multi-scale features extracted by the Backbone module, the Head module is used to perform regression prediction on the multi-scale features fused by the Neck module, a PSA attention mechanism is added to the BackBone module, and a HAT hybrid attention transformer is used to improve the Head module to obtain an improved YOLOv8 model; Wherein, the BackBone module includes a Conv unit, a C2f unit and a SPPF unit; S3, inputting the data set into the improved YOLOv8 model, training the improved YOLOv8 model until the loss function converges, and obtaining a trained improved YOLOv8 model; S4, use the trained improved YOLOv8 model to detect defects on insulators and obtain the defect type.

2. The insulator defect detection method based on the improved YOLOv8 model according to claim 1, It is characterized in that In step S1, the preprocessing step includes cropping, mirror reversal and labeling steps; The data set includes a training set, a validation set and a test set.

3. The insulator defect detection method based on the improved YOLOv8 model according to claim 1, It is characterized in that The SOATA lightweight downsampling operation Adown unit is used to improve the Conv unit and used as the Conv for feature extraction on the BackBone module backbone.

4. The insulator defect detection method based on the improved YOLOv8 model according to claim 1, It is characterized in that The CSPNet structure is introduced on ELAN to form the GELAN unit to improve the C2f unit.

5. The insulator defect detection method based on the improved YOLOv8 model according to claim 3 or 4, It is characterized in that The step S3 specifically includes the following steps: S31. Use the training set to train the improved YOLOv8 model; S32. Using the validation set to test the improved YOLOv8 model, so as to test whether the improved YOLOv8 model is trained accurately; S33. Use the trained improved YOLOv8 model to detect the image samples in the test set, and evaluate the detection accuracy of the detection results of the test set.

6. The insulator defect detection method based on the improved YOLOv8 model according to claim 1, It is characterized in that In step S33, the detection accuracy evaluation includes the calculation of precision and recall; The calculation formula of the accuracy is: The calculation formula of the recall rate is: Among them, TP represents the prediction of positive targets as positive, FP represents the wrong prediction of negative targets as positive, FN represents the judgment of negative targets as negative, and TN represents the correct prediction of negative samples as negative.

7. The insulator defect detection method based on the improved YOLOv8 model according to claim 1, It is characterized in that The HAT hybrid attention transformer integrates the self-attention mechanism and the channel attention mechanism; The self-attention mechanism is based on a multi-target search algorithm that integrates a self-attention module and a channel attention module, wherein the self-attention module includes: The first convolutional layer is used to reduce the feature dimension and reduce the computational load of self-attention; Multi-head self-attention layer, used to capture long-distance dependencies between features after reducing feature dimensions; The second convolutional layer is used to restore the feature dimension; The first batch normalization layer is used for normalization in YOLOv8 model training and adds the output of the self-attention module to the initial input to form a residual connection; The first activation function layer is used to map the input to the output; The channel attention module includes: The pooling layer performs global maximum pooling and global average pooling on an input feature map of size h*w*c in the spatial dimension to obtain two 1*1*c feature maps. Pooling is performed in the spatial dimension to compress the spatial size and obtain the results of global maximum pooling and global average pooling. Shared learning layer, input the results of the pooling layer into the shared multi-layer perceptron for learning, and obtain two 1*1*c feature maps. The number of neurons in the first layer of the multi-layer perceptron is c / r, the activation function is RELU, and the number of neurons in the second layer of the multi-layer perceptron is c. The result output by the multi-layer perceptron is added, and then mapped by the Sigmoid activation function to finally obtain the channel attention weight matrix Mc.

8. The insulator defect detection method based on the improved YOLOv8 model according to claim 1, It is characterized in that The types of defects detected include: aging, defect gaps and / or dirtiness.

9. A computer device, It is characterized in that include: processor; A memory for storing executable instructions; The processor is used to read the executable instructions from the memory and execute the executable instructions to implement the insulator defect detection method based on the improved YOLOv8 model as described in any one of claims 1 to 8.

10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor implements the insulator defect detection method based on the improved YOLOv8 model as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Smart phone panel surface defect detection method based on YOLO V5 model

    CN115861204A

  • YOLOv8 target detection method based on attention mechanism and multi-scale feature fusion

    CN116883801A

  • YOLOv7 vehicle identification method based on improved HAT attention mechanism

    CN117253204A

  • Temperature vision-based intelligent detection method and apparatus, and electronic device

    WO2023092759A1

Cited By

  • Cherry tomato maturity detection method based on YOLOv8 improved algorithm

    CN119832221A

  • Marine organism detection method and system based on two-stage multi-target tracking

    CN119887854A

  • Steel wire rope defect detection method, steel wire rope defect detection device, medium and equipment

    CN121033003A

  • Railway fastener elastic backing plate defect detection method based on improved YOLOv8

    CN121955018A