A transmission line strain clamp defect detection method based on improved YOLOv8
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- KUNMING UNIV OF SCI & TECH
- Filing Date
- 2026-04-27
- Publication Date
- 2026-07-21
Smart Images

Figure CN122434870A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of power equipment defect detection technology, specifically relating to a method for detecting defects in transmission line tension clamps based on an improved YOLOv8. Background Technology
[0002] Tension clamps are critical hardware components in transmission lines, used to fix and connect conductors, withstand conductor tension, and hang conductors on tension insulator strings or tension clamp supports on towers. The crimping quality of tension clamps directly affects the safe and stable operation of transmission lines. Defects such as inadequate crimping, broken conductor strands, and foreign matter inclusions can lead to increased contact resistance, localized overheating, and even line breakage accidents, seriously threatening power grid safety.
[0003] Traditional inspection of tension clamp defects mainly relies on manual interpretation of X-ray images, which has the following problems: First, the inspection efficiency is low, as manual interpretation of a single X-ray image is time-consuming and cannot meet the needs of large-scale line inspections; second, it is highly subjective, as different inspectors have different experience levels and interpretation standards, resulting in poor consistency of inspection results; third, the rates of missed detection and false detection are high, as minor defects are easily overlooked, and prolonged operation can cause visual fatigue, affecting the accuracy of inspection.
[0004] With the development of deep learning technology, object detection methods based on convolutional neural networks have been widely used in the field of industrial defect detection. Currently, the mainstream object detection algorithms are mainly divided into two categories: one is two-stage detection algorithms, such as the R-CNN series, which first extracts candidate regions and then performs classification and regression, resulting in high detection accuracy but slow speed; the other is single-stage detection algorithms, such as the YOLO series and SSD, which directly complete object localization and classification in the network, resulting in fast detection speed but relatively low accuracy.
[0005] YOLOv8, as the latest version of the YOLO series, has achieved a good balance between detection accuracy and speed. However, it still has the following shortcomings in the application of tension clamp X-ray image defect detection: First, there is a large domain difference between general datasets such as COCO and tension clamp X-ray images, making it difficult to obtain ideal results through direct training; Second, the standard YOLOv8 network is insufficient in detecting small target defects, while internal defects of tension clamps are often small in size and have indistinct features; Third, the detection robustness of a single network model is limited, and its generalization ability is insufficient when facing complex and varied defect types; Fourth, a fixed confidence threshold is difficult to adapt to the detection needs of different defect categories, resulting in a high rate of missed detections or false detections for some categories.
[0006] To address the aforementioned issues, existing technologies have proposed several improvement schemes, such as using data augmentation to expand samples, introducing attention mechanisms to enhance feature representation, and designing multi-scale fusion networks. However, most of these schemes optimize a single aspect and are insufficient to fully meet the comprehensive requirements of high precision, high robustness, and high real-time performance for the detection of defects in tension clamps of transmission lines. Summary of the Invention
[0007] The purpose of this invention is to overcome the shortcomings of the prior art and provide a defect detection method for tension clamps in transmission lines based on an improved YOLOv8. By using transfer learning pre-training, network structure improvement (introducing ECA module, CoordAtt module and Gold-YOLO aggregation-distribution mechanism), confidence adaptive adjustment and multi-model fusion optimization, this invention solves the technical problems of low accuracy in X-ray image defect detection of tension clamps, high false negative rate for small target defects, and insufficient model generalization ability in the prior art.
[0008] To achieve the above objectives, the present invention adopts the following technical solution: A method for detecting defects in tension clamps of transmission lines based on an improved YOLOv8, comprising the following steps: S1. Image data preprocessing: Obtain a set of X-ray images of tension clamps and perform image data preprocessing on the set of X-ray images of tension clamps. S2. Obtaining pre-trained weights: YOLOv8 is pre-trained using the COCO dataset to obtain pre-trained weights; S3. Model Training: The pre-trained weights are loaded into the improved YOLOv8 network, and the improved YOLOv8 network is trained using the pre-processed tension clamp X-ray image sample set to obtain the tension clamp X-ray image defect detection model. S4. Calculation of confidence adjustment coefficient: Calculate the confidence adjustment coefficient. ; S5. Multi-network fusion: Based on the confidence adjustment coefficient It integrates multiple network defect detection models; S6. Defect Detection: The preprocessed X-ray image of the tension clamp after S1 is used to detect defects using the fused multi-network defect detection model, and the defect detection results of the tension clamp X-ray image are output.
[0009] Preferably, the image data preprocessing in step S1 includes: image denoising, image enhancement, image normalization, and image size unification; the image denoising uses median filtering or Gaussian filtering to remove noise from X-ray image acquisition; the image enhancement uses histogram equalization or adaptive gamma correction to enhance the contrast of defect areas; the image normalization normalizes pixel values to the range of [0,1]; the image size unification scales the image to a resolution of 640×640 or 1280×1280 to adapt to network input requirements.
[0010] In step S2, YOLOv8 is pre-trained using object detection category data from the COCO dataset. A multi-scale training strategy is used to obtain pre-trained weights with general object detection capabilities. The multi-scale training strategy randomly changes the size of the input image during training to enhance the model's adaptability to objects of different scales.
[0011] The improved YOLOv8 network described in step S3 includes improvements to three parts: the backbone, the neck, and the head. I. Backbone Network Improvements The backbone network introduces an Efficient Channel Attention (ECA) mechanism, or ECA module, to replace or enhance the channel attention module in the original YOLOv8 backbone network. The ECA module avoids dimensionality reduction operations in channel attention, employing a local cross-channel interaction strategy to achieve efficient channel attention computation through 1D convolution. The ECA module adaptively selects the 1D convolution kernel size to determine the coverage of local cross-channel interactions.
[0012] The core design principles of the ECA module are based on the following key technological insights: (1) Principle of avoiding dimensionality reduction: Through in-depth analysis of the SENet channel attention module, this invention empirically demonstrates that dimensionality reduction is detrimental to learning channel attention. Traditional channel attention mechanisms (such as the SE module) reduce the dimensionality of channel features through fully connected layers and then increase it. This dimensionality reduction-increase process leads to information loss between channels and reduces the feature representation ability. The ECA module operates directly on the original channel features without any dimensionality reduction process, thus fully preserving the information interaction ability between channels.
[0013] (2) Local cross-channel interaction strategy: The ECA module uses 1D convolution to achieve local cross-channel interaction, with each channel interacting only with its own channel. Instead of fully connecting with all channels, it exchanges information with neighboring channels. The mathematical expression of this local interaction strategy is:
[0014] in, This represents the channel feature vectors after global average pooling. The kernel size is 1D convolution operation, It is the Sigmoid activation function. The channel attention weights for the output.
[0015] (3) Adaptive kernel size selection mechanism: To avoid manually adjusting the kernel size The ECA module has developed an adaptive selection method that automatically determines the kernel size based on the channel dimension C:
[0016] in, b are hyperparameters. This indicates taking the nearest odd number. This adaptive mechanism ensures that feature layers of different depths can obtain appropriate local interaction coverage. The coverage is proportional to the channel dimension; the more channels, the larger the interaction range.
[0017] (4) High-efficiency computing architecture: The computation process of the ECA module is as follows: First, global spatial information is obtained through global average pooling (GAP) to generate a 1×1×C feature descriptor; then, the dependencies between channels are learned through adaptive 1D convolution; finally, attention weights are generated through sigmoid activation and multiplied with the original features channel by channel. The entire module contains only about 80 parameters and 4.7e-4 GFLOPs of computation, which can bring more than 2% improvement in Top-1 accuracy compared to the ResNet50 backbone network.
[0018] In the application of X-ray image defect detection for tension clamps, the ECA module can effectively enhance the channel feature response of the defect area, suppress background noise interference, and make the model pay more attention to key defect features such as incomplete crimping and broken strands of wire, while maintaining extremely low computational overhead to meet real-time detection requirements.
[0019] II. Improvements to the Detection Head The detection head introduces the CoordAtt (Coordinate Attention) mechanism, or the CoordAtt module, to replace the standard convolutional operation in the original YOLOv8 detection head. The CoordAtt module embeds positional information into channel attention by performing 1D global pooling of the feature tensor along two spatial directions, aggregating features along the vertical and horizontal directions respectively. This captures long-range dependencies along one spatial direction while preserving precise positional information along the other. The CoordAtt module encodes the resulting feature map into a pair of orientation-aware and position-sensitive attention maps, which are complementaryly applied to the input feature map to enhance the representation of tension clamp defects.
[0020] The core design principle of the CoordAtt module is based on the following key technological insights: (1) Location information embedding principle: Traditional channel attention mechanisms (such as the SE module) compress feature tensors into a single feature vector through 2D global pooling, completely losing spatial location information. However, in object detection tasks, accurate location information is crucial for generating spatially selective attention maps. The CoordAtt module innovatively embeds location information into channel attention, enabling the model to simultaneously focus on "what" (channel information) and "where" (location information).
[0021] (2) Dual 1D Feature Encoding Decomposition Strategy: The CoordAtt module decomposes the traditional 2D global pooling into two parallel 1D feature encoding processes, performing global average pooling along the horizontal direction (X-axis) and the vertical direction (Y-axis) respectively:
[0022]
[0023] in, and Features encoded along the height and width directions, respectively. and These are the coordinates along the height and width directions, respectively. and These represent the height and width of the input feature map, respectively. and The input feature maps are located at the following positions: and The eigenvalues at that location. This decomposition strategy achieves the goal of capturing long-range dependencies along one spatial direction while preserving precise location information along another spatial direction.
[0024] (3) Direction-aware attention map generation mechanism: After concatenating the feature maps of two directions, the feature maps are processed by a shared 1×1 convolution, batch normalization and activation function, and then divided into two independent feature tensors along the spatial dimension. The feature tensors are then processed by two 1×1 convolutions and a sigmoid activation function to generate direction-aware and position-sensitive attention maps respectively.
[0025] ,
[0026] in, The fused feature tensor, BN is batch normalization. For 1×1 convolution operations, and Encoding features in the height and width directions respectively This indicates a splicing operation along a spatial dimension. For h-swish activation function, and These are the attention weights in the height and width directions, respectively. and These are the height and width features after segmentation, respectively.
[0027] (4) Complementary attention fusion principle: The final output generates two-dimensional attention weights by performing an outer product operation on the attention maps of the two directions, and then performs element-wise multiplication with the original input features:
[0028] in, and The output feature maps are located in spatial positions. The original eigenvalues and eigenvalues at that location, and Attention maps in the height and width directions respectively in the 1st and Attention weights for rows. This multiplicative fusion mechanism allows attention maps in two directions to complement each other on the input feature map. Attention in the height direction focuses on "which row" and attention in the width direction focuses on "which column". The combined effect of the two accurately locates the defect.
[0029] (5) Lightweight and efficient design: The CoordAtt module only introduces two 1D global pooling operations and a small number of 1×1 convolutions, which hardly increases the computational overhead. It can be flexibly inserted into lightweight networks such as MobileNetV2 and EfficientNet, and has shown excellent performance in ImageNet classification, object detection and semantic segmentation tasks.
[0030] In the application of X-ray image defect detection for tension clamps, the CoordAtt module can effectively locate defects in key locations such as the crimping area and the end of the conductor, solving the problem that traditional attention mechanisms cannot accurately distinguish the spatial location of defects, and significantly improving the positioning accuracy of small target defects (such as micro-cracks and localized corrosion).
[0031] III. Neck Network Improvement The neck network employs the Gold-YOLO Gather-and-Distribute (GD) mechanism to replace the PANet structure in the original YOLOv8 neck network. This Gold-YOLO Gather-and-Distribute mechanism utilizes convolution and self-attention operations to process information from different network layers. It aggregates features from different layers through a feature alignment module and an information fusion module, and then distributes the fused information back to each layer of the network through an information injection module. The Gold-YOLO Gather-and-Distribute mechanism includes low-order and high-order aggregation and distribution branches, respectively handling larger-sized (… and smaller size () The feature maps are aligned and fused to achieve efficient fusion of multi-scale features.
[0032] The core design principle of the GD mechanism is based on the following key technological insights: (1) Analysis of information fusion bottleneck: Traditional feature pyramid networks (such as FPN and PANet) have two key problems in the information fusion process: First, feature maps at different levels have spatial resolution differences, and direct fusion will lead to feature misalignment; Second, simple element-wise addition or concatenation operations cannot fully explore the semantic association between multi-scale features, resulting in low information fusion efficiency. The GD mechanism solves the misalignment and inefficiency problems in information fusion through an explicit "aggregation-distribution" process.
[0033] (2) Aggregation-Distribution Architecture Design: The GD mechanism adopts a two-stage strategy of "aggregation first, distribution later". In the aggregation stage, the feature alignment module (FAM) and information fusion module (IFM) are used to align and deeply fuse features from different levels; in the distribution stage, the information injection module (Inject) distributes the fused global information back to each level, enhancing the semantic expressive power of each layer's features. This architecture enables efficient interaction between global and local information.
[0034] (3) Low-GD branch principle: For large feature maps of shallow networks (rich in detailed information, suitable for detecting small targets), the Low-GD branch adopts the following processing flow: Low-FAM (Low-Level Feature Alignment Module): Receives features from four levels at different stages of the backbone network, aligns all features to a uniform spatial resolution through adaptive average pooling and bilinear interpolation, and then stitches them together along the channel dimension to achieve spatial alignment of multi-scale features.
[0035] Low-IFM (Low-Order Information Fusion Module): Employs a lightweight RepVGGBlock stacked structure to perform deep fusion of aligned features. During training, RepVGGBlock uses a multi-branch structure (3×3 convolution, 1×1 convolution, and identity mapping), and during inference, it is converted to a single-path 3×3 convolution through structural reparameterization, achieving the best balance between training accuracy and inference speed.
[0036] (4) Principle of High-GD Branch: For small-sized feature maps of deep networks (rich in semantic information, suitable for detecting large targets), the High-GD branch adopts the following processing flow: High-FAM (High-Order Feature Alignment Module): Receives three levels of features from the deep network and aligns the features to the target resolution through adaptive average pooling, achieving spatial unification of high-level semantic features.
[0037] The High-IFM (High-Order Information Fusion) module employs a Transformer-based self-attention mechanism for feature fusion and comprises multiple top-block modules. Each top-block consists of an Attention module and an Mlp module, capturing global dependencies through multi-head self-attention and performing feature transformation via a feedforward network. This design enables the model to establish semantic relationships between long-distance features, enhancing its ability to perceive complex defect scenarios.
[0038] (5) Inject Module Principle: The Inject module is the core component of the GD mechanism, responsible for distributing the aggregated global information back to each level. Its working principle is as follows: Local feature embedding: Channel transformation is performed on the local features of the current layer through 1×1 convolution; Global feature embedding: Channel transformation is performed on the aggregated global features using 1×1 convolution; Global activation generation: Global attention weights are generated through 1×1 convolution and h-sigmoid activation; Adaptive fusion: Based on the spatial size relationship between the current layer and the global features, pooling or interpolation is selected for size alignment, and then weighted fusion is used to generate enhanced features.
[0039] For the output characteristics of the Inject module, The original features of the current level. For the Sigmoid activation function, For global features, This involves embedding global features. This fusion mechanism allows local features to adaptively adjust to the global context while preserving local details.
[0040] (6) Lightweight Neighboring Layer Fusion (LAF) Mechanism: The LAF module is used to improve the fusion of feature maps of adjacent layers. It aligns the feature map size through average pooling and bilinear up / down sampling operations, ensuring that the local features of each layer are rich in information from the direct neighboring layers, forming a progressive information transmission chain.
[0041] (7) MAE-style pre-training strategy: Gold-YOLO was the first YOLO series to introduce MAE (Masked Autoencoder) style self-supervised pre-training. This strategy trains the model to reconstruct the occluded content by randomly masking parts of the input image, forcing the model to learn the structural features and semantic content of the image. This pre-training method does not rely on labeled data and can learn rich visual representations on large-scale unlabeled data, significantly improving the convergence speed and final accuracy of downstream detection tasks.
[0042] In the application of X-ray image defect detection for tension clamps, the GD mechanism effectively integrates shallow detail features through the Low-GD branch, improving the detection capability for small-sized defects (such as micro-cracks and localized poor bonding); it establishes deep semantic associations through the High-GD branch, enhancing the ability to discriminate complex defect scenarios (such as the coexistence of multiple types of defects and defects similar to normal structures); and it achieves effective transmission of global contextual information to each level through the Inject module, enabling the model to significantly improve detection accuracy and robustness while maintaining low inference latency.
[0043] The improved YOLOv8 network described in step S3 also uses the CIoU loss function instead of the original IoU loss function to optimize the bounding box regression accuracy.
[0044] Preferably, the confidence adjustment coefficient in step S4 The calculation formula is:
[0045] in, For the first i The number of correctly detected defects of this type For the first i The total number of class defects, For the first i Average accuracy of class defects, This represents the maximum average accuracy across all defect categories. The confidence adjustment coefficient comprehensively considers both detection accuracy and category performance differences, enabling adaptive adjustment of detection confidence for different defect categories.
[0046] Preferably, the multi-network defect detection model fusion described in step S5 adopts a confidence-weighted multi-model fusion strategy, and the fusion formula is as follows: in, K represents the final detection confidence score after fusion, and K is the number of network models fused. For the first The detection confidence of the network. For the first The confidence adjustment coefficients for each network.
[0047] The multi-network defect detection model in step S5 includes multiple YOLOv8 networks with different improvement strategies. These different improvement strategies include different backbone network structures, different feature pyramid structures, or different combinations of loss functions.
[0048] The defect detection in step S6 includes: locating the defect target, identifying the defect category, and scoring the defect confidence score on the input X-ray image of the tension clamp, and outputting the detection result containing the coordinates of the defect bounding box, the defect category label, and the confidence score; the defect categories include incomplete crimping, broken wire strands, foreign matter inclusions, crack defects, and corrosion defects.
[0049] The beneficial effects of this invention are as follows: (1) This invention uses the COCO dataset to pre-train YOLOv8 and effectively alleviates the problem of insufficient X-ray image samples of tension clamps through transfer learning strategy, improves the feature extraction capability and convergence speed of the model, and enables the model to obtain better detection performance under limited sample conditions.
[0050] (2) The present invention introduces an ECA module into the backbone network. Through innovative designs such as avoiding dimensionality reduction operations, local cross-channel interaction and adaptive convolution kernel selection, it achieves significant channel attention effect with very few parameters (only 80) and very low computational cost (4.7e-4 GFLOPs), effectively enhancing the feature representation ability of the tension clamp defect area, and bringing more than 2% accuracy improvement while maintaining low model complexity.
[0051] (3) The present invention introduces the CoordAtt module in the detection head. Through innovative designs such as dual 1D feature encoding decomposition, direction-aware attention map generation and complementary attention fusion, the position information is embedded in the channel attention, enabling the model to pay attention to "what" and "where" at the same time. This effectively solves the problem that standard channel attention ignores position information, significantly improves the positioning accuracy of small defects inside the tension clamp, and hardly increases the computational overhead.
[0052] (4) This invention adopts the Gold-YOLO aggregation-distribution mechanism in the neck network. Through the collaborative design of the low-order aggregation distribution (Low-GD) branch and the high-order aggregation distribution (High-GD) branch, combined with core components such as feature alignment module (FAM), information fusion module (IFM), information injection module (Inject) and lightweight neighboring layer fusion (LAF), it realizes efficient aggregation and distribution of multi-scale features. For the first time, MAE style pre-training is introduced in the YOLO series. Through self-supervised learning, the model's ability to understand image features is improved, and the detection ability of defects of different sizes is significantly improved while maintaining low latency.
[0053] (5) The present invention proposes a confidence adjustment coefficient calculation method, which dynamically adjusts the confidence threshold according to the detection performance of different defect categories, effectively solving the problem of uneven detection performance between categories caused by fixed thresholds and reducing the false negative rate of difficult-to-detect defect categories.
[0054] (6) The present invention adopts a confidence-weighted multi-model fusion strategy to integrate the detection results of multiple improved YOLOv8 networks, give full play to the complementary advantages of each network, improve the overall robustness and generalization ability of the detection system, and adapt to the complex and ever-changing field detection environment.
[0055] (7) This invention realizes the automated and intelligent detection of X-ray image defects of tension clamps. It has high detection efficiency and good consistency, can replace manual interpretation, greatly reduce detection costs, and provide reliable protection for the safe operation of transmission lines. Attached Figure Description
[0056] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0057] Figure 1 A flowchart illustrating the overall process of the transmission line tension clamp defect detection method based on the improved YOLOv8 provided in this embodiment of the invention. Figure 2A schematic diagram of the improved YOLOv8 network architecture provided in this embodiment of the invention; Figure 3 This is a schematic diagram of the structure of the ECA attention module provided in an embodiment of the present invention; Figure 4 This is a schematic diagram of the CoordAtt attention module provided in an embodiment of the present invention; Detailed Implementation
[0058] The present invention will be further described below with reference to the accompanying drawings and specific embodiments.
[0059] Example 1, as Figure 1 As shown in the figure, this invention provides an overall flowchart of a method for detecting defects in transmission line tension clamps based on an improved YOLOv8. The method includes the following steps: Step 1: Image Data Preprocessing In this step, image data preprocessing is a fundamental step in defect detection, directly affecting the training effect and detection accuracy of subsequent models. The specific preprocessing process is as follows: (1) Image acquisition and sample set construction: X-ray images of tension clamps are acquired through X-ray digital imaging equipment to construct the original image sample set. The image format is usually DICOM or TIFF, the bit depth is 16 bits or 8 bits, and the spatial resolution is determined according to the equipment parameters, generally 0.1 mm / pixel to 0.5 mm / pixel.
[0060] (2) Image denoising: Median filtering or Gaussian filtering is used to remove random noise and salt-and-pepper noise generated during X-ray image acquisition. The median filter kernel size is set to 3×3 or 5×5, which is suitable for removing impulse noise; the Gaussian filter kernel size is set to 5×5, and the standard deviation σ is set to 1.0, which is suitable for smoothing Gaussian noise. For the inherent texture noise generated by the internal structure of the clamp, bilateral filtering can be used for edge-preserving denoising.
[0061] (3) Image enhancement processing: Adaptive histogram equalization (CLAHE) is used to enhance the contrast between defective and normal areas. The clip limit parameter of CLAHE is set to 2.0, and the tile grid size is set to 8×8. For local overexposure or underexposure issues in the pressing area, adaptive gamma correction is used for dynamic range adjustment. The gamma value is adaptively calculated based on the image grayscale distribution, and the formula is:
[0062] in, This represents the average grayscale value of the image.
[0063] (4) Image normalization: The pixel values of the 16-bit depth image are normalized to the floating-point range of [0,1]. The normalization formula is as follows: in, These are the original pixel values. and These are the minimum and maximum pixel values of the image, respectively.
[0064] (5) Image size normalization: The normalized image is scaled to a fixed size required by the network input. This embodiment uses two input sizes, 640×640 and 1280×1280, for fast detection and fine detection modes, respectively. The scaling uses a bilinear interpolation algorithm to maintain the image aspect ratio, and fills the insufficient parts with a grayscale value of 128.
[0065] (6) Data augmentation: To alleviate the problem of insufficient samples, data augmentation is performed on the training set, including random rotation, random scaling, random flipping, random brightness adjustment, random contrast adjustment, and augmentation techniques such as Mosaic and MixUp.
[0066] Step 2: Obtaining Pre-trained Weights In this step, a transfer learning strategy is employed, using the large-scale general dataset COCO to pre-train YOLOv8, obtaining pre-trained weights with general object detection capabilities. The specific process is as follows: (1) COCO Dataset Preparation: Download the COCO 2017 dataset, which contains 118K training images and 5K validation images, covering 80 common object categories. Convert the dataset annotation format to YOLO format, that is, each image corresponds to a txt file, and each line records the category ID and normalized bounding box coordinates of an object.
[0067] (2) YOLOv8 Basic Network Configuration: YOLOv8n (nano), YOLOv8s (small), YOLOv8m (medium), or YOLOv8l (large) are used as the basic architecture, and the appropriate scale is selected according to the computing resources and accuracy requirements. In this embodiment, YOLOv8n is used as an example. Its backbone network is CSPDarknet, its neck network is PANet, and its detection head is a decoupled head.
[0068] (3) Pre-training hyperparameter settings: The number of training epochs was set to 300, the batch size to 16, the initial learning rate to 0.01, the cosine annealing learning rate scheduling strategy was adopted, the momentum was set to 0.937, the weight decay was set to 0.0005, and the optimizer was SGD. Data augmentation was performed using Mosaic (probability 1.0), MixUp (probability 0.15), and random affine transformations.
[0069] (4) Saving pre-trained weights: After training is completed, save the model weight file (usually best.pt) corresponding to the best validation mAP as the initial weights for subsequent training of the tension clamp defect detection model.
[0070] Step 3: Improve YOLOv8 network construction and training In this step, pre-trained weights are loaded into a pre-constructed improved YOLOv8 network, and fine-tuned using a pre-processed set of X-ray images of tension clamps to obtain a model specifically designed for detecting defects in tension clamps. The network improvement consists of three parts: a backbone network, a neck network, and a detection head.
[0071] (1) Embedding of ECA module in backbone network: An ECA attention module is embedded after each C2f module in the YOLOv8 backbone network. Specifically, the embedding positions are: after the 2nd C2f module (corresponding to P2 features, 80×80 resolution), after the 4th C2f module (corresponding to P3 features, 40×40 resolution), after the 6th C2f module (corresponding to P4 features, 20×20 resolution), and after the 8th C2f module (corresponding to P5 features, 10×10 resolution).
[0072] ECA module parameter settings: For the P2 feature layer (128 channels), adaptive kernel size. =3; for the P3 feature layer (256 channels). =5; for the P4 feature layer (512 channels). =5; for the P5 feature layer (1024 channels). =7. Hyperparameters Set to 2, Set it to 1.
[0073] (2) Replacement of the neck network GD mechanism: Replace the PANet structure of the original YOLOv8 neck network with the aggregation-distribution (GD) mechanism of Gold-YOLO. The specific configuration is as follows: The Low-GD branch receives features from four layers of the backbone network: P2, P3, P4, and P5, with 128, 256, 512, and 1024 channels respectively. The Low-FAM module aligns P2 and P3 to the P4 size (20×20) using adaptive average pooling, and aligns P5 to the P4 size using bilinear interpolation upsampling. These are then concatenated along the channel dimension, resulting in an output of 1920 channels. The Low-IFM module contains three RepVGGBlocks with an embedding dimension of 512, producing an output of 512 channels.
[0074] The High-GD branch receives fused features from the Low-GD output and P5 features. The High-FAM module aligns features to a 10×10 resolution using adaptive average pooling. The High-IFM module contains two top blocks, with an embedding dimension of 512, a key dimension of 64, an attention head count of 8, an MLP ratio of 4, and an attention ratio of 2.
[0075] Inject Modules: Four Inject modules are set up to inject the fused global information back into the four layers P2, P3, P4, and P5, respectively. The number of input and output channels of each Inject module matches the corresponding layer, and the global index global_index is determined based on the source of the fused features.
[0076] (3) Embedding the CoordAtt module in the detection head: The CoordAtt coordinate attention module is embedded before the classification and regression branches of the YOLOv8 decoupling head. Specifically, for each detection layer (P3, P4, P5), one CoordAtt module is embedded in both the classification and regression branches, the reduction ratio is set to 32, and the number of intermediate channels (mip) is calculated as max(8, inp / / 32).
[0077] The CoordAtt module captures positional information through dual 1D global pooling, enhances nonlinear expressive power through the h-swish activation function, and finally performs element-wise multiplication between the generated direction-aware attention map and the original features to enhance defect localization accuracy.
[0078] (4) Loss function configuration: The CIoU (Complete Intersection over Union) loss function is used instead of the original IoU loss. The CIoU loss considers the overlapping area of the bounding boxes, the distance between the center points, and the consistency of the aspect ratio. The formula is as follows:
[0079] in, CIoU represents the bounding box loss function value, where IoU is the intersection-over-union ratio. For Euclidean distance, and , where are the center points of the predicted bounding box and the ground truth bounding box, respectively, and c is the diagonal distance of the minimum closure region. As a measure of aspect ratio consistency, These are the balancing parameters.
[0080] The classification loss uses either Variational Loss (VFL) or Focal Loss to address the imbalance between positive and negative samples. The total loss is:
[0081] in, This is the total loss function value. Weights for bounding box regression loss. The CIoU bounding box loss function value, For classification loss weights, Varifocal classification loss, For the distribution focus loss weights, This represents the regression loss of DFL.
[0082] (5) Fine-tuning training hyperparameter settings: The training epochs were set to 200, the batch size to 8 (adjustable due to memory limitations), and the initial learning rate to 0.001 (1 / 10 of the pre-trained weights). A warm-up strategy was used, with the learning rate increasing linearly for the first 3 epochs. The backbone network was frozen for the first 50 epochs, training only the neck and detection heads. After unfreezing, the entire network was fine-tuned. The optimizer used was AdamW, with weight decay set to 0.05.
[0083] (6) Model evaluation and storage: The model performance is evaluated on the validation set every 10 rounds. Evaluation metrics include mAP@0.5, mAP@0.5:0.95, F1-score, FPS, etc.
[0084] Step 4: Calculation of confidence adjustment coefficient In this step, after model training is complete, confidence adjustment coefficients for various defects are calculated based on the validation set performance. These coefficients are then used for subsequent multi-model fusion and inference optimization. The specific process is as follows: (1) Validation set inference: The trained improved YOLOv8 model is inferred on the validation set. A low initial confidence threshold (e.g., 0.1) is set to retain more detection results for analysis.
[0085] (2) Confusion matrix construction: Based on the inference results and the actual annotations, a confusion matrix is constructed, and the number of correct detections for each type of defect is counted. Number of false positives and the number of missed detections The total number of tests is:
[0086] (3) AP Calculation for Each Category: Plot the Precision-Recall Curve for each category and calculate the Average Precision (AP). AP calculation uses either the 11-point interpolation method or the 101-point interpolation method.
[0087] in, Let be the interpolation precision at recall r.
[0088] (4) Calculation of confidence adjustment coefficient: Calculate the confidence adjustment coefficient for each category according to the formula:
[0089] in, For the first i The number of correctly detected defects of this type For the first i The total number of class defects, For the first i Average accuracy of class defects, The first term represents the maximum average accuracy across all defect categories. The second item reflects the accuracy of the test. This reflects the relative performance level of the category. For categories that are difficult to detect (such as microcracks)... If the value is small, its confidence weight should be reduced during subsequent fusion to avoid false detections; for categories that are easy to detect (such as improper crimping). A larger number of samples increases the confidence weight and ensures a higher recall rate.
[0090] (5) Adaptive threshold determination: based on Calculate the adaptive inference threshold for each category:
[0091] in, The base threshold. For hard-to-detect categories, Small, Larger categories raise the entry threshold and reduce false positives; for easily detectable categories, big, Smaller size, lower entry barriers, and increased recalls.
[0092] Step 5: Construction of Multi-Network Fusion Model In this step, a confidence-weighted multi-network fusion model is constructed, integrating multiple YOLOv8 networks with different improvement strategies to enhance the robustness and generalization ability of the detection system.
[0093] (1) Multi-network architecture design: Three improved YOLOv8 networks were constructed, each employing a different improvement strategy: Network A (ECA-Gold): The backbone network embeds ECA modules, the neck network adopts the Gold-YOLO GD mechanism, and the detection head is a standard decoupled head.
[0094] Network B (CoordAtt-PANet): The backbone network is the standard CSPDarknet, the neck network is the improved PANet (with an added small target detection layer), and the detection head is embedded with the CoordAtt module.
[0095] Network C (ECA-CoordAtt-Gold): The backbone network embeds an ECA module, the neck network uses the GD mechanism, the detection head embeds a CoordAtt module, and the EIoU loss function is used.
[0096] (2) Independent training and weight acquisition: The three networks were trained independently, and the optimal weights and corresponding confidence adjustment coefficients of each network were obtained according to the procedures in Examples 3 and 4. .
[0097] (3) Fusion Strategy Design: For the input image, inference is performed through three networks to obtain their respective detection results. For multiple detection boxes of the same target, Soft-NMS or Weighted Boxes Fusion (WBF) is used for box fusion. For confidence fusion, a method based on... Weighted average:
[0098] in, These represent the detection confidence levels for the three networks.
[0099] (4) Dynamic weight adjustment: In practical applications, the fusion weights are dynamically adjusted based on the real-time performance of each network on the validation set. If a network's performance on a specific type of defect continues to decline, its corresponding weight is reduced. To achieve adaptive fusion.
[0100] Step Six: Defect Detection Reasoning Process In this step, the fused multi-network defect detection model is used to detect defects in the X-ray image of the tension clamp to be tested, and the final defect detection result is output.
[0101] (1) Parallel inference of multiple networks: The preprocessed image is input into three improved YOLOv8 networks in parallel to obtain the detection results of each network. The output of each network includes: detection box coordinates (x1, y1, x2, y2), class label, and confidence score.
[0102] (2) Detection result fusion: The WBF (Weighted Boxes Fusion) algorithm is used to fuse the detection boxes from multiple networks. The WBF algorithm calculates the weighted average box coordinates based on the confidence level and box overlap of each network. The formula is as follows:
[0103]
[0104] The coordinates of the merged bounding box. For the first The fusion weights of the predicted bounding boxes, For the first The coordinates of each prediction box. No. The confidence score of each predicted box. For the first The intersection-union ratio of each predicted bounding box and the fused bounding box. It is a very small constant.
[0105] (3) Post-processing optimization: Post-processing is performed on the fused detection results, including: NMS deduplication: Use DIoU-NMS or Soft-NMS to remove overlapping detection boxes, with the IoU threshold set to 0.65.
[0106] Confidence filtering: Adaptive thresholds based on each category Filter out low-confidence detections.
[0107] Edge filtering: Removes false detections located at the edges of the image (which may be caused by filled areas).
[0108] (4) Output of results: The final output is a defect detection report containing the following information: defect bounding box coordinates (pixel-level precision); defect category label (incomplete crimping / broken wire strand / foreign object inclusion / crack defect / corrosion defect); defect confidence score (range 0-1); screenshot of the defect area; and detection timestamp.
[0109] (5) Visualization: Draw detection boxes on the original X-ray image, use different colors to mark different categories, and label the category name and confidence score.
[0110] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for detecting defects in transmission line tension clamps based on an improved YOLOv8, characterized in that, Includes the following steps: S1. Image data preprocessing: Obtain a set of X-ray images of tension clamps and perform image data preprocessing on the set of X-ray images of tension clamps. S2. Obtaining pre-trained weights: YOLOv8 is pre-trained using the COCO dataset to obtain pre-trained weights; S3. Model Training: The pre-trained weights are loaded into the constructed improved YOLOv8 network, and the improved YOLOv8 network is trained using the pre-processed tension clamp X-ray image sample set to obtain the tension clamp X-ray image defect detection model. S4. Calculation of confidence adjustment coefficient: Calculate the confidence adjustment coefficient; S5. Multi-network fusion: Based on the confidence adjustment coefficient, fuse multiple network defect detection models; S6. Defect Detection: The preprocessed X-ray image of the tension clamp after S1 is used to detect defects using the fused multi-network defect detection model, and the defect detection results of the tension clamp X-ray image are output.
2. The method for detecting defects in transmission line tension clamps based on improved YOLOv8 according to claim 1, characterized in that, The image data preprocessing in step S1 includes: image denoising, image enhancement, image normalization, and image size unification.
3. The method for detecting defects in transmission line tension clamps based on improved YOLOv8 according to claim 1, characterized in that, In step S2, YOLOv8 is pre-trained using object detection category data from the COCO dataset, and pre-trained weights with general object detection capabilities are obtained through a multi-scale training strategy.
4. The method for detecting defects in transmission line tension clamps based on improved YOLOv8 according to claim 1, characterized in that, The improved YOLOv8 network described in step S3 includes improvements to three parts: the backbone network, the neck network, and the detection head. The backbone network introduces an ECA module, which avoids dimensionality reduction operations in channel attention and adopts a local cross-channel interaction strategy to achieve efficient channel attention calculation through 1D convolution. The detection head incorporates the CoordAtt module, which embeds positional information into the channel attention. By performing 1D global pooling of the feature tensor along two spatial directions, it aggregates features along the vertical and horizontal directions respectively, capturing long-distance dependencies along one spatial direction while retaining precise positional information along the other spatial direction. The neck network adopts the Gold-YOLO aggregation-distribution mechanism. The Gold-YOLO aggregation-distribution mechanism uses convolution and self-attention operations to process information from different layers of the network. It aggregates features from different layers through a feature alignment module and an information fusion module, and distributes the fused information back to each layer of the network through an information injection module.
5. The method for detecting defects in transmission line tension clamps based on improved YOLOv8 according to claim 4, characterized in that, The ECA module determines the coverage of local cross-channel interactions by adaptively selecting the 1D convolution kernel size.
6. The method for detecting defects in transmission line tension clamps based on improved YOLOv8 according to claim 4, characterized in that, The CoordAtt module encodes the resulting feature map into a pair of direction-aware and position-sensitive attention maps, which are complementary to the input feature map to enhance the representation of the tension clamp defect object.
7. The method for detecting defects in transmission line tension clamps based on improved YOLOv8 according to claim 4, characterized in that, The Gold-YOLO aggregation-distribution mechanism includes low-order aggregation-distribution branches and high-order aggregation-distribution branches, respectively for... and The feature maps are aligned and fused to achieve efficient fusion of multi-scale features.
8. The method for detecting defects in transmission line tension clamps based on improved YOLOv8 according to claim 1, characterized in that, Confidence adjustment coefficient in step S4 The calculation formula is: ; in, For the first i The number of correctly detected defects of this type For the first i The total number of class defects, For the first i Average accuracy of class defects, This represents the maximum average accuracy across all defect categories.
9. The method for detecting defects in transmission line tension clamps based on improved YOLOv8 according to claim 1, characterized in that, The multi-network defect detection model described in step S5 adopts a confidence-weighted multi-model fusion strategy, and the fusion formula is as follows: ; in, K represents the final detection confidence score after fusion, and K is the number of network models fused. For the first The detection confidence of the network. For the first The confidence adjustment coefficients for each network.
10. The method for detecting defects in transmission line tension clamps based on improved YOLOv8 according to claim 1, characterized in that, The multi-network defect detection model mentioned in step S5 includes multiple YOLOv8 networks with different improvement strategies. The different improvement strategies include different backbone network structures, different feature pyramid structures, or different combinations of loss functions. The defect detection in step S6 includes: locating the defect target, identifying the defect category, and scoring the defect confidence score on the input X-ray image of the tension clamp, and outputting the detection result containing the defect bounding box coordinates, defect category label, and confidence score; The defect categories include: undervoltage in grooves, flash, overvoltage in aluminum tubes, undervoltage in aluminum stranded wires, and broken core wires.