Power transmission line cotter defect detection method based on improved YOLOv8

By improving the YOLOv8 model, combining image preprocessing, data enhancement and attention mechanisms, the error detection and missed detection problems of opening pin detection in the prior art under small targets and complex background conditions are solved, achieving more efficient and accurate detection effects.

CN119832212AActive Publication Date: 2025-04-15YUNNAN UNIV
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411895049.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-21
Publication Date
2025-04-15
Estimated Expiration
2044-12-21

AI Technical Summary

Technical Problem

The existing open pin defect detection algorithm is prone to mis-checking or missed under small targets and complex background conditions, and is complex in calculations and slow in detection speed, making it difficult to effectively detect fine-grained defects in the opening pins of the transmission line.

Method used

The improved YOLOv8 model is adopted to increase the relative size of the opening pin in the image through image preprocessing and data enhancement, and a small object detection head P2, P-C2f module, MCA attention module and WIOU loss function are introduced into the model to improve the detection accuracy of the model for small and fine-grained targets.

Benefits of technology

The accuracy and speed of opening pin detection are improved, the model's detection ability of small targets and fine-grained targets is enhanced, the error detection rate and missed detection rate are reduced, and the detection efficiency and accuracy are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119832212A_ABST
    Figure CN119832212A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of target detection, and discloses a power transmission line cotter defect detection method based on improved YOLOv8, and the method comprises the steps: carrying out the image preprocessing, constructing a PMW-YOLOv8 model, extracting the image features of cotter defects, obtaining the fusion features, and generating the detection result of the cotter defects. According to the invention, the high-resolution image is segmented into a plurality of sub-images, the relative size of the cotter pin in the image is increased, and the detection precision of the cotter pin is improved; in the PMW-YOLOv8 model, a small target detection head is added, and the edge information and detail features of the small target are fully utilized to improve the detection precision of the small target; one MCA attention module is integrated at the front end of each of the four target detection heads P2-P5, and the extracted features are further enhanced, so that the small target detection and classification capability of the model is improved; a polarization self-attention mechanism is introduced to construct a P-C2f module, and the P-C2f module is integrated into the model, so that the extraction and processing of the model on fine-grained information are enhanced, and the detection precision of the model on a cotter fine-grained target is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of target detection technology, and specifically to a method for detecting cotter pin defects in a power transmission line based on improved YOLOv8. Background Art

[0002] Target detection aims to solve the problem of determining the category and location of objects. In the traditional machine learning era, there were methods such as HOG+SVM, which are now mostly replaced by deep learning models. Small target detection is challenging due to the small number of pixels, weak features, and difficulty in labeling. Although multi-scale feature fusion and data set enhancement can improve the efficiency of small target detection, they have limited effect on cotter pins, and background information also has an adverse effect on their detection. It is difficult to distinguish similar subcategories with fine-grained recognition. There are methods based on positioning and classification subnetworks, end-to-end feature encoding, and the use of auxiliary information. The former two have disadvantages such as large workload when used for cotter pin detection.

[0003] The mainstream of existing split pin defect detection is deep learning method, which is divided into single-stage and multi-stage cascade detection algorithms. Single-stage algorithms such as automatic detection models focus on the missing split pins, and are optimized based on YOLOv5 to improve speed and accuracy. However, single-stage algorithms are affected by target size, deformation, etc., and are prone to misdetection or missed detection when the target is small and the background is complex, and there is a problem of fine granularity. Multi-stage cascade algorithms first generate candidate regions by region proposal network, and then classify and regress. For example, CSSAdet combines attention mechanism detection, two-stage cascade detectors and cascade network-based methods have achieved certain results, but due to the small target, fine granularity and background interference of split pins, their applicability is limited, and the calculation is complex and the detection speed is slow. At present, split pin defect detection algorithms have their own shortcomings. Single-stage detection speed is fast but the accuracy is low. Although multi-stage cascade has advantages in accuracy, it is limited by the scene.

[0004] In summary, a new technical solution for the transmission line cotter pin defect based on improved YOLOv8 is urgently needed to overcome the above technical problems. Summary of the invention

[0005] The purpose of this application is to provide a transmission line split pin defect detection method based on improved YOLOv8 to solve the technical problems raised in the above background technology.

[0006] To achieve the above objectives, the present application discloses the following technical solutions: A method for detecting cotter pin defects in power transmission lines based on improved YOLOv8, comprising:

[0007] Step 1: performing image preprocessing and data enhancement; wherein the image preprocessing is used to adjust the image size, and the data enhancement is used to increase the relative size of the cotter pin in the image;

[0008] Step 2: Construct a PMW-YOLOv8 model; wherein the PMW-YOLOv8 model is used to detect cotter pin defects in transmission lines, and the PMW-YOLOv8 model at least includes a small target detection head P2, a P-C2f module integrated with a PSA module, an MCA attention module and a WIOU loss function, and the MCA attention module is integrated in front of each detection head;

[0009] Step 3: Train the PMW-YOLOv8 model to extract image features of split pin defects;

[0010] Step 4: Fusing and enhancing the image features to obtain the fused features;

[0011] Step 5: Storing the fusion features into the PMW-YOLOv8 model to complete model construction, and running the PMW-YOLOv8 model to generate the detection results of the transmission line split pin defects.

[0012] Preferably, the step one specifically comprises: adjusting the input image to a uniform preset size, dividing the resized image into a number of sub-images with equal pixels, and excluding sub-images without cotter pins based on a preset cropping overlap ratio.

[0013] Preferably, the small target detection head P2 is arranged in front of three detection heads P3 to P5 of different sizes of the original YOLOv8 model, and the operation of the small target detection head P2 is specifically as follows:

[0014] After the C2f module of the original YOLOv8 model outputs a feature map of size 80×80×256, the feature map is upsampled to output a feature map of size 160×160×128, and the 160×160×128 feature map is fused with the shallow feature jump connection in the backbone network to generate a large-size feature map.

