Power transmission line insulator defect detection method based on dynamic attention guidance and lightweight architecture
By improving the YOLOv8 network model and combining dynamic attention with a lightweight architecture, the accuracy and efficiency issues of transmission line insulator defect detection were solved, achieving high-precision, low-complexity insulator defect detection.
Patent Information
- Application Number
- CN202510657486.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-21
- Publication Date
- 2025-09-26
AI Technical Summary
The existing technology for transmission line insulator defect detection has problems such as low detection accuracy, poor adaptability to complex environments, and high computational overhead, making it difficult to meet the requirements of high-precision and high-efficiency detection.
An improved YOLOv8 network model based on dynamic attention guidance and lightweight architecture is adopted. The AKConv module, C2f_RVB module and EMA attention mechanism are used to optimize insulator defect detection. Combined with multi-scale feature fusion and loss function optimization, the detection accuracy and real-time performance are improved.
It improves the ability to identify defects in insulators of different sizes in complex environments, ensures the safe and stable operation of transmission lines, reduces computational complexity and improves detection efficiency.
Smart Images

Figure CN120707797A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of intelligent detection and identification of transmission lines, and relates to a method for detecting defects in transmission line insulators based on dynamic attention guidance and a lightweight architecture. Background Art
[0002] Transmission line insulators are a crucial component of high-voltage power systems, providing electrical insulation and mechanical fixation to ensure proper current transmission and prevent leakage. However, due to prolonged exposure to the elements, insulators are susceptible to various environmental factors, including wind, rain, dust accumulation, and humidity fluctuations, leading to defects such as contamination, cracks, oxidation, and aging. These defects can directly impact the insulator's insulation performance and even threaten the safe and stable operation of the power system, resulting in significant economic losses and safety risks.
[0003] Currently, defect detection for transmission line insulators relies primarily on manual inspections and automated detection methods based on deep learning. Manual inspections require professionals to climb transmission towers or use telescopes to visually inspect the insulator surface. However, this method is time-consuming and labor-intensive, inefficient, and carries the risk of missed and false detections in complex environments. With the rapid development of deep learning technology, automated detection methods based on convolutional neural networks (CNNs) are gradually being applied to insulator defect detection. For example, Faster R-CNN has been proposed for detecting target information in insulators. Although it offers high detection accuracy, its complex network structure and high computational complexity make it difficult to meet the rapid detection requirements of actual transmission line sites.
[0004] To further improve detection efficiency, the Single Shot Multi-Box Detector (SSD) was proposed, combining a multi-scale detection mechanism to rapidly locate and classify insulator defects. However, detection accuracy remains insufficient for small insulator defects in complex environments, particularly for small, minor defects.
[0005] Therefore, existing insulator defect detection technologies still suffer from low accuracy, poor adaptability to complex environments, and high computational overhead, making them difficult to meet the practical needs for high-precision and efficient insulator detection during transmission line operation. An improved defect detection method is urgently needed that balances accuracy with real-time performance, further improving the ability to identify insulator defects of varying sizes in complex environments, and ensuring the safe and stable operation of transmission lines. Summary of the Invention
[0006] In view of this, the present invention provides a transmission line insulator defect detection method based on dynamic attention guidance and lightweight architecture, which can take into account both detection accuracy and real-time performance, improve the ability to identify insulator defects of different sizes in complex environments, and ensure the safe and stable operation of transmission lines.
[0007] In order to solve the above technical problems, the technical solution adopted by the present invention is:
[0008] A method for detecting defects in insulators of transmission lines based on dynamic attention guidance and lightweight architecture, the method comprising the following steps:
[0009] S1, obtain a visible light insulator image dataset and manually screen the data to obtain an insulator defect image dataset;
[0010] S2, manually annotating the insulator defect image data obtained in S1 using an image annotation tool;
[0011] S3, preprocessing the labeled insulator defect image data;
[0012] S4, divide the preprocessed dataset into training set and test set;
[0013] S5: Improve the YOLOv8 network model and use it to identify and detect defects in the insulator defect image dataset. The improvement process is as follows:
[0014] S51, replace the convolution module of the YOLOv8 network model with the AKConv module;
[0015] S52, upgrade the C2f module in the neck network of the YOLOv8 network model to the C2f_RVB module;
[0016] S53, introduces the EMA attention mechanism into the head network of the YOLOv8 network model;
[0017] S54, construct the loss function form of the improved Y0L0v8 network;
[0018] S6, using the insulator defect image dataset and loss function obtained in S4 to train the improved YOLOv8 network model;
[0019] S7. Use the test set to test the trained improved YOLOv8 network.
[0020] Furthermore, in S3, the process of preprocessing the marked insulator defect image data includes the following steps:
[0021] S31, resizing the insulator defect image data to scale all insulator defect images to a size required by the network model;
[0022] S32, performing data enhancement processing on the image data set obtained in S31 using data enhancement technology;
[0023] S33, performing normalization processing on the enhanced image data;
[0024] S34, converting each tag name and its corresponding bounding box into a YOLO format annotation.
[0025] Furthermore, in S4, the preprocessed data set is divided into a training set and a test set in a ratio of 8:2.
[0026] Furthermore, in said S51, the AKConv module processing steps are as follows: inputting the image into the improved YOLOv8 network model to extract target features;
[0027] AKConv module, the specific calculation formula is as follows:
[0028] Y=F(X)+A(X)
[0029] Where X represents the input feature map, F(X) represents the basic features extracted by group convolution, A(X) is the weighted feature generated by the attention mechanism, and Y is the output feature map;
[0030] The basic information of the input feature map is extracted by grouped convolution. During the grouped convolution extraction process, the input feature map X is divided into multiple sub-feature maps. Each sub-feature map is processed by a convolution kernel, and the generated features are recorded as F. i , the specific calculation formula is as follows:
[0031] F i,j =Φ i (X i,j ),i=1,…,m,j=1,…,s
[0032] Among them, Φ i is the convolution operation corresponding to each group, X i,j is the feature of the jth channel of the i-th group of the input feature map, F i,j is the output sub-feature map, m is the number of groups, and s is the number of channels in each group;
[0033] Subsequently, weighted features are generated through a dynamic attention mechanism, which generates a weight map A based on the global context information of the input feature map. i,j and the feature F generated by group convolution i,j The specific formula for fusion is as follows:
[0034] A i,j =σ(W i,j ·GAP(F i,j )),W i,j ∈ c×1
[0035] Among them, GAP represents the global average pooling operation, W i,j is the learned weight, σ represents the activation function;
[0036] Finally, the features generated by the group convolution are fused with the features generated by the attention mechanism, and the output feature map Y is output. During the fusion process, the features of each group are combined through weighted operations. The specific calculation formula is:
[0037]
[0038] Among them, λ i,j is the fusion weight parameter, which can be obtained through network training.
[0039] Furthermore, in S52, the processing process of the C2f_RVB module is as follows:
[0040] First, the input feature map is extracted and transformed through a lightweight and heavily parameterized convolutional structure to capture multi-scale spatial information. At the same time, the representation capability of the target area is enhanced through a deep convolution and global feature fusion mechanism. The specific calculation formula is as follows:
[0041] Y=F rep (X)+F res (X)
[0042] Among them, X represents the input feature map, F rep (X) is the local feature extracted by the reparameterized convolution (RepConv), F res is the global feature generated by the deep residual connection, and Y is the output feature map;
[0043] In the reparameterized convolution part, the input feature map X is first subjected to a standard convolution operation to extract the basic features F. base , and then multi-scale features are extracted in parallel through the branch structure of 1×1 convolution and 3×3 convolution. The specific calculation formula is as follows:
[0044] F rep =W 1×1 *X+W 3×3 *X+b
[0045] Among them, * represents the convolution operation, W 1×1 and W 3×3 are the weights of the 1×1 and 3×3 convolution kernels, and b is the bias term;
[0046] At the same time, the input feature X is modeled through the residual block for global feature modeling. The specific calculation formula is:
[0047] F res =X+σ(W·BN(X))
[0048] Where σ is the activation function (such as ReLU), BN represents the batch normalization operation, and W is the linear transformation matrix. Through this operation, the model can capture the global context information of the input features, thereby enhancing the robustness of the feature representation;
[0049] In the fusion stage, the feature F extracted by the re-parameterized convolution is rep Feature F generated by connecting with the residual res The final output feature Y is generated by adding point by point. The RepViTBlocks module performs multi-scale attention processing on the feature map after fusion. The weight distribution is calculated by the following formula:
[0050] W attn =Softmax(GAP(Y)·W global )
[0051] Among them, GAP represents the global average pooling operation, which is used to extract the global information of the feature map, W global It is the weight matrix of the global features, and the Softmax function normalizes the generated weights to ensure that the contribution of each position in the feature map has a reasonable distribution;
[0052] Finally, the output features of the RepViTBlocks module are obtained by the following formula:
[0053] Y out =W attn ·Y.
[0054] Furthermore, in S53, the formula of the EMA attention mechanism is as follows:
[0055]
[0056] Where, Represents the EMA characteristic graph after the tth update; represents the EMA feature graph after the t-1th update; F t is the feature map of the current moment; α is the smoothing coefficient of the exponential moving average, ranging from 0 to 1, which is used to control the importance of the features of the current moment and the historical moments;
[0057] Furthermore, in said S53, the weights in EMA are weighted based on the spatial information of the feature map;
[0058] The simple attention mechanism formula can be expressed as:
[0059] Where A ij Represents the attention weight of pixel i, j in the feature map, F ij Represents the pixel value of the current feature map at position i, j, and W is a weight matrix used to calculate attention.
[0060] Furthermore, in S54, the loss function is weighted:
[0061]
[0062] Among them, p i is the predicted probability of target category i, λ i is the weighting factor set for category i;
[0063] By combining IoU loss and center point error, the accuracy of bounding box regression is optimized. The optimized bounding box loss function is expressed as:
[0064] L bbox =α·L IoU +β·L center
[0065] Among them, L IoU is the IoU loss, L center is the deviation loss of the center point of the bounding box, α and β are weighting coefficients;
[0066] Furthermore, in said S54,
[0067] For targets of different sizes, the bounding box loss calculation is scale-adaptively adjusted. The adjustment formula is as follows:
[0068]
[0069] in, is the scale factor of the object, w and h are the width and height of the object bounding box respectively.
[0070] Furthermore, in S6, based on the designed loss function form, the loss term of the model performance during the training process is calculated, including the binary classification loss and the regression loss, and the regression loss part includes the DFL loss and the CIoU loss;
[0071] The calculation formula of the loss function of the two-class loss is as follows:
[0072] Loss=-w n ·(y n ·log(x n )+(1-y n )·log(1-xn ))
[0073] Among them, w n represents the category weight, y n is the target true value, x n is the predicted value;
[0074] The calculation formula of the loss function of DFL loss is as follows:
[0075] DFL(S n ,S n+1 )=-((y n -y)log(S n )+(yy n+1 )log(Sn+1))
[0076] Among them, S n represents the bounding box prediction confidence at the nth time step K, S n+1 is the confidence of the prediction box at the n+1th time step, y n and y n+1 are the true values of the bounding box for the current and next steps respectively;
[0077] The loss function of CIoU loss is expressed as follows:
[0078]
[0079] Among them, w g and h g are the width and height of the ground-truth bounding box, w p and h p To predict the width and height of the bounding box; Distance 2 Represents the square of the Euclidean distance between the center point of the predicted box and the true box, Represents the square of the diagonal length of the minimum enclosing area containing the predicted box and the true box; v is the aspect ratio consistency measure.
[0080] The beneficial effects of the present invention compared with the prior art are:
[0081] 1. This invention introduces the partial channel splitting mechanism of C2f into the convolutional layers of RepViT. The number of channels of the input features of each layer is split into two parts. One part of the channels is passed directly to the next layer without convolution processing (equivalent to a residual connection), while the other part of the channels undergoes multi-layer convolution for feature extraction. In each C2f module, the convolved channels and the unconvolved channels are re-fused at a certain stage of the network. This is to ensure that the network can effectively fuse features when using shallow features (unconvolved channels) and deep features (convolved channels). The channel splitting and fusion mechanism can also retain more shallow feature information while reducing the model's computational complexity, enhancing gradient flow, and improving feature extraction capabilities through skip connections of partial features and re-fusion after deep convolution processing. In addition, the improved model combines RepViT's reparameterization technology, which can merge multiple convolution branches into a single equivalent convolution during the inference phase, further accelerating the inference process. Therefore, the improved structure retains the high inference efficiency of RepViT while also possessing the advantages of C2f in feature fusion and gradient propagation.
[0082] 2. The neck network of the present invention adopts a multi-scale feature fusion method, combined with the C2f_RVB module to optimize and combine the feature maps obtained from the backbone network. The main purpose of this module is to fuse the low-level spatial information of the shallow feature map while retaining the high-level semantic information of the deep feature map, thereby improving the network's ability to detect multi-scale targets. In the FPN structure, the feature map is first compressed by 1×1 convolution, and then the feature map is upsampled to a higher resolution using nearest neighbor upsampling, and then the upsampled feature map is combined with the corresponding low-resolution feature map from the backbone network. In this process, the C2f_RVB module enhances the feature expression capability by re-parameterizing the structure.
[0083] 3. In the PAN structure of the Neck portion of the network, the present invention downsamples feature maps using 3×3 max pooling. This is then further downsampled to a lower resolution using 3×2 convolutions with a stride of 3. The higher-resolution feature maps are then compressed using 1×1 convolutions. These downsampled feature maps are then element-wise added to the high-resolution feature maps from the FPN. The C2f_RVB module effectively integrates multi-scale feature information in this step. By blending local and global semantic information, the final feature representation is more precise, further improving detection performance and network robustness.
[0084] 4. This invention introduces the EMA attention mechanism into the head network of the YOLOv8 network model. Based on the output of each convolutional layer, the EMA attention mechanism calculates a weighted average of the output features of that layer and its historical state to smooth feature information and suppress noise. Specifically, during training, the model not only generates the output feature map of the current moment, but also retains feature map information from several past moments, integrating historical information into the current feature map using an exponentially weighted formula. The introduction of the EMA attention mechanism does not significantly increase the computational complexity of the model, as the EMA update process requires only simple weighting and updating, without involving complex matrix operations or additional parameter learning. In the head network, the current mainstream decoupled head structure is adopted to separate the target classification and detection tasks. At the same time, the anchor-based method is replaced by the anchor-free method. This design enables the head part to directly predict the center point position of the target without relying on the offset of the preset anchor box, thereby effectively avoiding errors caused by inaccurate anchor box settings. In addition, the anchor-free method significantly reduces the number of prediction boxes, improves inference efficiency, and speeds up the processing speed of non-maximum suppression (NMS). BRIEF DESCRIPTION OF THE DRAWINGS
[0085] The accompanying drawings are incorporated in and constitute a part of this application and are used to provide a further understanding of the present invention.
[0086] Figure 1 This is a flow chart of a method for detecting defects in transmission line insulators based on dynamic attention guidance and lightweight architecture according to this embodiment.
[0087] Figure 2 This is a structural diagram of a transmission line insulator defect detection method based on dynamic attention guidance and lightweight architecture according to this embodiment.
[0088] Figure 3 FIG. 4 is a network structure diagram of AKConv in this embodiment.
[0089] Figure 4 This is a diagram showing the identification results of an insulator string after identification by a method for detecting defects in insulators of a transmission line based on dynamic attention guidance and lightweight architecture according to this embodiment.
[0090] Figure 5 This is a diagram showing defect location results of an insulator string identified using a transmission line insulator defect detection method based on dynamic attention guidance and lightweight architecture according to this embodiment. DETAILED DESCRIPTION
[0091] The present invention is described in detail below with reference to the accompanying drawings and specific embodiments.
[0092] This embodiment provides a method for detecting transmission line insulator defects based on dynamic attention guidance and a lightweight architecture. By collecting a dataset of transmission line insulator defect images, an improved YOLOv8 network model is constructed, which is then used to identify and detect defects in the insulator defect image dataset. During the model optimization process, the transmission line insulator dataset and loss function are improved to make them more suitable for YOLOv8 model training. Furthermore, combined with the optimized YOLOv8 model, insulator defects can be efficiently identified and detected, achieving a balance between high accuracy and rapid detection.
[0093] Specifically, Figure 1 A flow chart of a method for detecting defects in transmission line insulators based on dynamic attention guidance and lightweight architecture is shown in FIG. Figure 1 As shown, the insulator defect detection method includes the following steps:
[0094] S1, using a camera system carried by a drone to photograph transmission line insulators, obtains a visible light insulator image dataset. The obtained transmission line insulator image dataset includes images of insulators in intact and defective states. Manual data screening is performed to obtain an insulator defect image dataset.
[0095] S2, using an image annotation tool, such as LabelImg software, to manually annotate the insulator defect image data obtained in S1.
[0096] S3, preprocessing the labeled insulator defect image data to generate more training samples and improve the generalization ability of the network model; the preprocessing process includes the following steps:
[0097] S31, resizing the insulator defect image data to scale all insulator defect images to a fixed size required by the network model, specifically to 640×640×3, to ensure consistency in the size of the image data input to the network model;
[0098] S32 uses data augmentation techniques to enhance the image dataset obtained in S31 to generate a more comprehensive insulator defect dataset. Specifically, the image dataset is augmented using PyTorch's integrated functions, such as random cropping, random rotation, scaling, color jittering, and horizontal flipping. For example, by randomly adjusting the cropping range, rotation angle, and flipping direction of the image, a more diverse sample is generated, resulting in a more comprehensive insulator defect dataset. This data augmentation method can significantly improve the generalization and robustness of the network model, making it more stable in complex scenarios.
[0099] S33, normalizing the enhanced image data, i.e. scaling the image pixel values to the range of [0, 1] or [-1, 1], so as to accelerate the convergence speed of the network model training.
[0100] S34, converting each tag name and its corresponding bounding box into a YOLO format annotation, including normalized bounding box coordinates and category labels.
[0101] S4, divide the preprocessed dataset into training set and test set: To ensure that the training and testing of the network model are more scientific and reasonable, the preprocessed dataset is divided into training set and test set in a ratio of 8:2. The output of data preprocessing will be used as training input to ensure that the data in each iteration is properly processed, thereby improving the training effect and accuracy of the model.
[0102] S5, improve the YOLOv8 network model and use the improved network model to identify and detect defects in the insulator defect image dataset. The specific improvement process is as follows:
[0103] S51, such as Figure 3 As shown in the figure, the convolution module of the YOLOv8 network model is replaced by the AKConv module. The AKConv module combines the attention mechanism with the efficient convolution structure. It can dynamically focus on the salient areas in the image, while improving the network's ability to perceive local details and contextual semantics, especially in complex backgrounds, showing better feature extraction results. The specific processing steps are as follows:
[0104] After resizing the input image to 640×640×3, it is input into the improved YOLOv8 network model to extract target features;
[0105] AKConv module, the specific calculation formula is as follows:
[0106] Y=F(X)+A(X)
[0107] Among them, X represents the input feature map, F(X) represents the basic features extracted by group convolution, A(X) is the weighted feature generated by the attention mechanism, and Y is the output feature map.
[0108] The basic information of the input feature map is extracted by grouped convolution. During the grouped convolution extraction process, the input feature map X is divided into multiple sub-feature maps. Each sub-feature map is processed by a convolution kernel, and the generated features are recorded as F. i , the specific calculation formula is as follows:
[0109] F i,j =Φ i (X i,j ),i=1,…,m,j=1,...,s
[0110] Among them, Φ i is the convolution operation corresponding to each group, X i,j is the feature of the jth channel of the i-th group of the input feature map, F i,j is the output sub-feature map, m is the number of groups, and s is the number of channels in each group.
[0111] Subsequently, a dynamic attention mechanism is used to generate weighted features, thereby generating a more adaptable feature expression. The attention mechanism generates a weight map A based on the global context information of the input feature map. i,j and the feature F generated by group convolution i,j The specific formula for fusion is as follows:
[0112] A i,j =σ(W i,j ·GAP(F i,j )),W i,j ∈ c×1
[0113] Among them, GAP represents the global average pooling operation, W i,j is the learned weight, and σ represents the activation function (such as Sigmoid). Through this mechanism, the network can dynamically adjust the feature weights to enhance the saliency of the target area while suppressing background noise.
[0114] Finally, the features generated by the group convolution are fused with the features generated by the attention mechanism, and the output feature map Y is output. During the fusion process, the features of each group are combined through weighted operations. The specific calculation formula is:
[0115]
[0116] Among them, λ i,j is the fusion weight parameter, which can be obtained through network training.
[0117] Through these operations, the AKConv module not only extracts multi-scale features but also fully utilizes contextual information in its feature representation, improving its ability to recognize complex objects. The resulting feature map serves as input to the next layer of the network, enabling accurate object detection.
[0118] S52: Upgrade the C2f module in the neck network of the YOLOv8 network model to the C2f_RVB module. The processing process is as follows: First, the input feature map is extracted and transformed through a lightweight and heavily parameterized convolutional structure to capture multi-scale spatial information. At the same time, the representation capability of the target area is enhanced through deep convolution and global feature fusion mechanism, thereby generating an efficient feature map expression. The specific calculation formula is as follows:
[0119] Y=F rep (X)+Fres (X)
[0120] Among them, X represents the input feature map, F rep (X) is the local feature extracted by the reparameterized convolution (RepConv), F res is the global feature generated by the deep residual connection, and Y is the output feature map.
[0121] In the reparameterized convolution part, the input feature map X is first subjected to a standard convolution operation to extract the basic features F. base , and then multi-scale features are extracted in parallel through the branch structure of 1×1 convolution and 3×3 convolution. The specific calculation formula is as follows:
[0122] F rep =W 1×1 *X+W 3×3 *X+b
[0123] Among them, * represents the convolution operation, W 1×1 and W 3×3 are the weights of the 1×1 and 3×3 convolution kernels respectively, and b is the bias term.
[0124] At the same time, the input feature X is modeled through the residual block for global feature modeling. The specific calculation formula is:
[0125] F res =X+σ(W·BN(X))
[0126] Among them, σ is the activation function (such as ReLU), BN represents the batch normalization operation, and W is the linear transformation matrix. Through this operation, the model can capture the global context information of the input features, thereby enhancing the robustness of the feature representation.
[0127] In the fusion stage, the feature F extracted by the re-parameterized convolution is rep Feature F generated by connecting with the residual res Add point by point to generate the final output feature Y. To further improve the feature expression capability, the RepViTBlocks module performs multi-scale attention processing on the feature map after fusion, and the weight distribution is calculated by the following formula:
[0128] W attn =Softmax(GAP(Y)·W global )
[0129] Among them, GAP represents the global average pooling operation, which is used to extract the global information of the feature map, W global It is the weight matrix of the global features, and the Softmax function normalizes the generated weights to ensure that the contribution of each position in the feature map has a reasonable distribution.
[0130] Finally, the output features of the RepViTBlocks module are obtained by the following formula:
[0131] Y out =W attn ·Y.
[0132] This embodiment introduces the partial channel splitting mechanism of C2f in the convolutional layer of RepViT. The number of channels of the input features of each layer is split into two parts. One part of the channels is passed directly to the next layer without convolution processing (equivalent to a residual connection), and the other part of the channels is subjected to multi-layer convolution for feature extraction. In each C2f module, the channels that have been convolved and the channels that have not been processed are re-fused at a certain stage of the network. This is to ensure that the network can perform effective feature fusion when using shallow features (unconvolved channels) and deep features (convolutional channels). The channel splitting and fusion mechanism can also retain more shallow feature information while reducing the amount of model calculation, enhance gradient flow, and improve feature extraction capabilities by skipping some features and re-fusion after deep convolution processing. In addition, the improved model combines RepViT's reparameterization technology, and can merge multiple convolution branches into an equivalent convolution during the inference stage, thereby further accelerating the inference process. Therefore, the improved structure retains the high inference efficiency of RepViT and has the advantages of C2f in feature fusion and gradient propagation.
[0133] The neck network uses a multi-scale feature fusion method, combined with the C2f_RVB module, to optimize and combine feature maps obtained from the backbone network. The main purpose of this module is to fuse the low-level spatial information of shallow feature maps while preserving the high-level semantic information of deep feature maps, thereby improving the network's ability to detect multi-scale objects. In the FPN structure, the feature map is first compressed through 1×1 convolution, then upsampled to a higher resolution using nearest neighbor upsampling. The upsampled feature map is then combined with the corresponding low-resolution feature map from the backbone network. The C2f_RVB module enhances feature expression capabilities through a reparameterized structure.
[0134] In the PAN architecture of the Neck portion of the network, feature maps are downsampled using 3×3 max pooling. These maps are then further downsampled to a lower resolution using 3×2 convolutions with a stride of 3. 1×1 convolutions are then used to compress the higher-resolution feature maps. These downsampled feature maps are then element-wise added to the high-resolution feature maps from the FPN. The C2f_RVB module effectively integrates multi-scale feature information in this step. By blending local and global semantic information, the final feature representation is more precise, further improving detection performance and network robustness.
[0135] S53, introduce the EMA attention mechanism into the head network of the YOLOv8 network model. The formula of the EMA attention mechanism is as follows:
[0136]
[0137] Where, Represents the EMA characteristic graph after the tth update; represents the EMA feature graph after the t-1th update; F t is the feature map of the current moment; α is the smoothing coefficient of the exponential moving average, which ranges from 0 to 1 and is used to control the importance of the features of the current moment and the historical moments.
[0138] To enhance the attention mechanism, the weights in EMA are weighted based on the spatial information of the feature maps.
[0139] The simple attention mechanism formula can be expressed as:
[0140] Where A ij Represents the attention weight of pixel i, j in the feature map. ij represents the pixel value at position i,j in the current feature map. W is a weight matrix (or vector) used to calculate attention. This formula is similar to the Softmax normalization operation in the classic self-attention mechanism, ensuring that the weight of each pixel is distributed between 0 and 1. This attention weight can then be combined with the feature map in the EMA to enhance the model's capture of important spatial information.
[0141] In this embodiment, the EMA attention mechanism calculates a weighted average of the output features of each convolutional layer and its historical state based on the output of that layer, thereby smoothing feature information and suppressing noise. Specifically, during training, the model not only generates the output feature map at the current moment, but also retains feature map information from several past moments, integrating historical information into the current feature map using an exponentially weighted formula. The introduction of the EMA attention mechanism does not significantly increase the computational complexity of the model, because the EMA update process only requires simple weighting and updating, without involving complex matrix operations or additional parameter learning. In the head network, the current mainstream decoupled head structure is adopted to separate the target classification and detection tasks. At the same time, the anchor-based method is replaced with the anchor-free method. This design enables the head part to directly predict the center point position of the target without relying on the offset of the preset anchor box, thereby effectively avoiding errors caused by inaccurate anchor box settings. In addition, the anchor-free method significantly reduces the number of prediction boxes, improves inference efficiency, and speeds up the processing speed of non-maximum suppression (NMS).
[0142] S54, construct the loss function form of the improved Y0L0v8 network: This loss function aims to improve the network's detection accuracy for targets of different sizes by optimizing the loss calculation method, specifically including fine-tuning the classification loss and bounding box loss, to improve the model's performance in different scenarios.
[0143] The traditional YOLOv8 loss function mainly relies on cross entropy loss to measure the correctness of the target category, but its detection ability for small targets is weak. To this end, the loss function can be weighted in the following way:
[0144]
[0145] Among them, p i is the predicted probability of target category i, λ i is the weighting factor set for category i, for targets of different sizes, λ i It can be adjusted according to the size of the target. For example, for smaller targets, you can increase λ i The value of , enhances the classification signal of small targets.
[0146] In terms of bounding box loss, YOLOv8 typically uses mean squared error or IoU loss. However, traditional MSE loss has low positioning accuracy for small objects and has a more balanced impact on large objects. Therefore, by combining IoU loss and center point error, the accuracy of bounding box regression can be optimized. The optimized bounding box loss function can be expressed as:
[0147] L bbox =α·L IoU +β·L center
[0148] Among them, L IoU is the IoU loss, L center is the deviation loss of the center point of the bounding box, and α and β are weighting coefficients used to balance the importance of the two loss terms.
[0149] Furthermore, the bounding box loss calculation can be scale-adaptive for objects of different sizes. For example, by introducing the object scale factor s, the weight of the loss function corresponding to each object can be adjusted to make the impact of the loss of small and large objects on the network more balanced. The adjustment formula is as follows:
[0150]
[0151] in, is the scale factor of the target, w and h are the width and height of the target bounding box respectively. In this way, for smaller targets, the loss of the bounding box will be amplified, while for larger targets, the loss will be relatively reduced, thereby improving the detection accuracy of targets of different sizes.
[0152] S6. Use the insulator defect image dataset and loss function obtained in S4 to train the improved YOLOv8 network model: Based on the designed loss function form, calculate the loss terms of the model performance during the training process, including binary classification loss and regression loss.
[0153] The calculation formula of the loss function of BCE classification loss is as follows:
[0154] Loss=-w n ·(y n ·log(x n )+(1-y n )·log(1-x n ))
[0155] Among them, w n represents the category weight, y n is the target true value, x n is the predicted value.
[0156] The regression loss part includes DFL loss and CIoU loss.
[0157] DFL loss is a distribution focus loss that can enhance the accuracy of the network in bounding box distribution prediction. Its core is to focus on the confidence distribution of adjacent pixels of the bounding box, making it closer to the position of the true bounding box. The calculation formula of the loss function is as follows:
[0158] DFL(S n ,S n+1 )=-((y n -y)log(S n )+(yy n+1 )log(Sn+1))
[0159] Among them, S n represents the bounding box prediction confidence at the nth time step K, S n+1 is the confidence of the prediction box at the n+1th time step, y n and y n+1 are the ground truth values of the current and next steps respectively.
[0160] The CIoU loss is an optimization loss for bounding box regression in target detection. It comprehensively considers the center point distance and aspect ratio consistency between the predicted box and the true box. The CIoU loss comprehensively considers the overlap and distance between the predicted bounding box and the true bounding box by introducing the IoU indicator and other geometric constraints. The loss function is expressed as follows:
[0161]
[0162] Among them, w g and h g are the width and height of the ground-truth bounding box, w p and h p is the width and height of the predicted bounding box.
[0163] Among them, Distance 2 Represents the square of the Euclidean distance between the center point of the predicted box and the true box, Represents the square of the diagonal length of the minimum enclosing area containing the predicted box and the true box; v is the aspect ratio consistency measure, which is used to optimize the consistency of the aspect ratio of the predicted box and the true box.
[0164] The preprocessed dataset is input into the improved YOLOv8 network model for training, and the final output is the power insulator defect detection results. The training process is as follows:
[0165] An optimized YOLOv8 network model and pre-trained weights on the COCO dataset were used as initial parameters for network training. During training, the model's training and testing environments ran on Ubuntu 21.04, using the Python 3.8 and PyTorch 1.8.2 deep learning detection frameworks. To ensure optimal allocation of computing resources, the epoch count was set to 200, the batch size to 32, and the initial learning rate to 0.001. After training, the model's accuracy was tested on the test set, and the final detection results were output.
[0166] This example uses a deep learning framework built on Python 3.8, PyTorch 1.10, and CUDA 12.1, and utilizes GPU-accelerated training. During training, the Adam optimization algorithm is used to optimize model parameters. The experimental environment configuration and model parameters are shown in Table 1. The pre-trained weights provided by YOLOv8 (yolov8n.pt) are used as the initial reference parameters for model training.
[0167] Table 1 shows the detailed information of the hardware configuration and model parameters of the experimental environment.
[0168]
[0169] This example optimizes the YOLOv8 network by introducing AKConv into the backbone network and upgrading the C2f module in the original YOLOv8 to the C2f_RVB module. This further reduces the model's computational complexity and parameter count while improving its object detection performance. The EMA attention mechanism is also introduced into C2f_RVB to smooth feature weights and mitigate noise from low-level features in detection tasks. This mechanism enables the network to more accurately focus on important features while reducing interference from background noise, thereby improving detection robustness.
[0170] S7. Use the test set to test the trained improved YOLOv8 network.
[0171] This example evaluates the performance of the improved YOLOv8 network model, comprehensively evaluating the performance of the network model to improve the detection accuracy and adaptability of the model. The performance evaluation indicators mainly include precision, recall, average precision, computational complexity, and parameter count. Precision reflects the accuracy of the model's predicted categories. A higher value indicates better classification and recognition results. The specific expression is:
[0172]
[0173] Where TP is the number of positive samples correctly detected by the model, and FP is the number of negative samples that were mistakenly classified as positive samples. A higher precision value indicates a better recognition effect of the model classification.
[0174] The recall rate measures the model's ability to capture real targets. A larger value indicates a lower missed detection rate. The calculation formula is:
[0175]
[0176] Where FN is the number of positive samples that the model did not correctly detect. A higher recall value indicates that the model has a stronger coverage capability for target detection.
[0177] The average precision measures the overall detection performance of the model by the average accuracy of all categories. The higher the value, the more stable the network's detection performance for various types of targets. The calculation formula is:
[0178]
[0179] Among them, m is the total number of categories, AP i is the average precision for each category.
[0180] Furthermore, computational complexity indicates the computational resource consumption of the model; smaller values indicate more efficient network operation. The number of parameters reflects the scale of the network; smaller parameters help reduce model complexity. By comprehensively optimizing these metrics, the model's detection performance and applicability in various scenarios are effectively improved.
[0181] As shown in Table 2, experimental results demonstrate that the transmission line insulator defect detection method based on dynamic attention guidance and a lightweight architecture in this embodiment significantly improves detection accuracy while reducing the number of parameters. Compared with existing algorithms such as RTDETR, YOLOv8, and YOLOv1n, this method offers significant advantages in detection accuracy and parameter optimization.
[0182] Table 2 Experimental comparison results
[0183]
[0184]
[0185] In order to verify the improvement effect of the innovations mentioned in this model on the algorithm, an ablation experiment was conducted on each module. The ablation experiment results are shown in Table 3.
[0186] Table 3 Ablation experiment results
[0187]
[0188] Table 3 shows that the introduction of the C2f_RVB and AKConv modules significantly improves insulator defect detection accuracy while effectively reducing the computational complexity and number of model parameters. This improvement fully demonstrates the ability to maintain high detection accuracy while maintaining a lightweight model, meeting the practical needs of power line inspections.
[0189] As 2 and Figure 3 As shown in FIG, the performance of the insulator identification and positioning algorithm proposed in this embodiment in a specific application. Figure 4 You can see the identification results of the insulator string. Figure 5 The results of locating defects in insulator strings are shown. Figure 4 and Figure 5It can be seen that the present invention has high detection precision and positioning accuracy in insulator defect detection, and the effect is significant.
[0190] In summary, this embodiment proposes a method for detecting transmission line insulator defects based on dynamic attention guidance and a lightweight architecture. By introducing redesigned C2f_RVB and AKConv modules, this method achieves a lightweight design while optimizing the model while ensuring detection accuracy. This method combines the advantages of lightweight design, high precision, and high recall, making it particularly suitable for the deployment of portable devices in the field in the power industry. It can significantly improve the efficiency of power line insulator inspection and provides an innovative technical solution for insulator defect detection.
[0191] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the scope of protection of the present invention. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the essence and scope of the technical solutions of the present invention.
Claims
1. A method for detecting defects in transmission line insulators based on dynamic attention guidance and lightweight architecture, characterized by: The insulator defect detection method comprises the following steps: S1, obtain a visible light insulator image dataset and manually screen the data to obtain an insulator defect image dataset; S2, manually annotating the insulator defect image data obtained in S1 using an image annotation tool; S3, preprocessing the labeled insulator defect image data; S4, divide the preprocessed dataset into training set and test set; S5: Improve the YOLOv8 network model and use it to identify and detect defects in the insulator defect image dataset. The improvement process is as follows: S51, replace the convolution module of the YOLOv8 network model with the AKConv module; S52, upgrade the C2f module in the neck network of the YOLOv8 network model to the C2f_RVB module; S53, introduces the EMA attention mechanism into the head network of the YOLOv8 network model; S54, construct the loss function form of the improved Y0L0v8 network; S6, using the insulator defect image dataset and loss function obtained in S4 to train the improved YOLOv8 network model; S7. Use the test set to test the trained improved YOLOv8 network.
2. The method for detecting defects in transmission line insulators based on dynamic attention guidance and lightweight architecture according to claim 1, characterized in that: In S3, the process of preprocessing the labeled insulator defect image data includes the following steps: S31, resizing the insulator defect image data to scale all insulator defect images to a size required by the network model; S32, performing data enhancement processing on the image data set obtained in S31 using data enhancement technology; S33, performing normalization processing on the enhanced image data; S34, converting each tag name and its corresponding bounding box into a YOLO format annotation.
3. The method for detecting defects in transmission line insulators based on dynamic attention guidance and lightweight architecture according to claim 1, characterized in that: In S4, the preprocessed data set is divided into a training set and a test set in a ratio of 8:
2.
4. The method for detecting defects in transmission line insulators based on dynamic attention guidance and lightweight architecture according to claim 1, characterized in that: In S51, the AKConv module processing steps are as follows: inputting the image into the improved YOLOv8 network model to extract target features; AKConv module, the specific calculation formula is as follows: Y=F(X)+A(X) Where X represents the input feature map, F(X) represents the basic features extracted by group convolution, A(X) is the weighted feature generated by the attention mechanism, and Y is the output feature map; The basic information of the input feature map is extracted by grouped convolution. During the grouped convolution extraction process, the input feature map X is divided into multiple sub-feature maps. Each sub-feature map is processed by a convolution kernel, and the generated features are recorded as F. i , the specific calculation formula is as follows: F i,j =Φ i (X i,j ),i=1,...,m,j=1,…,s Among them, Φ i is the convolution operation corresponding to each group, X i,j is the feature of the jth channel of the i-th group of the input feature map, F i,j is the output sub-feature map, m is the number of groups, and s is the number of channels in each group; Subsequently, weighted features are generated through a dynamic attention mechanism, which generates a weight map A based on the global context information of the input feature map. i,j and the feature F generated by group convolution i,j The specific formula for fusion is as follows: A i,j =σ(W i,j ·GAP(F i,j )),W i,j ∈ c×1 Among them, GAP represents the global average pooling operation, W i,j is the learned weight, σ represents the activation function; Finally, the features generated by the group convolution are fused with the features generated by the attention mechanism, and the output feature map Y is output. During the fusion process, the features of each group are combined through weighted operations. The specific calculation formula is: Among them, λ i,j is the fusion weight parameter, which can be obtained through network training.
5. The method for detecting defects in transmission line insulators based on dynamic attention guidance and lightweight architecture according to claim 1, characterized in that: In S52, the processing process of the C2f_RVB module is as follows: First, the input feature map is extracted and transformed through a lightweight and heavily parameterized convolutional structure to capture multi-scale spatial information. At the same time, the representation capability of the target area is enhanced through a deep convolution and global feature fusion mechanism. The specific calculation formula is as follows: Y=F rep (X)+F res (X) Among them, X represents the input feature map, F rep (X) is the local feature extracted by the reparameterized convolution (RepConv), F res is the global feature generated by the deep residual connection, and Y is the output feature map; In the reparameterized convolution part, the input feature map X is first subjected to a standard convolution operation to extract the basic features F. base , and then multi-scale features are extracted in parallel through the branch structure of 1×1 convolution and 3×3 convolution. The specific calculation formula is as follows: F rep =W 1×1 *X+W 3×3 *X+b Among them, * represents the convolution operation, W 1×1 and W 3×3 are the weights of the 1×1 and 3×3 convolution kernels, and b is the bias term; At the same time, the input feature X is modeled through the residual block for global feature modeling. The specific calculation formula is: F res =X+σ(W·BN(X)) Where σ is the activation function (such as ReLU), BN represents the batch normalization operation, and W is the linear transformation matrix. Through this operation, the model can capture the global context information of the input features, thereby enhancing the robustness of the feature representation; In the fusion stage, the feature F extracted by the re-parameterized convolution is rep Feature F generated by connecting with the residual res The final output feature Y is generated by adding point by point. The RepViTBlocks module performs multi-scale attention processing on the feature map after fusion. The weight distribution is calculated by the following formula: W attn =Softmax(GAP(Y)·W global ) Among them, GAP represents the global average pooling operation, which is used to extract the global information of the feature map, W global It is the weight matrix of the global features, and the Softmax function normalizes the generated weights to ensure that the contribution of each position in the feature map has a reasonable distribution; Finally, the output features of the RepViTBlocks module are obtained by the following formula: Y out =W attn ·Y。 6. The method for detecting defects in transmission line insulators based on dynamic attention guidance and lightweight architecture according to claim 1, characterized in that: In S53, the formula of the EMA attention mechanism is as follows: Where, Represents the EMA characteristic graph after the tth update; represents the EMA feature graph after the t-1th update; F t is the feature map of the current moment; α is the smoothing coefficient of the exponential moving average, which ranges from 0 to 1 and is used to control the importance of the features of the current moment and the historical moments.
7. The method for detecting defects in transmission line insulators based on dynamic attention guidance and lightweight architecture according to claim 6, characterized in that: In the S53, the weights in the EMA are weighted based on the spatial information of the feature map; The simple attention mechanism formula can be expressed as: Where A ij Represents the attention weight of pixel i, j in the feature map, F ij Represents the pixel value of the current feature map at position i, j, and W is a weight matrix used to calculate attention.
8. The method for detecting defects in transmission line insulators based on dynamic attention guidance and lightweight architecture according to claim 1, characterized in that: In S54, the loss function is weighted: Among them, p i is the predicted probability of target category i, λ i is the weighting factor set for category i; By combining IoU loss and center point error, the accuracy of bounding box regression is optimized. The optimized bounding box loss function is expressed as: L bbox =α·L IoU +β·L center Among them, L IoU is the IoU loss, L center is the deviation loss of the bounding box center point, and α and β are weighting coefficients.
9. The method for detecting defects in transmission line insulators based on dynamic attention guidance and lightweight architecture according to claim 8, characterized in that: In the above S54, For targets of different sizes, the bounding box loss calculation is scale-adaptively adjusted. The adjustment formula is as follows: in, is the scale factor of the object, w and h are the width and height of the object bounding box respectively.
10. The method for detecting defects in transmission line insulators based on dynamic attention guidance and lightweight architecture according to claim 1, characterized in that: In S6, based on the designed loss function form, the loss term of the model performance during the training process is calculated, including the binary classification loss and the regression loss, and the regression loss part includes the DFL loss and the CIoU loss; The calculation formula of the loss function of the two-class loss is as follows: Loss=-w n ·(y n ·log(x n )+(1-y n )·log(1-x n )) Among them, w n represents the category weight, y n is the target true value, x n is the predicted value; The calculation formula of the loss function of DFL loss is as follows: DFL(S n ,S n+1 )=-((y n -y)log(S n )+(y-y n+1 )log(Sn+1)) Among them, S n represents the bounding box prediction confidence at the nth time step K, S n+1 is the confidence of the prediction box at the n+1th time step, y n and y n+1 are the true values of the bounding box for the current and next steps respectively; The loss function of CIoU loss is expressed as follows: Among them, w g and h g are the width and height of the ground-truth bounding box, w p and h p To predict the width and height of the bounding box; Distance 2 Represents the square of the Euclidean distance between the center point of the predicted box and the true box, Represents the square of the diagonal length of the minimum enclosing area containing the predicted box and the true box; v is the aspect ratio consistency measure.
Citation Information
Cited By
Sub-cartridge case surface defect detection method and image training and reasoning integrated platform
CN121304597A