A kind of lightweight model-based strain clamp defect detection method

By constructing a lightweight Faster-YOLO model and combining the K-means algorithm and EIoU loss function, the problem of tension clamp crimping quality inspection was solved, and efficient and accurate defect detection was achieved on edge devices.

CN117237327BActive Publication Date: 2025-11-28ZATE ELECTRICAL POWER TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311337875.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-16
Publication Date
2025-11-28
Estimated Expiration
2043-10-16

AI Technical Summary

Technical Problem

In existing technologies, the crimping quality of tension clamps is difficult to detect effectively, leading to potential power accident risks. Furthermore, deep learning networks are difficult to deploy on edge devices and have high computational resource requirements.

Method used

A lightweight Faster-YOLO model is adopted, combined with the K-means algorithm and EIoU loss function to construct a lightweight target detection network. Through lightweight backbone feature extraction and neck feature fusion network, the localization and classification of tension clamp defects are realized.

Benefits of technology

Precise location and classification of tension clamp defects were achieved on edge devices, reducing computing resource requirements and improving detection efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117237327B_ABST
    Figure CN117237327B_ABST
Patent Text Reader

Abstract

The application discloses a kind of based on lightweight model's strain clamp defect detection method, collect the strain clamp X-ray image formed by power grid inspection personnel using X-ray nondestructive testing technology, construct transmission line strain clamp X-ray image dataset, utilize K-means algorithm to the real frame of dataset clustering, generate and the anchor frame of the size matching of each kind of defect of strain clamp;Based on the pre-training weight of VOC public dataset, build Faster-YOLO target detection model, using the strain clamp X-ray image dataset after pre-processing continues to train, realize migration learning, obtain the defect detection model of strain clamp;Strain clamp X-ray image is input into the model after training and is tested, realize the positioning and classification of strain clamp defect.The application can accurately realize the positioning and identification of defect in strain clamp X-ray image while lightening the model, provide reference for the deployment of strain clamp defect detection model in edge device.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application belongs to the technical field of power transmission line monitoring image data processing, and particularly relates to a strain clamp defect detection method based on a lightweight model. BACKGROUND

[0002] The strain clamp is an important fitting in the power transmission line, which is formed by pressing an aluminum pipe with a steel anchor and a steel core aluminum stranded wire, is often connected with the power transmission wire, and is installed at the junction of the crossing pole tower, and needs to bear all the tension between the wires and serve as a carrier of electric current. Once the pressed strain clamp is put into use, it is difficult to disassemble and replace, so the pressing quality directly affects the safe and stable operation of the power transmission line. However, the pressing of the strain clamp is a secret project, and the pressing quality is closely related to the technical level and operation specification of the staff, and it is impossible to judge the quality of the pressed strain clamp from the appearance. Once the unqualified strain clamp is put into use, it is easy to cause local overheating under the condition of heavy load, thereby damaging the wire or reducing the threshold of the strain that can be borne by itself, and is easy to cause rupture under the condition of wind vibration or icing of the wire, thereby causing serious power accidents. Therefore, an efficient method is needed to detect the quality of the strain clamp before it is put into operation and in the working state, so as to ensure the safe operation of the power system.

[0003] Compared with traditional detection methods such as grip strength experiment, ultrasonic detection, and electromagnetic detection, the X-ray image obtained by using X_DR (X-ray digital imaging) technology can clearly reflect the internal structural defects of the strain clamp, and has the characteristics of intuitiveness and detail, and is widely used in the field of defect detection of strain clamps.

[0004] In recent years, the target detection algorithm based on deep learning has been widely applied in the power industry. The deep learning network can automatically extract the features of the target defect to be detected from a large amount of power equipment defect image data, and train and verify the defect detection model, so as to realize the positioning and classification of the defects in the power equipment defect image, and greatly improve the inspection efficiency. However, at present, high complexity and deep network is generally used in the field of X-ray image defect detection of strain clamps, and the parameter quantity is large, a large number of matrix multiplication and iteration calculation are needed during prediction, the demand for massive computing resources is burst, with the proposal of edge intelligent computing device, it becomes more and more difficult to perform model inference on mobile devices, and the lightweight demand of model deployment on low-performance edge devices is not considered. SUMMARY

[0005] In view of this, the purpose of the present application is to provide a strain clamp defect detection method based on a lightweight model, which is used to accurately realize the positioning and classification of the pressing defects in the strain clamp, and provides a reference for the deployment of the strain clamp defect detection model in the edge device.