[0015] Preferably, the P-C2f module is specifically:

[0016] The channel self-attention mechanism of PSA is used to compress information, and the spatial self-attention mechanism of PSA retains high-resolution information. The channel self-attention mechanism and the spatial self-attention mechanism are arranged in series to obtain a complete PSA module. The PSA module is integrated with the original C2f module to obtain a P-C2f module.

[0017] Preferably, the P-C2f module is used to replace part of the C2F modules in the original YOLOv8.

[0018] Preferably, the MCA attention module receives the features extracted and processed by the backbone network, and based on a preset three-branch architecture, performs modeling attention in channel, width and height dimensions respectively.

[0019] Preferably, the WIOU loss function is constructed based on the center point of the detection box, the center point of the target box, and the width and height of the joint area.

[0020] Preferably, the image feature extraction process includes:

[0021] The preprocessed image is input into the backbone network, and shallow features and deep features are extracted based on the increase in the number of layers of the backbone network.

[0022] Preferably, the fusion process of the fusion features includes:

[0023] Performing a splicing operation on the extracted shallow features and deep features in the neck network;

[0024] The spliced ​​features are enhanced by the P-C2f module and the MCA attention module, and then sent to the decoupled detection head for target frame detection and classification recognition, respectively. Each detection head outputs feature maps of two scales, classification and regression. The feature maps of the four detection heads are spliced ​​to obtain a detection frame, which is filtered and restored to the original image for detection.

[0025] Preferably, the running of the PMW-YOLOv8 model to generate the detection result of the transmission line split pin defect is specifically:

[0026] Real-time images are acquired and step one and step five are executed to perform cotter pin defect detection for power transmission lines. The detection results include whether the cotter pin is normal, the cotter pin is loose, and the cotter pin disappears.

[0027] Beneficial effects: The power transmission line split pin defect detection method based on improved YOLOv8 of the present application, in response to the small target problem faced by the existing split pin detection method, divides the high-resolution image into several sub-images in the data processing stage of model training, increases the relative size of the split pin in the image, and improves the detection accuracy of the split pin; in the PMW-YOLOv8 model, adds a small target detection head to make full use of the edge information and detail features of the small target, thereby improving the detection accuracy of the small target; an MCA attention module is integrated at the front end of each of the four target detection heads P2-P5 to further enhance the extracted features, thereby improving the model's detection and classification capabilities for small targets; in response to the fine-grained problem in split pin detection, a polarized self-attention mechanism (PSA) is introduced on the basis of the C2f module, and a P-C2f module is proposed and integrated into the model, so as to strengthen the model's extraction and processing of fine-grained information and improve the model's detection accuracy for split pin fine-grained targets. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.

[0029] Figure 1 A flowchart of a method for detecting cotter pin defects in a power transmission line based on improved YOLOv8 provided in an embodiment of the present application;

[0030] Figure 2 This is a structural block diagram of the PMW-YOLOv8 model provided in an embodiment of the present application. DETAILED DESCRIPTION

[0031] The technical solutions in the embodiments of the present application are described clearly and completely below. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present application.

[0032] In this article, the term "comprising" is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of more restrictions, the elements defined by the sentence "comprising..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0033] Split pins account for a small proportion of conventional inspection images, and the difference between their defect morphology and normal state is subtle, making the defect detection task difficult. This embodiment uses a cropping data enhancement method for small targets to increase the relative size of small targets. This method not only simulates the effect of initial target area screening in multi-stage detection, but also its application is limited to the data processing stage, thereby ensuring that the detection speed is not affected and effectively improving the detection accuracy. At the same time, a PMW-YOLOv8 split pin detection model is constructed. The model uses the YOLOv8 model as the backbone network. By adding an attention mechanism, the network's attention to important target areas is enhanced to solve the low-precision problem of the single-stage detection algorithm; in addition, this embodiment also optimizes the loss function to reduce the adverse effects of data quality fluctuations on the training process, thereby further improving the stability and performance of the model.

[0034] This embodiment discloses Figure 1A transmission line split pin defect detection method based on improved YOLOv8 is shown, comprising:

[0035] Step 1: Perform image preprocessing and data enhancement; image preprocessing is used to adjust the image size, and data enhancement is used to increase the relative size of the cotter pin in the image;

[0036] Step 2: Construct a PMW-YOLOv8 model; wherein the PMW-YOLOv8 model is used to detect cotter pin defects in transmission lines. The PMW-YOLOv8 model at least includes a small target detection head P2, a P-C2f module integrated with a PSA module, an MCA attention module and a WIOU loss function, and the MCA attention module is integrated in front of each detection head;

[0037] Step 3: Train the PMW-YOLOv8 model to extract the image features of the split pin defect;

[0038] Step 4: Fuse and enhance image features to obtain fused features;

[0039] Step 5: Store the fused features into the PMW-YOLOv8 model to complete the model construction, and run the PMW-YOLOv8 model to generate the detection results of the transmission line cotter pin defects.

[0040] The present invention improves the YOLOv8 structure and proposes a new PMW-YOLOv8 model. The structure of the PMW-YOLOv8 model is as follows: Figure 2 shown.

[0041] First, the input power inspection images are preprocessed and resized to 640×640×3 to ensure that all images maintain the same size when input into the neural network. After the preprocessed images enter the backbone network, the backbone network composed of convolutional layers, pooling layers, and activation functions will extract image features. As the number of backbone network layers increases, deeper image features are extracted.

[0042] Then, the extracted deep features are compared with the shallow features (such as Figure 2 At the first Concat in the image, the deep information of the Upsample layer is fused with the shallow information of the C2f layer) and the concatenation (Concat) operation is performed in the neck network to achieve the purpose of feature fusion, thereby enhancing the model's detection performance for targets of different sizes. Finally, the fused features are enhanced by the P-C2f module and the MCA attention module, and then sent to the decoupled detection head for target box detection and classification recognition, respectively. Each detection head outputs feature maps of two scales, classification and regression. The feature maps of the four detection heads are concatenated to obtain the detection frame of the model, which is then filtered and restored to the original image to obtain the final detection result.