[0006] To achieve the above object, the application provides the following technical scheme: a strain clamp defect detection method based on a lightweight model, comprising the following steps:

[0007] S1, constructing an X-ray image data set of a strain clamp of a power transmission line, and dividing a training set, a validation set and a test set;

[0008] S2, clustering the real box data of the strain clamp defects by using a K-means algorithm to obtain anchor box parameters matched with the sizes of various defects of the strain clamp;

[0009] S3, building a Faster-YOLO strain clamp X-ray image defect detection network model, which comprises a lightweight backbone feature extraction network, a neck feature fusion network and a detection head for regression prediction;

[0010] The lightweight backbone feature extraction network FasterNet is composed of a Focus module, a CBS module, a FasterNetBlock residual module and a spatial pyramid pooling SPP module, and has a total of 5 parts: the first part is a Focus module, which performs a cutting and slicing operation on the input image, divides the data into 4 parts, each part is equivalent to being obtained under 2 times downsampling, and then the width and height information is fused into the channel information by stacking and splicing in the longitudinal channel; the second to fourth parts are each stacked by one CBS module and one residual module FasterNet Block, in each residual module FasterNet Block, a 3x3 PConv partial convolution is first performed, then a 1x1 convolution operation is performed, after a BN batch normalization layer and a Leaky_ReLU activation function, a 1x1 convolution operation is finally performed, and a residual connection is added between the input and output of the FasterNet Block module; the fifth part is stacked by one CBS module, one SPP module and one FasterNet Block; finally, the feature maps after the third to fifth FasterNet Block modules are selected as the output of the lightweight backbone feature extraction network, and the three output feature maps are respectively input into the neck feature fusion network after passing through a CBAM attention mechanism module, and are respectively named as Feat3, Feat2 and Feat1;

[0011] The neck feature fusion network fuses deep feature maps and shallow feature maps by using a combination of a CBS module, a CARAFE light-weight upsampling operator, a downsampling, a CBAM attention mechanism module and a FasterNet Block module: first, the input feature map Feat1 is subjected to a CBS module to obtain an extracted feature map Layer1, the extracted feature map Layer1 is subjected to a CARAFE light-weight upsampling operator and a CBAM attention mechanism module to obtain an extracted feature map Layer2; after the extracted feature map Layer2 is stacked with the input feature map Feat2, the extracted feature map Layer2 is subjected to a FasterNet Block module and a CBS module to obtain an extracted feature map Layer3, the extracted feature map Layer3 is subjected to a CARAFE light-weight upsampling operator and a CBAM attention mechanism module to obtain an extracted feature map Layer4; after the extracted feature map Layer4 is stacked with the input feature map Feat3, the extracted feature map Layer4 is subjected to a FasterNet Block module to obtain an enhanced feature map P3; the enhanced feature map P3 is subjected to a downsampling and a CBAM attention mechanism module to obtain an extracted feature map Layer5; after the extracted feature map Layer5 is stacked with the extracted feature map Layer3, the extracted feature map Layer5 is subjected to a FasterNet Block module to obtain an enhanced feature map P2; the enhanced feature map P2 is subjected to a downsampling and a CBAM attention mechanism module to obtain an extracted feature map Layer6; after the extracted feature map Layer6 is stacked with the extracted feature map Layer1, the extracted feature map Layer6 is subjected to a FasterNet Block module to obtain an enhanced feature map P1; finally, the three newly generated enhanced feature maps P1, P2 and P3 are input to corresponding three detection heads for regression prediction, and the prediction value is output, and an EIoU loss function is used to calculate the loss value between the prediction value and the true value for back propagation to update the parameters;

[0012] The EIoU loss function includes three parts of calculating an overlap loss, calculating a center distance loss and calculating a width-height loss, and the calculation formula is as follows:

[0013]

[0014] In the formula, B is a prediction box, B i is a true box, b and b gt are center points of the prediction box and the true box respectively, p is the Euclidean distance of the two center points, d is the diagonal distance of the minimum bounding rectangle of the prediction box and the true box, w, w gt , h and h gt are the width and length of the prediction box and the true box respectively, C ω and C h are the width and length of the minimum bounding rectangle covering the two boxes.