[0043] like Figure 2 As shown in the figure, in order to improve the model's ability to detect small targets, the improved model adds a small target detection head P2 on the basis of the YOLOv8 structure. It receives shallower large-size feature maps, thereby utilizing shallower image features. Among these shallow features, the contours and of small targets are retained, thereby improving its detection accuracy for small targets. At the same time, based on the new P-C2f module, the original C2f module is replaced by the P-C2f module. The P-C2f module is composed of a PSA module added to the original structure of C2f. The PSA module can achieve fine control on the screening and enhancement of feature information on the basis of effectively preventing information loss, thereby handling complex tasks in the process of cotter pin defect detection and improving detection accuracy. In order to improve the model's fine-grained detection capability for cotter pin defects, the MCA attention module is added to the added small target detection head, and the feature information extracted by the P-C2f module is sent to the MCA module. The module can fully extract the correlation between different dimensions, calibrate the attention weights generated by different dimensions, and thus extract and output more refined features, further improving the detection accuracy and classification accuracy of cotter pin small targets.

[0044] Specifically, step one is as follows: adjusting the input image to a uniform preset size, dividing the resized image into a number of sub-images with equal pixels, and excluding sub-images without cotter pins based on a preset cropping overlap ratio.

[0045] Specifically, the small target detection head P2 is set in front of the three detection heads P3 to P5 of different sizes of the original YOLOv8 model, and the operation of the small target detection head P2 is specifically as follows:

[0046] After the C2f module of the original YOLOv8 model outputs a feature map of size 80×80×256, the feature map is upsampled to output a feature map of size 160×160×128, and the 160×160×128 feature map is fused with the shallow feature jump connection in the backbone network to generate a large-size feature map.

[0047] In this embodiment, the small target detection head P2 constitutes a small target detection layer. The design of YOLOv8 has three layers of feature mapping, and three detection heads of different sizes (i.e., P3-P5) are used to detect targets of different sizes. However, since the open pin targets on the transmission line are relatively small, the deep features obtained through continuous downsampling contain less feature information about such small targets, which reduces the algorithm's detection accuracy for open pin targets.

[0048] Therefore, in PMW-YOLOv8, based on the original YOLOv8 model architecture, a new small target detection head P2 and the corresponding detection layer are added. After the original model C2f module outputs a feature map of size 80×80×256, the feature map is upsampled again to increase the size of the feature map, and the output feature map of size 160×160×128 is fused with the shallow feature jump connection in the backbone network to generate a large-size feature map containing richer small target feature information. Compared with the original three detection layers of YOLOv8, the newly added small target detection layer structure can cleverly merge the shallower original features of the image with the features extracted and enhanced by the network depth. The resulting features therefore contain more shallow detail information, significantly improving the detection accuracy of small targets such as cotter pins and their defects, and to some extent making up for the performance shortcomings of the model in small target detection.

[0049] Specifically, the P-C2f module is:

[0050] The channel self-attention mechanism of PSA is used to compress information, and the spatial self-attention mechanism of PSA retains high-resolution information. The channel self-attention mechanism and the spatial self-attention mechanism are connected in series to obtain a complete PSA module. The PSA module is integrated with the original C2f module to obtain the P-C2f module.

[0051] In this embodiment, due to the diversity of the split pin targets in the inspection images, they show high complexity in size, shape, position and angle, resulting in the three forms of normal, loose and missing being relatively similar in features. This reduces the classification accuracy of the model for different categories. Although the C2f feature fusion module in YOLOV8 enables the model to obtain contextual information and high-resolution details at the same time, it treats features of multiple scales and levels equally, and maintains a relatively similar degree of attention to features of different scales. For the detection of split pin defect targets, most of the features presented by the split pin targets are small in scale and have fine-grained characteristics, and special attention needs to be paid to shallow features and the detailed features of the target. Therefore, the present invention introduces a polarized self-attention mechanism based on C2f and proposes a new P-C2f module.

[0052] The new P-C2f module, PSA, first compresses information in one direction and retains high-resolution information in the other direction, and then uses SoftmaxSigmoid to combine this nonlinear method to process data, increase the dynamic range, make full use of high-resolution information, and improve the model's attention to important features and processing efficiency, thereby improving the detection accuracy of the model; PSA is divided into two parts: channel self-attention and spatial self-attention mechanism. The calculation process of the channel self-attention branch can be expressed by formula (1):

[0053]

[0054] The calculation process of the spatial self-attention branch is expressed as follows:

[0055]

[0056] Among them, Wz, Wv and W q is a standard 1×1 convolution (Conv), θ1 is the intermediate parameter of the convolution, σ1 and σ2 are matrix reshaping operators (Reshape), which convert matrices (or three-dimensional arrays) of shape 1×H×W and C / 2×H×W into matrices of shape HW×1×1 and C / 2×1, respectively. SG and F SM They are Sigmoid and Softmax operators, F GP is the global pooling operator, and “×” is the dot product operation of the matrix. The two modules are arranged in series to form a complete PSA attention module. The operation of the complete PSA attention module is as shown in formula (3). The processed feature vector of the channel attention branch is used as input to the spatial attention branch:

[0057] PSA s (X) = A sp (A ch ) (3)

[0058] This embodiment combines PSA with C2f to propose a new P-C2f module, which replaces part of the C2f module in YOLOv8, enhances the feature representation ability of the model, and improves the detection accuracy of the model. C2f is a two-branch structure. After the CBS (Conv2d+batchNorm2d+Silu) module generates an intermediate feature map of size H×W×C for the input, the feature map is split into Figure 1The features are split into two parts with the size of H×W×1 / 2C. One branch is directly output to the final Concat block, and the other branch is directly output to the Concat block, and is further processed through multiple Bottleneck blocks before being passed to the Concat block. Botleneck processing is a process of extracting deeper features of the image. In this process, the bottleneck module processes the features layer by layer to extract deeper features. PSA is added to bottleNeck. PSA can participate in the whole process of layer-by-layer feature processing. The Softmax in PSA can convert the input feature value into a probability distribution, which means that Softmax can make larger feature values ​​more prominent and suppress smaller feature values ​​(unimportant channel features). It adjusts the weight of each channel so that the model can automatically focus on the most relevant channel and spatial information, highlight the key features in the global context, and enable important features to dominate in subsequent processing. This has been verified in subsequent experiments.

[0059] The expression of PSA-Bottleneck is as follows: X PSA-Bottleneck =PSA s (W 3×3 (W 3×3 (X)))+X (4)

[0060] Where X is the input of PSA-Bottleneck, X PSA-Bottleneck is its output, W 3×3 It is a 3×3 convolution, and PSA-Bottleneck replaces Bottleneck’s P-C2f. The expression is as follows:

[0061]

[0062] in, is the output of P-C2f, is the input of C2f, W 1×1 is a 1×1 convolution, X Split It is the part that is directly passed to the Concat block after the Split feature is split. is a stack of n PSA-Bottlenecks.

[0063] Specifically, the P-C2f module is used to replace part of the C2F module in the original YOLOv8.

[0064] Specifically, the MCA attention module receives the features extracted and processed by the backbone network, and based on the preset three-branch architecture, performs modeling attention in the channel, width and height dimensions respectively.

[0065] In this embodiment, in order to further improve the feature representation ability of the model, as well as its detection accuracy and efficiency for small targets, the present invention adds an MCA attention module before each detection head of the YOLOv8 model, that is, Figure 2 At positions 1, 2, 3, and 4, the features extracted and processed by the backbone network are sent to the MCA module to further enhance the image features, thereby improving the detection and classification capabilities of the detection head and reducing the false detection rate of the model.

[0066] MCA adopts a three-branch architecture, where each branch is responsible for modeling attention in the channel, width, and height dimensions. This embodiment takes the width W branch as an example, and the entire process of this branch can be summarized as formula (6):

[0067]

[0068] The features of the input MCA are sent to each branch. In the first branch, PM H (*) indicates a 90° rotation (permute) along the H direction. This means that the feature matrix is ​​rotated 90° clockwise (permute-1) along the H direction, T sq (*) indicates average pooling and standard pooling, T ex (*) is the excitation transform of the 1×K convolution kernel, F SG (*) is the Sigmoid function, is matrix multiplication. Similarly, in the other height H direction of the spatial dimension, the same operation is performed to obtain F' H , channel C is similar to the previous two channels in dimension, but with two fewer rotation operations, resulting in F′ C Finally, the outputs of the three branches are simply averaged to obtain the feature map after weight optimization of different dimensions.

[0069] PMW-YOLOv8 integrates an MCA module in front of each detection head, and enhances the feature maps that will be passed to the detection head and the next layer of structure from two dimensions: channel and space. This enhancement mechanism improves the representation ability of small target features in feature maps, ensuring that these fine-grained features are more prominent in subsequent processing. Specifically, the MCA module is integrated after the P-C2f and C2f modules. Before the P-C2f and C2f modules, the Concat module receives the feature map of the previous layer and the shallow feature map transmitted through the jump connection, and splices them to fuse the deep and shallow features. The fused feature map is sent to the P-C2f and C2f modules, which further extract the input features.

[0070] The integrated MCA module enhances the feature weight of the target area on the feature map output by the P-C2f and C2f modules, amplifies the response of small target features in both channel and spatial dimensions, ensures that they do not lose significance in the deep network, and thus improves the accuracy of small target detection. The mechanism of MCA in PM-YOLOv8 is as follows:

[0071]

[0072] Among them, F MCA represents the output of MCA, F C2f represents the input of MCA, i.e., the output of C2f or P-C2f. The integrated enhanced feature F MCA There are two processing paths: on the one hand, the enhanced features are directly passed to the corresponding detection head for classification and location prediction of feature maps of different resolutions; on the other hand, these features are further downsampled and fused with deeper features before the deep detection head completes the target detection task. This optimization mechanism enables the model to more effectively highlight the features of the target area while suppressing irrelevant background interference, especially showing significant advantages in small target detection tasks.

[0073] Specifically, the WIOU loss function is constructed based on the center point of the detection box, the center point of the target box, and the width and height of the joint area.

[0074] In this embodiment, the loss function of Yolov8 is divided into classification and regression branches. The classification loss function is the BCE loss function, which is used to help the model correctly classify the detected targets. Its calculation is expressed by formula (8), where y i is the true label of the sample, p i is the prediction probability of the model; the regression loss is a combination of CIOU+DFL (DistributionFocalLoss) loss functions, which is used to help the model locate the detected target.

[0075]

[0076] The calculation of DFL loss function is as shown in formula (9), S i and S i+1 are the predicted values ​​and near-predicted values ​​of the model, y, y i ,y i+1 They are the adjacent label value, predicted value and label value respectively.

[0077] DFL(S i ,S i+1 )=-((y i+1 -y)log(S i )+(yy i )log(S i+1)) (9)

[0078] In the training data set, some low-quality samples will inevitably appear, such as low IOU between the anchor box and the target box, or low resolution between the target and the background in the sample. The geometric factors such as distance and aspect ratio in CIOU used by YOLOv8 will increase the penalty for these low-quality samples, and the amount of calculation is large. Therefore, the CIOU loss function used in YOLOv8 is partially replaced by the WIOU loss function. When the detection box and the target box are well matched, the attention and intervention are reduced, the penalty of geometric factors is weakened, and the impact of low-quality samples on the generalization performance of the model is reduced, thereby improving the generalization ability of the model. The loss function of the improved model is as follows:

[0079] Loss total =ηLoss BCE +μLoss DFL +γLoss WIOU (10)

[0080] In the formula, the three loss functions are weighted by weight ratio, and the hyperparameters η, β, and γ are the weights of the three loss functions. In this embodiment, η, μ, and γ are 7.5, 0.5, and 1.5 respectively. WIOU is the WIOU loss function, which is expressed as Equation (11) and Equation (12):

[0081] Loss WIOU =rR WIOU L IOU (11)

[0082]

[0083] (x,y) and (x gt ,y gt ) are the center points of the detection box and the target box respectively, and W g and H g is the width and height of the joint region. When the detection box fits the target box well, L IOU Smaller, can significantly reduce the focus on detection boxes with better matching effects. On the contrary, when the detection box fits poorly due to the appearance of difficult samples, R WIoU Then it is smaller, so that the model can focus on most common samples as much as possible during training, reduce the attention to high-quality samples and low-quality samples, and enhance the generalization ability of the model. The specific expression of parameter r is as follows (13).

[0084]

[0085] In formula (13), α and δ are hyperparameters. In this embodiment, α=1.9, δ=3, and β is a parameter that expresses the degree of matching between two frames and is inversely proportional to the degree of matching between the frames. The specific expression of β is as follows: As shown, It is the sliding average of the IOU loss. β can dynamically adjust the gradient according to the matching degree of the two current boxes, and make the gradient gain allocation strategy that best suits the current situation. This keeps the overall gradient descent speed at a high level, speeds up the training speed, and improves the detection accuracy.

[0086] Specifically, the image feature extraction process includes:

[0087] The preprocessed image is input into the backbone network, and shallow features and deep features are extracted based on the increase in the number of layers of the backbone network.

[0088] Specifically, the fusion process of fusion features includes:

[0089] The extracted shallow features and deep features are spliced ​​in the neck network;

[0090] The spliced ​​features are enhanced by the P-C2f module and the MCA attention module, and then sent to the decoupled detection head for target box detection and classification recognition, respectively. Each detection head outputs feature maps of two scales, classification and regression. The feature maps of the four detection heads are spliced ​​to obtain the detection frame, which is then filtered and restored to the original image for detection.

[0091] The specific improvements and algorithm flow of this embodiment compared to the original YOLOv8 model are as follows:

[0092] The first CBS layer consists of a convolution module, a batch normalization module, and a Silu activation function. It is a common convolution block structure with 64 channels and 3×3 kernel size. It performs a convolution operation on the input image. After this convolution layer, the number of image channels becomes 64, and the feature map is reduced to half of the original size.

[0093] The second CBS layer performs convolution operation on the feature map, with the number of channels = 128 and the convolution kernel size = 3×3. The convolution operation is performed on the input image features. After this convolution layer, the number of image channels is doubled and the feature map is reduced to half of the original;

[0094] The third layer C2f layer structure is as follows Figure 2 It shows that it fuses features of different scales, and the scale of the feature map before and after processing remains unchanged, and the number of channels remains unchanged;

[0095] The subsequent fourth to ninth layers are arranged in the order of the second CBS layer and the third C2f layer. The CBS convolutional layer extracts features. After each CBS layer, the size of the feature map is reduced to half of the original size, while the number of channels is doubled.

[0096] The tenth layer is the SPPF layer, which performs the pooling operation of the spatial pyramid structure, performs pooling on features of different scales, and extracts the feature information of the target at different scales;

[0097] The eleventh layer Upsample is an upsampling layer, which upsamples the feature map passed by SPFF, doubling the size of the feature map, but halving the number of channels, which is consistent with the feature map size and number of channels of the seventh layer C2f;

[0098] The twelfth layer, Concat, performs a splicing operation on the spatial dimension of the feature maps of the eleventh and seventh layers to fuse their features;

[0099] The thirteenth layer P-C2f was originally C2f. On the basis of C2f, the PSA (Polarized Self-Attention, PSA) module is integrated. On the basis of C2f, it realizes the deep encoding of global information, suppresses unimportant features, and highlights key features, thereby enriching the hierarchical nature of feature expression while keeping the number of output channels consistent with the original structure. After P-C2f processing, the feature map size and number of channels remain unchanged.

[0100] like Figure 2 As shown in Figure 1, the 14th to 19th layers of the model repeat the module sequence of the 11th to 13th layers to process the feature maps, but only the 19th layer uses the P-C2f module, and the 16th layer uses the native C2f module of the YOLOv8 model;

[0101] The MCA module is introduced in the twentieth layer, which can fully extract the correlation between different dimensions and calibrate the attention weights generated by different dimensions, so as to extract and output more refined features, and further improve the detection accuracy and classification accuracy of the small target of the cotter pin. At the same time, the feature map of this layer is sent to the P2 detection head with a feature map size of 160×160×128. The detection head locates and classifies the target on the feature map, thereby realizing the detection of the target; since the feature map of this layer is larger in size, it contains more feature information such as target features and edge details, which is of great help for the detection of small targets.

[0102] The 21st CBS layer performs convolution operations on the feature map, halving the size of the feature map and doubling the number of channels;

[0103] The 22nd layer concatenates the feature map of the previous layer and the feature map of the 16th layer to fuse the features, while the size and number of channels of the feature map remain unchanged.

[0104] The 23rd layer C2f fuses features of different scales. The scale of the feature map before and after processing remains unchanged, and the number of channels remains unchanged.

[0105] The MCA module is introduced into the 24th layer to enhance the feature map, and the 80×80×256 feature map is sent to the P3 object detection head;