[0015] The CARAFE light-weight up-sampling operator includes two parts of up-sampling kernel prediction and feature reorganization. The up-sampling kernel prediction part is composed of a channel compression module, a content coding module and an up-sampling kernel normalization module. For an input feature map with a shape of HxWxC, an up-sampling rate of σ and an up-sampling kernel size of k up ×k up , the channel compression module first compresses the channel number of the input feature map from C to C m using a 1x1 normal convolution, then the content coding module uses a k encoder ×k encoder (k encoder = 3) convolution to predict the up-sampling kernel for the compressed feature map, and the output channel number is σ 2 k up 2, and then the channel dimension is expanded in the spatial dimension to obtain an up-sampling kernel with a shape of σHxσWxk up 2, finally, the up-sampling kernel normalization module uses the Softmax function to normalize each obtained up-sampling kernel so that the convolution kernel weight sum is 1; the feature reorganization part uses the predicted up-sampling kernel to perform up-sampling operation, and the dot product is performed with the corresponding position of the input feature map to obtain the output feature map, wherein different channels at the same position of the input feature map share the same up-sampling kernel;

[0016] S4, set the model parameters and training parameters of the Faster-YOLO strain clamp defect detection model, based on the YOLOv5-l pre-training weight of the VOC public data set, continue training the Faster-YOLO strain clamp defect detection model using the training set and the validation set divided in step S1, and obtain a target model;

[0017] S5, X-ray image defect target detection of strain clamp: input the strain clamp X-ray image to be detected into the target model, obtain three scales of feature layers after deep convolution operation, and correspondingly divide into SxS grids, each grid will be used to predict whether there is a corresponding defect target in the anchor frame corresponding to the grid, and generate all target prediction boxes that meet the confidence condition; finally, the maximum value suppression (NMS) is used for screening the target prediction boxes, and the corresponding defect position and category in the image are output, realizing the target detection of the strain clamp X-ray image defect.

[0018] Further, in step S1, the power grid personnel collects the X-ray image samples of the tension clamp of the power transmission line obtained by using the miniaturized X-ray imaging device during the inspection process, and performs pretreatment operation on the samples; for the pretreated image samples, a target detection label making tool LabelImg is used to label the real frame and the corresponding category of the image, an X-ray image dataset of the tension clamp containing N kinds of defects is constructed, the labeling format is Pascal VOC dataset format, and the labeled dataset is first divided into a training verification set and a test set according to a ratio of 9:1, and then the training verification set is divided into a training set and a verification set according to a ratio of 9:1.

[0019] Further, in step S2, the K-means clustering method is used to cluster the real frame data of the labeled tension clamp defects, 9 sample target frames are first randomly selected as initial clustering centers, the minimum intersection over union of the remaining sample frames and the current clustering center is calculated, and the probability of the remaining sample being selected as the next clustering center is judged, then the next clustering center is selected by using the roulette method, the above process is repeated until 9 clustering centers are selected, and finally 9 anchor frame parameters matched with the size of each defect of the tension clamp are obtained.

[0020] Further, in step S4, based on the YOLOv5-l pre-training weight of the VOC public dataset, the Faster-YOLO tension clamp defect detection model is trained by using Mosaic data enhancement, Mixup data enhancement and SGD optimizer training techniques in the training process.

[0021] Further, in step S5, the optimal weight obtained after training is loaded into the Faster-YOLO model, the X-ray image of the tension clamp to be detected is input, after passing through the lightweight backbone feature extraction network and the neck feature fusion network, three scale feature layers are obtained, and are correspondingly divided into SxS grids, each grid will be used to predict whether there is a corresponding defect target in the 3 anchor frames of the grid, and the position of the anchor frame will be adjusted appropriately, and the coordinates, confidence and category information of all target prediction frames meeting the confidence are generated; finally, the maximum suppression (NMS) is used to screen the target prediction frame, all target prediction frames with a coincidence degree higher than a set value and a confidence lower than a set value in all prediction results are removed, and the target detection of the X-ray image defects of the tension clamp is realized.

[0022] Compared with the prior art, the present application has the following beneficial effects: firstly, the 3D block matching filtering algorithm and the homomorphic filtering algorithm are used to pretreat the sample image, aiming to improve the image quality; secondly, the K-means algorithm is used to cluster the real frame of the data set, to generate anchor frames matched with the sizes of various defects of the strain clamp, so that the model has a higher probability of generating prior frames with good matching degree with the target in the training and prediction process; then, the Faster-YOLO target detection model is used to continue training the pretreated strain clamp X-ray image data set, to obtain a defect detection model of the strain clamp; finally, the strain clamp X-ray image is input into the trained model for testing, to realize the positioning and classification of the defects of the strain clamp. The present application can accurately realize the positioning and identification of the defects in the strain clamp X-ray image while lightening the model, and provides a reference for the deployment of the strain clamp defect detection model in edge devices. BRIEF DESCRIPTION OF DRAWINGS