[0106] The 25th to 32nd layers are arranged in the order of CBS layer, Concat layer, C2f layer and MCA to process the feature maps, and the 40×40×512 and 20×20×512 feature maps are sent to the P4 and P5 detection heads at the 29th and 33rd layers respectively.

[0107] The sizes of feature maps received by P2-5 detection heads decrease in sequence. After all detection heads predict and classify the target position, each detection head will output feature maps at two scales, classification and regression. The feature maps of the four detection heads are spliced ​​to obtain the detection frame of the model. The detection frame is filtered and restored to the original image to obtain the final detection result.

[0108] Specifically, the PMW-YOLOv8 model is run to generate the detection results of the cotter pin defects of the transmission line, which are as follows:

[0109] Acquire real-time images and execute steps one and five to perform cotter pin defect detection for power transmission lines. The detection results include normal cotter pins, loose cotter pins, and cotter pin disappearance.

[0110] As a comparative example of this embodiment, in order to evaluate the effectiveness of the proposed method, experiments were conducted on a data set of power transmission line cotter pin defects. This experimental data set was provided by a power supply bureau in Yunnan. After screening and sorting, there were 4218 inspection pictures that met this task. The pictures included power scenes of transmission lines in different environments, different weather conditions, and different angles collected during the inspection, which can effectively guarantee the generalization performance of the model. The labeled targets included three types of cotter pins: normal, loose, and missing. Among them, since the proportion of loose and missing cotter pins in all cotter pins in normal transmission lines is relatively small, the samples between defective cotter pins and normal cotter pins are extremely unbalanced. In order to solve this problem, the pictures containing defective cotter pins were enhanced by inversion, tilting, adding noise, etc. The final data set reached 9108 pictures, which were divided into training set, verification set, and test set in a ratio of 6:2:2.

[0111] In order to evaluate the proposed PMW-YOLOv8 improved model, this paper selects precision (P), recall (R) and mean average precision (mAP@0.5) as core evaluation indicators. These indicators not only independently reflect the different aspects of the model's capabilities in the detection task, but also complement each other and together constitute a comprehensive evaluation system for the model performance.

[0112] 1. Dataset

[0113] This experimental data set is provided by a power supply bureau in Yunnan. After screening and sorting, there are 4218 inspection pictures that meet this task. The pictures include power scenes of transmission lines in different environments, different weather conditions, and different angles collected during the inspection, which can effectively ensure the generalization performance of the model. The labeled targets include three types of cotter pins: normal, loose, and missing. Among them, since the proportion of loose and missing cotter pins in all cotter pins in normal transmission lines is relatively small, the samples between defective cotter pins and normal cotter pins are extremely unbalanced. In order to solve this problem, the pictures containing defective cotter pins are enhanced by inversion, tilting, and adding noise. The final data set reached 9108 pictures, which were divided into training set, validation set, and test set in a ratio of 6:2:2.

[0114] The size of the split pin is relatively small, and in standard power inspection images, the resolution of the image is often set quite high because a large number of power devices need to be observed in detail. This high-resolution processing method further reduces the relative size of the split pin in the image, which undoubtedly increases the difficulty of accurately detecting split pin defects. In order to overcome this challenge, a specific image processing method was adopted during the model training process. Specifically, the high-resolution inspection image is divided into several small-sized sub-images. In order to fit the input of the model, the size of the cropped sub-image is set to 640×640 pixels, and a 20% crop overlap rate is set. The relative size of all target frames is less than 20% of the image, and most of them are less than 5%. Therefore, a 20% crop overlap rate can avoid incomplete targets caused by cropping; on the other hand, sub-images without targets in the training set are directly excluded to improve training efficiency.

[0115] In the slice operation, the number of sub-images of each image is as follows:

[0116] N=N w +N h (15)

[0117]

[0118]

[0119] Among them, N w and N h are the number of sub-images in the horizontal and vertical directions of the image, W and H are the width and length pixels of the image, respectively, and P w and P h The pixel width and pixel length of the sub-image, α and β are the sub-image overlap ratios in the horizontal and vertical directions, respectively. Indicates rounding down.

[0120] After cropping, the number of sub-images in the training set, validation set, and test set are 12977, 4217, and 4203, respectively. Although the number of small objects in the cropped dataset is still the majority, their relative size has increased a lot, which is beneficial for detecting cotter pin defects.

[0121] The datasets before and after slicing were trained and tested. The results are shown in Table 1. All performance indicators have been greatly improved, with significant effects. The accuracy and recall rates have increased by 6.57% and 14.36% respectively, and the mAP@0.5 of the three categories have increased by 15.08%, 5.72%, and 16.41% respectively, indicating that the performance improvement of this method on different categories of data is very significant. At the same time, the overall mAP@0.5 index has increased by 13.60%, further verifying the universality of slicing processing on the performance improvement of the dataset. In a wider range of performance evaluation, the mAP@0.5~0.95 performance index has increased by 10.98%. This result not only demonstrates the effectiveness of slicing processing in improving model performance, but also further proves the stability and reliability of this method under different thresholds.

[0122]

[0123] Table 1

[0124] 2. Model Improvement Ablation Experiment

[0125] In order to further explore the effectiveness of the model improvement measures and the independence of each module's contribution to the model performance, a series of ablation experiments were performed. The model performance was quantitatively evaluated and compared by gradually integrating the P2 detection head, P-C2f module, MCA module, and using the WIOU loss function. In all experiments, a unified training strategy and hyperparameter configuration were adopted to ensure the academic rigor and repeatability of the experimental results. The experimental results (as shown in Table 2) clearly show the positive impact of each step of improvement on the model performance. After adding the small target detection head P2, the accuracy of the model increased by 1.24%, the accuracy of the cotter pin loose and cotter pin missing increased to 2.83% and 0.21%, and the mAP@0.5 increased by 0.54%. After introducing the P-C2f module, the mAP@0.5 index of the model increased significantly by 1.14 percentage points, and the overall accuracy also increased slightly (0.04%). In particular, in the recognition of the two types of targets with loose cotter pins and missing cotter pins, the accuracy achieved a significant increase of 1.21% and 2.50% respectively. This result strongly supports the effectiveness of the polarized self-attention mechanism in improving the feature representation capability of the model.