[0023] Figure 1 The present application is a method flowchart.

[0024] Figure 2 The present application is a Faster-YOLO network structure schematic diagram.

[0025] Figure 3 The present application is a FasterNet structure schematic diagram.

[0026] Figure 4 The present application is a CBAM attention mechanism module structure schematic diagram.

[0027] Figure 5 The present application is a CARAFE light weight upsampling module schematic diagram. DETAILED DESCRIPTION

[0028] The present application is further described below in combination with the embodiments, and it is necessary to point out here that the following embodiments are only used to further illustrate the present application, and cannot be understood as limiting the protection scope of the present application. Some non-essential improvements and adjustments made by the skilled person in the art based on the above application content still belong to the protection scope of the present application.

[0029] A strain clamp defect detection method based on a light weight model, a flowchart thereof is shown in Figure 1 The present application comprises the following steps:

[0030] S1, constructing the X-ray image dataset of the tension clamp of the power transmission line: collecting the X-ray image samples of the tension clamp of the power transmission line obtained by the power grid personnel in the inspection process by using the miniaturized X-ray imaging device. For the image samples, the 3D block matching filter algorithm is used to divide the image samples into multiple small areas in units of blocks, and the purpose of image denoising is achieved by finding similar blocks in the image and averaging these blocks; the homomorphic filter image enhancement algorithm is used to adjust the image brightness range and enhance the image contrast by suppressing low-frequency energy and enhancing high-frequency energy, so as to achieve the purpose of enhancing the details in the image. For the preprocessed image samples, the LabelImg target detection label making tool is used to label the image with true frame and corresponding category.

[0031] In this embodiment, a total of 5655 X-ray image samples of the tension clamp are collected, and an X-ray image dataset of the tension clamp containing five defects is constructed, including five defects: the defect that part of the groove at the connection between the steel anchor groove and the aluminum pipe is not crimped, or there is a gap between the aluminum pipe and the groove is defined as A area leakage pressure; the defect that the end of the conductor is not in line or scattered due to the mispositioning of the crimping position or the overload of the crimping position at the connection between the aluminum strand and the aluminum pipe is defined as C area leakage pressure; the defect that there is obvious bending at the connection between the steel anchor pipe and the steel core is defined as bending; the defect that burrs exist on the surface of the steel anchor pipe due to the failure to smooth the surface of the steel anchor pipe during the crimping process of the steel anchor pipe and the steel core is defined as burr; the defect that the deformation area of the aluminum pipe after crimping exceeds the range of the steel anchor groove, or the deformation area of the aluminum strand after crimping exceeds the range of the aluminum strand, reaching the non-pressure area, is defined as multiple pressure. The labeling format is Pascal VOC dataset format, and the labeled dataset is first divided into a training verification set and a test set in a ratio of 9:1, and then the training verification set is divided into a training set and a verification set in a ratio of 9:1, so that the training set contains 4581 samples, the verification set contains 510 samples, and the test set contains 567 samples.

[0032] S2, clustering the real box data using the K-means algorithm: the detection model proposed by the application contains three scale feature maps, each feature map corresponds to three anchor boxes, therefore, first, randomly select nine sample target boxes as initial clustering centers, take the normalized width and height of the sample target box as the sample features, calculate the minimum intersection over union of the remaining sample boxes with the current several clustering centers and judge the probability of the remaining samples being selected as the next clustering center, add each sample box to the class corresponding to the clustering center with the smallest distance, then use the roulette method to select the next clustering center, repeat the above process until the positions of the nine clustering centers no longer change, and finally obtain nine anchor box parameters matching the sizes of the various defects of the strain clamp, which are [10, 13], [16, 30], [33, 23], [30, 61], [62, 45], [59, 119], [116, 90], [156, 198], and [373, 326].

[0033] S3, building a Faster-YOLO strain clamp X-ray image defect detection network: including a lightweight backbone feature extraction network, a neck feature fusion network, and a detection head for regression prediction, the overall network structure of Faster-YOLO is as shown in Figure 2 .