[0126]

[0127] Table 2

[0128] Subsequently, after the MCA module was further integrated on the basis of the introduction of the P-C2f module, the model performance was significantly improved again. The mAP@0.5 index was further improved by 1.84 percentage points, and the overall accuracy rate also increased slightly (0.03%), especially in the recognition tasks of loose and missing cotter pins, the accuracy rates increased by 1.80% and 0.59% respectively. This result shows that the introduction of the MCA module effectively enhances the model's ability to handle complex scenes and capture multi-dimensional contextual information.

[0129] Finally, when the WIOU loss function was used for training, the model performance reached the best. The mAP@0.5 index was as high as 66.34%, an increase of 3.07 percentage points compared to the baseline network, and other key performance indicators were also significantly improved. This result not only verifies the effectiveness of the WIOU loss function in optimizing the model training process, but also fully proves the significant effect of this model improvement strategy in improving the overall performance of the model.

[0130] (1) Validation of MCA module

[0131] In order to fully verify the effectiveness and superiority of the MCA attention module in model optimization, several classic attention modules, such as GAM, CA and CBAM, were selected for comparative experiments with the MCA module. By comparing the detection results, the results shown in Table 3 were obtained. It can be clearly seen from the data in the table that in the model incorporating the MCA module, the best performance has been achieved in terms of key performance indicators such as accuracy and mAP@0.5. Specifically, compared with the baseline model, after the introduction of the MCA module, the accuracy of the model has been significantly improved by 1.74%, and the recall rate has also been increased by 2.39%.

[0132]

[0133] Table 3

[0134] Further analysis revealed that the addition of the MCA module brought significant performance improvements in tasks targeting specific defect categories, such as loose cotter pins and missing cotter pins. Among them, the mAP@0.5 index of the loose cotter pin defect increased by 3.82%, and the mAP@0.5 index of the missing cotter pin defect also increased by 1.39%, which shows that the MCA module has extremely strong targeted optimization capabilities for subtle and important detection tasks. In addition, the overall mAP@0.5 of the model was also improved by 1.53%. This comprehensive performance improvement fully verifies the core value and excellent effect of the MCA module in model optimization. This series of improvements fully demonstrates the effectiveness of the MCA module in model optimization.

[0135] (2) Validation of MCA module position

[0136] In order to further explore the rationality of the optimal insertion position of the MCA module in the model, four groups of control experiments were designed (see Table 4), marked as groups a, b, c, and d, each representing a different application strategy of the MCA module. Among them, group d is the scheme finally adopted in this study. In Table 4, serial numbers 1, 2, 3, and 4 correspond to four potential MCA module insertion points, and the "√" mark indicates that the MCA module is introduced at this position. Specifically, scheme d Figure 2 All four positions shown integrate the MCA module, achieving comprehensive feature enhancement.

[0137]

[0138] The experimental results are summarized in Table 5. Through comparative analysis, it can be observed that compared with the three groups of experiments a, b, and c, the model using solution d has achieved significant advantages in multiple key performance indicators. These indicators include overall accuracy, mAP@0.5 for two types of defects, loose and missing cotter pins, overall mAP@0.5, and a more comprehensive mAP@0.5-0.95 range evaluation. Solution d shows the best performance in all these aspects, which not only confirms the rationality of selecting the MCA module insertion position in the model, but also further demonstrates the effectiveness of the solution in improving detection accuracy and robustness.

[0139]

[0140] Table 5

[0141] 3. Comparative Experiment

[0142] In order to comprehensively evaluate the performance of the PMW-YOLOv8 algorithm in the task of split pin defect detection, a series of classic and currently advanced target detection algorithms were selected, including but not limited to the classic YOLO series networks, the anchor-free algorithm CenterNet, the two-stage algorithm Faster-RCNN, and some of the more advanced algorithms at the current stage.

[0143] The model is evaluated by comparing the accuracy of each category and the overall average accuracy. The experimental results are shown in Table 6. The results show that compared with the Faster-RCNN model, YOLOv5 series model, SSD model, YOLOX model, YOLOv7 model, and YOLOX model, PMW-YOLOv8 shows relatively good performance in P, R, mAP@0.5 and other indicators for different types of split pin defects. Among them, P, R, AP of loose and missing split pins, overall mAP@0.5 and mAP0.5~0.95 all achieve the best performance among many detection models. It is worth mentioning that in terms of the key indicator of mAP@0.5, PMW-YOLOv8 has improved by 3.07% compared with the native YOLOv8 model, and even compared with TPH-YOLOv5, which has the best performance among all the comparison models, it still achieved an improvement of 3.24%. In addition, since the model adds an additional attention module, it sacrifices some detection speed, but compared with the two-stage model, the model still has certain advantages in detection. Therefore, the proposed PMW-YOLOv8 model achieves good detection performance in the split pin defect dataset, creating good conditions for the intelligent inspection of split pin defects in power inspection.

[0144]

[0145] Table 6

[0146] In summary, the power line split pin defect detection method based on improved YOLOv8 in this embodiment, in response to the small target problem faced by the existing split pin detection method, divides the high-resolution image into several sub-images in the data processing stage of model training, increases the relative size of the split pin in the image, and improves the detection accuracy of the split pin; in the PMW-YOLOv8 model, adds a small target detection head to make full use of the edge information and detail features of the small target, thereby improving the detection accuracy of the small target; an MCA attention module is integrated at the front end of each of the four target detection heads P2-P5, and the extracted features are further enhanced, thereby improving the model's detection and classification capabilities for small targets; in response to the fine-grained problem in split pin detection, a polarized self-attention mechanism (PSA) is introduced on the basis of the C2f module, and a P-C2f module is proposed and integrated into the model, so as to strengthen the model's extraction and processing of fine-grained information and improve the model's detection accuracy for split pin fine-grained targets.