[0034] The lightweight backbone feature extraction network FasterNet is composed of a Focus module, a CBS module, a FasterNet Block residual module, and a spatial pyramid pooling SPP module, as shown in Figure 3 , which has five parts: the first part is to perform a crop slicing operation on the input image by the Focus module, divide the data into four parts, each part of data is equivalent to being obtained under 2 times downsampling, and then perform vertical channel splicing and stacking to fuse the width and height information into the channel information; the second to fourth parts are each stacked by one CBS module and one residual module FasterNet Block, in each residual module FasterNet Block, first perform a 3x3 PConv partial convolution, then perform a 1x1 convolution operation, then pass through a BN batch normalization layer and a Leaky_ReLU activation function, and finally perform a 1x1 convolution operation again, and add a residual connection between the input and output of the FasterNet Block module; the fifth part is stacked by one CBS module, one SPP module, and one FasterNet Block; finally, select the feature maps after the FasterNet Block modules of the third to fifth parts as the output of the lightweight backbone feature extraction network, and the three output feature maps are respectively input into the neck feature fusion network after passing through a CBAM attention mechanism module, and are named as Feat3, Feat2, and Feat1. The structure of the CBAM attention mechanism module is as shown inFigure 4 As shown, the CBAM attention mechanism module includes two independent attention modules, namely a channel attention module and a spatial attention module. The channel attention module generates a channel attention map using the relationship between feature map channels. First, the spatial information of the feature map is aggregated using maximum pooling and average pooling and input to a multi-layer perceptron. The corresponding elements of the two generated attention vectors are added, and the channel attention feature Mc(F) is obtained by activating the sigmoid function. The spatial attention module generates a spatial attention map using the spatial relationship of the feature map. First, the feature map is averaged and maximized by channel to obtain two spatial attention features and concatenate the features. Then, a 7x7 convolution is performed on the concatenated features, and the spatial attention feature Ms(F') is obtained by activating the sigmoid function. The CBS module is composed of a 2-dimensional convolution Conv2d, a BN batch normalization layer, and a Leaky_ReLU activation function. The SPP spatial pyramid pooling module uses 1x1, 5x5, 9x9, and 13x13 maximum pooling to convert feature maps of any size into fixed-size feature vectors, and improves the receptive field of the network through multi-scale fusion of the feature map.

[0035] The neck feature fusion network fuses deep feature maps and shallow feature maps by combining a CBS module, a CARAFE light-weight upsampling operator, a downsampling, a CBAM attention mechanism module and a FasterNet Block module: first, the input feature map Feat1 obtains an extracted feature map Layer1 after passing through a CBS module, the extracted feature map Layer1 obtains an extracted feature map Layer2 after passing through a CARAFE light-weight upsampling operator and a CBAM attention mechanism module, the extracted feature map Layer2 and the input feature map Feat2 are stacked, and then an extracted feature map Layer3 is obtained after passing through a FasterNet Block module and a CBS module, the extracted feature map Layer3 obtains an extracted feature map Layer4 after passing through a CARAFE light-weight upsampling operator and a CBAM attention mechanism module, the extracted feature map Layer4 and the input feature map Feat3 are stacked, and then an enhanced feature map P3 is obtained after passing through a FasterNet Block module, the enhanced feature map P3 obtains an extracted feature map Layer5 after passing through a downsampling and a CBAM attention mechanism module, the extracted feature map Layer5 and the extracted feature map Layer3 are stacked, and then an enhanced feature map P2 is obtained after passing through a FasterNet Block module, the enhanced feature map P2 obtains an extracted feature map Layer6 after passing through a downsampling and a CBAM attention mechanism module, the extracted feature map Layer6 and the extracted feature map Layer1 are stacked, and then an enhanced feature map P1 is obtained after passing through a FasterNet Block module, finally, the three newly generated enhanced feature maps P1, P2 and P3 are input to the corresponding large, medium and small three detection heads for regression prediction, and the prediction value is output, and the loss value between the prediction value and the true value is calculated by using the EIoU loss function for back propagation to update the parameters.

[0036] The EIoU loss function includes three parts of calculating overlap loss, calculating center distance loss and calculating width and height loss, and the calculation formula is as follows:

[0037]

[0038] In the formula: B is a prediction box, B i is a true box, b and b gt are the center points of the prediction box and the true box respectively, ρ is the Euclidean distance of the two center points, d is the diagonal distance of the minimum bounding rectangle of the prediction box and the true box, ω, ω gt , h, h gt are the width and length of the prediction box and the true box respectively, C ω , C h are the width and length of the minimum bounding rectangle covering the two boxes.

[0039] The CARAFE lightweight up-sampling operator includes two parts: up-sampling kernel prediction and feature reorganization, as shown in the following formula. Figure 5 The up-sampling kernel prediction part is composed of a channel compression module, a content coding module and an up-sampling kernel normalization module. For an input feature map with a shape of HxWxC, the up-sampling rate is σ, and the up-sampling kernel size is k up ×k up . First, the channel compression module uses a 1x1 ordinary convolution to compress the channel number of the input feature map from C to C m . Then, the content coding module uses a k encoder ×k encoder (k encoder = 3) convolution to predict the up-sampling kernel of the compressed feature map, and the output channel number is σ 2 k up 2 Then, the channel dimension is expanded in the spatial dimension to obtain an up-sampling kernel with a shape of σHxσWxk up 2 Finally, the up-sampling kernel normalization module uses the Softmax function to normalize each obtained up-sampling kernel so that the convolution kernel weight sum is 1. The feature reorganization part uses the predicted up-sampling kernel to perform up-sampling operation, and the dot product is obtained with the input feature map at the corresponding position, to obtain the output feature map, wherein different channels at the same position of the input feature map share the same up-sampling kernel.

[0040] S4, set the model parameters and training parameters of the Faster-YOLO tension clamp defect detection model, and train: based on the YOLOv5-l pre-training weight of the VOC public data set, the idea of transfer learning is used, and the training set and the validation set divided in step S1 are used to continue training the Faster-YOLO tension clamp defect detection model. During the training process, 50% of the image samples in each batch use Mosaic data augmentation, and 50% of the image samples in these image samples use Mixup data augmentation; the SGD optimizer is used to speed up the gradient descent speed, wherein the momentum value is set to 0.937; the maximum learning rate of the model is set to 1x10 -2 , the minimum learning rate is set to 0.01 times of the maximum learning rate, and the learning rate reduction method uses the cosine annealing algorithm; during the training process, the training rounds are set to 300 rounds, of which the first 50 rounds are frozen training, the minimum batch size is 8, and the last 250 rounds are unfreezing training, the minimum batch size is 4, the weight is reserved once every 10 rounds, and the validation evaluation is performed once, and finally the weight with the best validation result is selected as the target model weight;

[0041] S5, input the X-ray image of the strain clamp to be detected into the target model for detection: in the present example, the optimal training weight with the best verification result after training is loaded into the network as the final target model, the X-ray image of the strain clamp to be detected is input into the target model, after deep convolution operation, three scale feature layers of large, medium and small are obtained, and are correspondingly divided into SxS grids, each grid will be used to predict whether there is a corresponding defect target in the anchor frame corresponding to the grid, and generate all target prediction boxes meeting the confidence condition; finally, the maximum value suppression (NMS) is used for screening the target prediction boxes, and the prediction boxes with confidence score lower than the set value and overlap degree higher than the set value in the prediction result are removed, wherein the confidence is set to 0.5 and the overlap degree is set to 0.3, after the screening of the target box, the image and the corresponding defect position and category in the image are output, and the target detection of the X-ray image defect of the strain clamp is realized.

[0042] The experiment of the present application is completed under the software environment of Python3.7 as the compiling language, Pytorch 1.8.0 as the deep learning framework, the hardware environment of AMD Ryzen7 as the CPU, 2.90GHz as the main frequency, NVIDIA GeForce GTX 3080 as the GPU, and 8GB as the display memory, and the Faster-YOLO target detection model of the present application is evaluated by using the commonly used evaluation indexes in the target detection field, such as the average precision mean (mAP), the parameter quantity (Prameters) and the frame rate per second (FPS), the average precision (AP), the precision (Precision), the recall (Recall) and the F1 balance score. The experimental results show that after testing 567 test sets, the average precision mean of 5 defects reaches 93.93%, the model parameter quantity is only 32.53M, the frame rate per second can reach 32.41, and the specific detection result parameters of 5 defects are shown in Table 1, which verifies the feasibility of the X-ray image defect detection method of the strain clamp of the power transmission line based on the Faster-YOLO of the present application, and can provide a reference for the deployment of the strain clamp defect detection model in the edge device.

[0043] Table 1 Specific defect detection result of Faster-YOLO X-ray image defect detection model of strain clamp of power transmission line

[0044]

[0045] The above only expresses the preferred embodiments of the present application, and is not a limitation on other forms of the present application, and any skilled person in the art can modify or modify the above disclosed content into equivalent embodiments with equivalent changes. However, any simple modification, equivalent change and modification made to the above embodiments according to the technical essence of the present application without departing from the technical solution content of the present application still belongs to the protection scope of the technical solution of the present application.

Claims

1. A method for detecting defects of a strain clamp based on a lightweight model, characterized in that, The method comprises the following steps: S1, constructing an X-ray image data set of a tension clamp of a power transmission line, and dividing the data set into a training set, a verification set and a test set; S2, clustering the real frame data of the tension clamp defects by using a K-means algorithm to obtain anchor box parameters matched with the sizes of various defects of the tension clamp; S3, building a Faster-YOLO tension clamp X-ray image defect detection network model, which comprises a lightweight backbone feature extraction network, a neck feature fusion network and a detection head for regression prediction; The lightweight backbone feature extraction network FasterNet is composed of a Focus module, a CBS module, a FasterNet Block residual module and a spatial pyramid pooling SPP module, and has a total of five parts: the first part is a Focus module that performs a cutting and slicing operation on the input image, divides the data into four parts, and each part of data is equivalent to being obtained under 2 times downsampling, and then the longitudinal channel is spliced and stacked to fuse the width and height information into the channel information; the second to fourth parts are each stacked by one CBS module and one residual module FasterNet Block; in each residual module FasterNet Block, a 3x3 PConv partial convolution is first performed, then a 1x1 convolution operation is performed, then a BN batch normalization layer and a Leaky_ReLU activation function are performed, and finally a 1x1 convolution operation is performed, and a residual connection is added between the input and output of the FasterNet Block module; the fifth part is stacked by one CBS module, one SPP module and one FasterNet Block; finally, the feature maps after the FasterNet Block modules of the third to fifth parts are selected as the output of the lightweight backbone feature extraction network, and the three output feature maps are respectively input into the neck feature fusion network after passing through a CBAM attention mechanism module, and are respectively named as Feat3, Feat2 and Feat1. The neck feature fusion network fuses deep feature maps and shallow feature maps by using a combination of a CBS module, a CARAFE lightweight up-sampling operator, a down-sampling, a CBAM attention mechanism module and a FasterNet Block module: first, the input feature map Feat1 is subjected to a CBS module to obtain an extracted feature map Layer1, and the extracted feature map Layer1 is subjected to a CARAFE lightweight up-sampling operator and a CBAM attention mechanism module to obtain an extracted feature map Layer2; the extracted feature map Layer2 is stacked with the input feature map Feat2, and then subjected to a FasterNet Block module and a CBS module to obtain an extracted feature map Layer3, and the extracted feature map Layer3 is subjected to a CARAFE lightweight up-sampling operator and a CBAM attention mechanism module to obtain an extracted feature map Layer4; the extracted feature map Layer4 is stacked with the input feature map Feat3, and then subjected to a FasterNet Block module to obtain an enhanced feature map P3; the enhanced feature map P3 is subjected to a down-sampling and a CBAM attention mechanism module to obtain an extracted feature map Layer5; the extracted feature map Layer5 is stacked with the extracted feature map Layer3, and then subjected to a FasterNet Block module to obtain an enhanced feature map P2; the enhanced feature map P2 is subjected to a down-sampling and a CBAM attention mechanism module to obtain an extracted feature map Layer6; the extracted feature map Layer6 is stacked with the extracted feature map Layer1, and then subjected to a FasterNet Block module to obtain an enhanced feature map P1; finally, the three newly generated enhanced feature maps P1, P2 and P3 are input to the corresponding three detection heads for regression prediction, and the prediction value is output, and the EIoU loss function is used to calculate the loss value between the prediction value and the true value for back propagation to update the parameters; The EIoU loss function includes three parts: overlap loss calculation, center distance loss calculation and width-height loss calculation, and the calculation formula is as follows: (1.1); In the formula: B is a predicted frame, B i is a real frame, b and b gt are the center points of the predicted frame and the real frame respectively, r is the Euclidean distance of the two center points, d is the diagonal distance of the minimum circumscribed rectangle of the predicted frame and the real frame, w , w gt , h , h gt are the width and length of the predicted frame and the real frame respectively, C w , C h is the width and length of the minimum circumscribed rectangle covering the two frames; The CARAFE lightweight up-sampling operator includes two parts of up-sampling kernel prediction and feature reorganization; the up-sampling kernel prediction part is composed of a channel compression module, a content coding module and an up-sampling kernel normalization module; for an input feature map with a shape of H × W × C , an up-sampling rate is s , and an up-sampling kernel size is k up × k up , the channel compression module first adopts a 1*1 ordinary convolution to compress the channel number of the input feature map from C to C m , then the content coding module adopts a k encoder × k encoder convolution to predict the up-sampling kernel of the compressed feature map, wherein k encoder = 3, and the output channel number is s 2 k up 2 , the channel dimension is expanded in the spatial dimension to obtain an up-sampling kernel with a shape of sH × sW × k up 2 , finally, the up-sampling kernel normalization module normalizes each obtained up-sampling kernel by using a Softmax function, so that the convolution kernel weight sum is 1; the feature reorganization part performs an up-sampling operation by using the predicted up-sampling kernel, and dot products are obtained at corresponding positions of the input feature map, to obtain an output feature map, wherein different channels at the same position of the input feature map share the same up-sampling kernel; S4, set the model parameters and training parameters of the Faster-YOLO tension clamp defect detection model, based on the YOLOv5-l pre-training weight of the VOC public data set, continue to train the Faster-YOLO tension clamp defect detection model using the training set and the validation set divided in step S1, and obtain the target model; S5, the X-ray image of the strain clamp defect target detection: the strain clamp X-ray image to be detected is input into the target model, and after depth convolution operation, three scales of feature layers are obtained, and are correspondingly divided into SxS grids, each grid will be used to predict whether the corresponding anchor frame exists in the corresponding defect target, and all target prediction frames meeting the confidence condition are generated; finally, the maximum suppression NMS is used for screening the target prediction frame, and the corresponding defect position and category in the image are output, realizing the target detection of the strain clamp X-ray image defect.

2. The lightweight model-based strain clamp defect detection method of claim 1, wherein, In step S1, the power grid personnel collects X-ray image samples of the tension clamp of the power transmission line obtained by using a miniaturized X-ray imaging device during inspection, and performs a pretreatment operation on the samples; for the pretreated image samples, a target detection label making tool LabelImg is used to label the real frame and the corresponding category of the image, to construct an X-ray image dataset of the tension clamp containing defects N The annotation format is Pascal VOC dataset format, and the annotated dataset is first divided into a training verification set and a test set according to a ratio of 9:1, and then the training verification set is divided into a training set and a verification set according to a ratio of 9:

1.

3. The lightweight model-based strain clamp defect detection method of claim 2, wherein, In step S2, the K-means clustering method is used to cluster the strain clamp defect real frame data. First, 9 sample target frames are randomly selected as initial clustering centers, the minimum intersection ratio of the remaining sample frames with the current clustering center is calculated, and the probability of the remaining sample being selected as the next clustering center is judged, then the next clustering center is selected by using the roulette method, the above process is repeated until 9 clustering centers are selected, and finally 9 anchor frame parameters matched with the size of each type of strain clamp defect are obtained.

4. The lightweight model-based strain clamp defect detection method of claim 1, wherein, In step S4, based on the YOLOv5-l pre-training weight of the VOC public data set, the Faster-YOLO strain clamp defect detection model is trained using Mosaic data enhancement, Mixup data enhancement and SGD optimizer training techniques during the training process.

5. The lightweight model-based strain clamp defect detection method of claim 1, wherein, In step S5, the optimal weight obtained after training is loaded into the Faster-YOLO model, the strain clamp X-ray image to be detected is input, after the lightweight backbone feature extraction network and the neck feature fusion network, three scales of feature layers are obtained, and are correspondingly divided into SxS grids, each grid will be used to predict whether the corresponding 3 anchor frames exist in the corresponding defect target, and the position of the anchor frame is adjusted, the coordinates, confidence and category information of all target prediction frames meeting the confidence are generated; finally, the maximum suppression NMS is used for screening the target prediction frame, all target prediction frames with a coincidence degree higher than a set value and a confidence lower than a set value in all prediction results are removed, and the target detection of the strain clamp X-ray image defect is realized.