[0147] In the embodiments provided in the present application, it should be understood that the embodiments described herein can be implemented in hardware, software, firmware, middleware, code or any appropriate combination thereof. For hardware implementation, the processor can be implemented in one or more of the following units: application specific integrated circuit (ASIC), digital signal processor (DSP), digital signal processing device (DSPD), programmable logic device (PLD), field programmable gate array (FPGA), processor, controller, microcontroller, microprocessor, other electronic units designed to implement the functions described herein or their combination. For software implementation, part or all of the flow of the embodiment can be completed by instructing the relevant hardware through a computer program. When implemented, the above program can be stored in a computer-readable storage medium or transmitted as one or more instructions or codes on a computer-readable storage medium. Computer-readable storage media include computer storage media and communication media, wherein the communication medium includes any medium that is convenient for transmitting a computer program from one place to another. The storage medium can be any available medium that a computer can access. The computer-readable storage medium can include but is not limited to RAM, ROM, EEPROM, CD-ROM or other optical disk storage, disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of an instruction or data structure and can be accessed by a computer.

[0148] Finally, it should be noted that the above is only a preferred embodiment of the present application and is not intended to limit the present application. Although the present application has been described in detail with reference to the aforementioned embodiments, it is still possible for those skilled in the art to modify the technical solutions described in the aforementioned embodiments or to make equivalent substitutions for some of the technical features therein. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A transmission line split pin defect detection method based on improved YOLOv8, characterized in that: include: Step 1: performing image preprocessing and data enhancement; wherein the image preprocessing is used to adjust the image size, and the data enhancement is used to increase the relative size of the cotter pin in the image; Step 2: Construct a PMW-YOLOv8 model; wherein the PMW-YOLOv8 model is used to detect cotter pin defects in transmission lines, and the PMW-YOLOv8 model at least includes a small target detection head P2, a P-C2f module integrated with a PSA module, an MCA attention module and a WIOU loss function, and the MCA attention module is integrated in front of each detection head; Step 3: Train the PMW-YOLOv8 model to extract image features of split pin defects; Step 4: Fusing and enhancing the image features to obtain the fused features; Step 5: Storing the fusion features into the PMW-YOLOv8 model to complete model construction, and running the PMW-YOLOv8 model to generate the detection results of the transmission line split pin defects.

2. The power transmission line split pin defect detection method based on improved YOLOv8 according to claim 1 is characterized in that: The step 1 specifically includes: adjusting the input image to a uniform preset size, dividing the resized image into a number of sub-images with equal pixels, and excluding sub-images without cotter pins based on a preset cropping overlap ratio.

3. The power transmission line split pin defect detection method based on improved YOLOv8 according to claim 1 is characterized in that: The small target detection head P2 is arranged in front of the three detection heads P3 to P5 of different sizes of the original YOLOv8 model, and the operation of the small target detection head P2 is specifically as follows: After the C2f module of the original YOLOv8 model outputs a feature map of size 80×80×256, the feature map is upsampled to output a feature map of size 160×160×128, and the 160×160×128 feature map is fused with the shallow feature jump connection in the backbone network to generate a large-size feature map.

4. The power transmission line split pin defect detection method based on improved YOLOv8 according to claim 1, characterized in that: The P-C2f module is specifically: The channel self-attention mechanism of PSA is used to compress information, and the spatial self-attention mechanism of PSA retains high-resolution information. The channel self-attention mechanism and the spatial self-attention mechanism are arranged in series to obtain a complete PSA module. The PSA module is integrated with the original C2f module to obtain a P-C2f module.

5. The method for detecting defects of power transmission line split pins based on improved YOLOv8 according to claim 4, characterized in that: The P-C2f module is used to replace part of the C2F module in the original YOLOv8.

6. The power transmission line split pin defect detection method based on improved YOLOv8 according to claim 1, characterized in that: The MCA attention module receives the features extracted and processed by the backbone network, and performs modeling attention in the channel, width and height dimensions based on a preset three-branch architecture.

7. The method for detecting defects of power transmission line split pins based on improved YOLOv8 according to claim 1, characterized in that: The WIOU loss function is constructed based on the center point of the detection box, the center point of the target box, and the width and height of the joint area.

8. The method for detecting defects of power transmission line split pins based on improved YOLOv8 according to claim 1, characterized in that: The image feature extraction process includes: The preprocessed image is input into the backbone network, and shallow features and deep features are extracted based on the increase in the number of layers of the backbone network.

9. The method for detecting defects of power transmission line split pins based on improved YOLOv8 according to claim 8, characterized in that: The fusion process of the fusion features includes: Performing a splicing operation on the extracted shallow features and deep features in the neck network; The spliced ​​features are enhanced by the P-C2f module and the MCA attention module, and then sent to the decoupled detection head for target frame detection and classification recognition, respectively. Each detection head outputs feature maps of two scales, classification and regression. The feature maps of the four detection heads are spliced ​​to obtain a detection frame, which is filtered and restored to the original image for detection.

10. The method for detecting defects of power transmission line split pins based on improved YOLOv8 according to claim 9, characterized in that: The PMW-YOLOv8 model is run to generate the detection results of the cotter pin defects of the transmission line, specifically: Real-time images are acquired and step one and step five are executed to perform cotter pin defect detection for power transmission lines. The detection results include whether the cotter pin is normal, the cotter pin is loose, and the cotter pin disappears.

Citation Information

Patent Citations

  • PCB small target defect detection optimization method based on YOLOv8s

    CN118691577A

  • Steel surface defect target detection method and device, computer equipment and medium

    CN118865063A

  • Method and system for machine vision detection

    US11151405B1