Insulator defect detection method in severe environment based on improved DETR algorithm

Through the improved DETR algorithm and hybrid attention mechanism, combined with the Focal Loss loss function, the problem of low accuracy in insulator defect detection in complex environments is solved, accurate identification and judgment of insulator defects is achieved, and detection efficiency and robustness are improved. .

CN118537612APending Publication Date: 2024-08-23XI'AN POLYTECHNIC UNIVERSITY
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410377776.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-03-29
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

Existing technologies have low accuracy in detecting defects in transmission line insulators in complex environments, making it difficult to effectively identify and locate faults such as damage and self-explosion in insulators.

Method used

The improved DETR algorithm is used, combined with the ResNet50 backbone network and the hybrid attention mechanism CBAM, to expand and annotate data through insulator images captured by drones, introduce the Focal Loss loss function, and build a deep learning network to improve detection accuracy.

Benefits of technology

It achieves accurate detection of insulator defects in harsh environments, improves detection accuracy and efficiency, can more accurately identify and judge insulator defects, and improves the robustness of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118537612A
    Figure CN118537612A
Patent Text Reader

Abstract

The invention discloses an insulator defect detection method in a severe environment based on an improved DETR algorithm, and the method comprises the steps: firstly obtaining original insulator images in different environments, carrying out the expansion of the obtained insulator images, and taking the expanded insulator images as a real insulator data set; dividing the obtained insulator data set into a training set and a verification set; carrying out insulator defect category labeling on the training set, and storing the labeled insulator defect image information to obtain an insulator database; a mixed attention mechanism (CBAM) is fused in the DETR backbone network ResNet50, and an improved DETR algorithm is utilized to train a data set after marking is completed; and predicting the verification set to obtain a corresponding insulator defect category detection result. According to the invention, the problem of low accuracy of detecting the insulator defect of the power transmission line in a complex environment in the prior art is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of image processing, and in particular relates to an insulator defect detection method under harsh environment based on an improved DETR algorithm. Background Art

[0002] Due to the rapid construction of my country's power system and the continuous increase in electricity consumption in the whole society, the scope of transmission lines is also expanding. Transmission lines exposed to the outdoors are not only exposed to the sun and rain, but also affected by natural factors such as lightning, heavy rain, freezing, and floods. If a certain section of the transmission line causes the power system to collapse, it will directly or indirectly cause major economic losses or other serious hazards.

[0003] Insulators are key electrical equipment that can isolate the connection between the supporting electrical equipment and the lead wires of transmission lines. They are widely used in high-voltage and ultra-high-voltage transmission lines. Due to their long-term exposure to adverse natural environments, insulators may become contaminated, flashed, damaged, exploded, or have caps missing, posing a major hidden danger to the safe and stable working environment of electricity. Therefore, whether problems in insulators can be found in advance to ensure the reliability and safety of electric energy has become people's primary task.

[0004] In recent years, drones have been used for autonomous patrol and long-distance ultra-clear image transmission. The high-definition cameras carried by drones can take high-definition pictures of insulators on transmission lines. These pictures contain GPS data on each tower and label data on each insulator. If the insulator information in the picture can be accurately located and identified, it can provide a basis for subsequent insulator defect inspection and maintenance. The pictures taken by the drone are transmitted to the client via the 5G network, and finally the defects are located and identified using algorithms. Summary of the invention

[0005] The purpose of the present invention is to provide an insulator defect detection method under harsh environment based on an improved DETR algorithm, which solves the problem of low accuracy in detecting transmission line insulator defects under complex environment in the prior art.

[0006] The technical solution adopted by the present invention is an insulator defect detection method in a harsh environment based on an improved DETR algorithm, which is specifically implemented according to the following steps:

[0007] Step 1: obtain original insulator images in different environments, expand the obtained insulator images, and use the expanded insulator images as real insulator datasets;

[0008] Step 2, dividing the insulator data set obtained in step 1 into a training set and a validation set;

[0009] Step 3: label the insulator defect categories of the training set in step 2, save the labeled insulator defect image information, and obtain the insulator database;

[0010] Step 4: Integrate the hybrid attention mechanism CBAM into the DETR backbone network ResNet50, and use the improved DETR algorithm to train the dataset annotated in step 3;

[0011] Step 5: Predict the validation set in step 2 to obtain the corresponding insulator defect category detection results.

[0012] The present invention is also characterized in that:

[0013] Step 1 is implemented as follows:

[0014] Step 1.1, use drone inspection to take insulator images on the transmission line, and perform horizontal flipping, random deduction, rotation transformation, brightness enhancement, and contrast enhancement operations on the obtained insulator images to expand the data set;

[0015] Step 1.2: reintegrate the insulator image captured in step 1.1 and the expanded insulator image into a new data set as a sample library.

[0016] Step 3 is implemented as follows:

[0017] Step 3.1, select the insulator defect image to be marked, accurately determine and mark the insulator defect area, obtain the marking frame of the insulator defect area, and classify the defect category into two labels: broken and self-explosion according to the insulator defect image in the marking frame, and finally obtain the insulator defect area marking frame with category labels;

[0018] Step 3.2, use Labelmg annotation software to generate the XML tag file corresponding to the insulator defect image, and store the annotated sample data in Pascal VOC format. The sample data folder is VOC devkit, which includes three folders: Annotations, JPEG Images, and Image Sets. Annotations stores all the annotated insulator defect XML tag files. The XML tag file includes the image ID, image path, image name, pixel height and width of the image. The pixel height and width of the image are represented by four coordinates of a rectangular box, including x min ,y min ,x max ,y max , where (x min ,y min ) is the coordinate of the upper left vertex of the rectangle, (x min ,ymax ) is the coordinate of the lower right vertex of the rectangular box, and each marked file corresponds to the original image in JPEG Images; the JPEG Images folder contains all the marked original images; Image Sets has a Main subfolder, in which the train document contains the names of all the images in the training set, and the val document contains the names of all the images in the validation set.

[0019] Step 4 is implemented according to the following steps:

[0020] Step 4.1, CBAM hybrid attention mechanism is based on the construction of spatial attention mechanism module spatial and channel attention mechanism module channel. The hybrid attention mechanism CBAM is as follows:

[0021] First, the insulator database in step 3 is moved step by step from top to bottom and from left to right on the feature map through a 3*3 convolution kernel and the coverage area is convolved step by step to obtain the local signal of the image. Then the obtained local signal is first sent to the channel attention module to reduce a feature map to a one-dimensional feature map in a specific field of view space to obtain the key features in the image; secondly, the key nodes of the image information in the channel are accurately identified through the spatial attention module; finally, the next convolution operation is performed;

[0022] Step 4.2, adding the CBAM attention mechanism obtained in step 4.1 between adjacent convolutions of the DETR algorithm backbone network, and introducing the Focal Loss loss function to obtain the improved DETR target detection network;

[0023] Step 4.3: Use the DETR target detection network improved in step 4.2 to train the VOC devkit sample data obtained in step 3.2, and finally obtain the validation set benchmark network with the best weight data.

[0024] Step 4.1 is implemented as follows:

[0025] Step 4.1.1: The channel attention module obtains the feature map as follows:

[0026] The channel attention mechanism can reduce a feature map to a one-dimensional feature map in a specific field of view, and then identify the key features in the map through one-dimensional vector space operations and feature point coordinate operations. In the process of using the channel attention module, the average pooling and maximum pooling characteristics are combined with it. The average pooling needs to consider the impact of all pixels in the feature map on the global; the maximum pooling rule needs to back propagate in the gradient space to calculate the gradient features of each image. The output data of average pooling and maximum pooling contain information about the spatial mapping relationship of image aggregation features. The average pooling feature is usually represented by the symbol Common symbols for representing and max pooling features It means that after these two feature descriptions are input into a shared network composed of multi-layer perceptrons (MLP), a channel attention distribution map can be generated. Then, through the shared fully connected layer, the feature data in the image is parsed, elementwise operations are performed, and sigmoid activation is performed to construct a complete channel attention module feature map. The expression of channel attention is shown in formula (1):

[0027]

[0028] Wherein, Avgpool(F) represents the average pooling operation, Maxpool(F) represents the maximum pooling operation, and MLP represents the multi-layer perceptron.

[0029] Step 4.1.2: The spatial attention module obtains the feature map as follows:

[0030] The operation steps of spatial structure attention are as follows: first, the input image information is uniformly pooled and max-pooled according to the direction of the pipeline central axis, all pixels on the central axis are connected to obtain a reasonable spatial structure feature description, and all channel information of each feature map is aggregated by two mean pooling methods to obtain two 2D feature maps: and Among them, the first picture describes the channel average pooling characteristics, and the second picture describes the maximum pooling characteristics. The two pictures are connected by a standard convolution layer and then convolved to obtain a two-dimensional spatial attention map. The convolution formula is:

[0031]

[0032] Step 4.2 is implemented as follows:

[0033] Step 4.2.1, the loss calculation formula is as follows:

[0034]

[0035] The loss formula based on the matching results is:

[0036]

[0037] Where, L box is the marker symbol of the maximum regression loss function, the classification loss function is represented by the cross entropy loss function, and λ iou and λ 11 Indicates the importance of a specific target, that is, the weight coefficient, which is expressed as:

[0038]

[0039]

[0040] The backbone network ResNet50 is divided into 5 stages. After preprocessing the image to be detected, a 224×224 3-channel feature map is obtained. The preprocessed feature map is input into ResNet50. The input image is firstly extracted by a 7×7 convolution kernel. While compressing the feature image size, the feature map is extended in the number of channels in the depth dimension. In the second stage, the image is subjected to the maximum pooling layer and then subjected to 3-size residual convolution for 3 times to extract features and output the feature map. The remaining stages 3, 4, and 5 are all cyclic convolutions of different numbers of feature maps. After multiple stages, the output feature map size is smaller and smaller, and finally a 7*7 feature map with 2048 channels is obtained.

[0041] Improve the DETR algorithm model to keep the original DETR network's Transformer encoder, Transformer decoder, and prediction head unchanged; add a hybrid attention mechanism to the backbone network ResNet50;

[0042] Step 4.2.2: In the prediction layer, select the EIoU loss function with the best performance at this stage to replace the original IOU loss function. The calculation formula of the EIOU loss function is as follows:

[0043]

[0044]

[0045]

[0046]

[0047]

[0048]

[0049] Among them, IoU represents the ratio of the intersection and union of the real box A and the predicted box B, b and b gt are the center points of the predicted box and the real box respectively, c is the diagonal distance of the minimum closure area that can contain both the predicted box and the real box, P is the Euclidean distance between the two center points, α is the weight factor, V is the similarity of the aspect ratio, and w gt Indicates the width of the real box, h gt Represents the height of the real box, W represents the width of the predicted frame, and h represents the height of the predicted frame. The loss function consists of three parts: overlap loss, center distance loss, and width-height loss. The first two parts continue the method in CIOU, but the width-height loss directly minimizes the difference between the width and height of the target box and the anchor box, making the convergence faster.

[0050] Separate high-quality anchor boxes from low-quality anchor boxes. The formula is as follows:

[0051] L Focal-EIoU =IoU γ L EIoU (12)

[0052] Among them, γ is a parameter that controls the degree of outlier suppression. Focal Loss is introduced to optimize the sample imbalance problem in the bounding box regression task, that is, to reduce a large number of anchor boxes that overlap less with the target box, so that the regression process focuses on high-quality anchor boxes, and obtain an improved DETR algorithm network model;

[0053] Step 4.2.3: Combine the CBAM in step 4.2.1 and the FocalEIOULoss loss function in step 4.2.2 to form a DETR target detection network with better detection effect.

[0054] Step 5 is implemented according to the following steps:

[0055] Two files are needed for training result prediction, namely detr.py and predict.py. First, you need to modify the model_path and classes_path in detr.py; model_path points to the trained best weight file, and in the logs folder, classes_path points to the txt file corresponding to the detection category. After completing the modification, start the prediction.

[0056] The beneficial effect of the present invention is to provide an insulator defect detection method in harsh environments based on an improved DETR algorithm to achieve accurate detection of insulator defects in transmission lines. The difference of this algorithm is that, first, the insulator defect images collected by drone inspections are expanded with a data set operation; the improved DETR algorithm is used to detect transmission line insulators, thereby improving detection accuracy and efficiency. This includes using ResNet50 as the backbone network, introducing a hybrid attention mechanism module and a Focal Loss function, using DETR to build a deep learning network model; labeling the insulator defect data, and finally inputting the labeled insulator defect data into the improved DETR algorithm for insulator defect feature data training, generating a neural network detection model for insulator defect images, thereby being able to more accurately identify and judge insulator defects. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] Figure 1 It is a flow chart of the insulator defect detection method under harsh environment based on the improved DETR network of the present invention;

[0058] Figure 2(a) is a network structure diagram of the DETR algorithm of the present invention, which consists of the backbone network ResNet50 Figure 2(b) and Transformer Figure 2(c);

[0059] Figure 3 It is a schematic diagram of the channel attention mechanism in the method for detecting defects of insulators of transmission lines in harsh environments based on the improved DETR network of the present invention;

[0060] Figure 4 It is a schematic diagram of the spatial attention mechanism in the method for detecting defects of insulators of transmission lines in harsh environments based on the improved DETR network of the present invention;

[0061] Figure 5 This is a schematic diagram of the hybrid attention mechanism CBAM applied to the backbone network ResNet50;

[0062] Figure 6 It is a diagram showing the effect of the DETR network on insulator defect detection in a harsh environment in the method for detecting insulator defects of a transmission line under a harsh environment based on the improved DETR network of the present invention;

[0063] Figure 7 The present invention compares the accuracy change curves of insulator defect detection of various comparison algorithms in the transmission line insulator defect detection method under harsh environment based on the improved DETR network, taking insulator breakage as an example;

[0064] Figure 8 It is a comparison chart of the recall rate variation curves of insulator defect detection of various comparison algorithms in the method for detecting insulator defects of transmission lines under harsh environments based on the improved DETR network of the present invention, taking insulator breakage as an example;

[0065] Fig. 9 This is a comparison chart of the mAP values ​​of insulator self-explosion and damage detection of various comparison algorithms in the method for detecting defects in transmission line insulators under harsh environments based on the improved DETR network of the present invention. DETAILED DESCRIPTION

[0066] The present invention is described in detail below with reference to the accompanying drawings and specific embodiments.

[0067] The present invention is based on an improved DETR algorithm for detecting insulator defects in harsh environments. The flow chart is as follows: Figure 1 As shown, the specific implementation steps are as follows:

[0068] Step 1: Obtain original insulator images in different environments through drone inspection, expand the obtained insulator images, and use the expanded insulator images as the real insulator dataset;

[0069] Step 1 is implemented as follows:

[0070] Step 1.1, use drone inspection to take insulator images on the transmission line, and perform horizontal flipping, random deduction, rotation transformation, brightness enhancement, and contrast enhancement operations on the obtained insulator images to expand the data set;

[0071] Step 1.2: reintegrate the insulator image captured in step 1.1 and the expanded insulator image into a new data set as a sample library.

[0072] Step 2: Divide the insulator data set obtained in step 1 into a training set and a validation set, with the ratio of the training set to the validation set being 9:1.

[0073] Step 3: Labelmg software is used to label the insulator defect categories of the training set in step 2, and the VOC mode is selected for image labeling, and the insulator defect image information after labeling is saved to obtain the insulator database;

[0074] Step 3 is implemented as follows:

[0075] Step 3.1, select the insulator defect image to be marked, accurately determine and mark the insulator defect area, obtain the marking frame of the insulator defect area, and classify the defect category into two labels: break and explosion according to the insulator defect image in the marking frame, and finally obtain the insulator defect area marking frame with category labels;

[0076] Step 3.2, use Labelmg annotation software to generate the XML tag file corresponding to the insulator defect image, and store the annotated sample data in Pascal VOC format. The sample data folder is VOC devkit, which includes three folders: Annotations, JPEG Images, and Image Sets. Annotations stores all the annotated insulator defect XML tag files. The XML tag file includes the image ID, image path, image name, pixel height and width of the image. The pixel height and width of the image are represented by four coordinates of a rectangular box, including x min ,y min ,x max ,y max , where (x min ,y min ) is the coordinate of the upper left vertex of the rectangle, (x min ,y max ) is the coordinate of the lower right vertex of the rectangular box, and each marked file corresponds to the original image in JPEG Images; the JPEG Images folder contains all the marked original images; Image Sets has a Main subfolder, in which the train document contains the names of all the images in the training set, and the val document contains the names of all the images in the validation set.

[0077] Step 4: Integrate the hybrid attention mechanism CBAM (Convolutional Block Attention Module) into the DETR backbone network ResNet50. By adding the CBAM model to the DETR backbone network ResNet50, the training failure rate is reduced. The Focal Loss loss function is introduced to make the regression process focus on high-quality anchor frames. The improved DETR algorithm is used to train the data set annotated in step 3. FIG2(a) is a network structure diagram of the DETR algorithm of the present invention, which consists of the backbone network ResNet50 FIG2(b) and the Transformer FIG2(c). Figure 3 It is a schematic diagram of the channel attention mechanism in the method for detecting defects of insulators of transmission lines in harsh environments based on the improved DETR network of the present invention; Figure 4 It is a schematic diagram of the spatial attention mechanism in the method for detecting defects of insulators of transmission lines in harsh environments based on the improved DETR network of the present invention; Figure 5 This is a schematic diagram of the hybrid attention mechanism CBAM applied to the backbone network ResNet50; Figure 6 It is a diagram showing the effect of the DETR network on insulator defect detection in a harsh environment in the method for detecting insulator defects of a transmission line under a harsh environment based on the improved DETR network of the present invention;

[0078] Step 4 is implemented according to the following steps:

[0079] Step 4.1, CBAM hybrid attention mechanism is based on the construction of spatial attention mechanism module spatial and channel attention mechanism module channel. The hybrid attention mechanism CBAM is as follows:

[0080] First, the insulator database in step 3 is moved step by step from top to bottom and from left to right on the feature map through a 3*3 convolution kernel and the coverage area is convolved step by step to obtain the local signal of the image. Then the obtained local signal is first sent to the channel attention module to reduce a feature map to a one-dimensional feature map in a specific field of view space to obtain the key features in the image; secondly, the key nodes of the image information in the channel are accurately identified through the spatial attention module; finally, the next convolution operation is performed;

[0081] Step 4.2, add λ between adjacent convolutions of the DETR algorithm backbone network. The CBAM attention mechanism obtained in step 4.1 is introduced, and the Focal Loss loss function is introduced to obtain the improved DETR target detection network.

[0082] Step 4.3: Use the DETR target detection network improved in step 4.2 to train the VOC devkit sample data obtained in step 3.2, and finally obtain the validation set benchmark network with the best weight data.

[0083] Step 4.1 is implemented as follows:

[0084] Step 4.1.1: The channel attention module obtains the feature map as follows:

[0085] The channel attention mechanism can reduce a feature map to a one-dimensional feature map in a specific field of view, and then identify the key features in the map through one-dimensional vector space operations and feature point coordinate operations. In the process of using the channel attention module, the average pooling and maximum pooling characteristics are combined with it. The average pooling needs to consider the impact of all pixels in the feature map on the global; the maximum pooling rule needs to back propagate in the gradient space to calculate the gradient features of each image. The output data of average pooling and maximum pooling contain information about the spatial mapping relationship of image aggregation features. The average pooling feature is usually represented by the symbol Common symbols for representing and max pooling features It means that after these two feature descriptions are input into a shared network composed of multi-layer perceptrons (MLP), a channel attention distribution map can be generated. Then, through the shared fully connected layer, the feature data in the image is parsed, elementwise operations are performed, and sigmoid activation is performed to construct a complete channel attention module feature map. The expression of channel attention is shown in formula (1):

[0086]

[0087] Wherein, Avgpool(F) represents the average pooling operation, Maxpool(F) represents the maximum pooling operation, and MLP represents the multi-layer perceptron.

[0088] Step 4.1.2: The spatial attention module obtains the feature map as follows:

[0089] The operation steps of spatial structure attention are as follows: first, the input image information is uniformly pooled and max-pooled according to the direction of the pipeline central axis, all pixels on the central axis are connected to obtain a reasonable spatial structure feature description, and all channel information of each feature map is aggregated by two mean pooling methods to obtain two 2D feature maps: and Among them, the first picture describes the channel average pooling characteristics, and the second picture describes the maximum pooling characteristics. The two pictures are connected by a standard convolution layer and then convolved to obtain a two-dimensional spatial attention map. The convolution formula is:

[0090]

[0091] Step 4.2 is implemented as follows:

[0092] Step 4.2.1, DETR algorithm uses Hungarian algorithm as the core algorithm of positive sample matching, which is the source of loss calculation. The loss calculation formula is as follows:

[0093]

[0094] Compared with the CNN method, DETR can significantly reduce the complexity of the matching operation, and there is no problem of overlapping matching results, eliminating the need for complicated NMS post-processing. The Hungarian loss formula based on the matching results is:

[0095]

[0096] Where, L box is the marker symbol of the maximum regression loss function, the classification loss function is represented by the cross entropy loss function, and λ iou and λ 11Indicates the importance of a specific target, that is, the weight coefficient, which is expressed as:

[0097]

[0098]

[0099] The backbone network ResNet50 is divided into 5 stages. After preprocessing the image to be detected, a 224×224 3-channel feature map is obtained. The preprocessed feature map is input into ResNet50. The input image is firstly extracted by a 7×7 convolution kernel. While compressing the feature image size, the feature map is extended in the number of channels in the depth dimension. In the second stage, the image is subjected to the maximum pooling layer and then subjected to 3-size residual convolution for 3 times to extract features and output the feature map. The remaining stages 3, 4, and 5 are all cyclic convolutions of different numbers of feature maps. After multiple stages, the output feature map size is smaller and smaller, and finally a 7*7 feature map with 2048 channels is obtained.

[0100] Improve the DETR algorithm model to keep the original DETR network's Transformer encoder, Transformer decoder, and prediction head unchanged; add a hybrid attention mechanism to the backbone network ResNet50;

[0101] Step 4.2.2: In the prediction layer, select the EIoU loss function with the best performance at this stage to replace the original IOU loss function. The calculation formula of the EIOU loss function is as follows:

[0102]

[0103]

[0104]

[0105]

[0106]

[0107]

[0108] Among them, IoU represents the ratio of the intersection and union of the real box A and the predicted box B, b and b gt are the center points of the predicted box and the real box respectively, c is the diagonal distance of the minimum closure area that can contain both the predicted box and the real box, P is the Euclidean distance between the two center points, α is the weight factor, V is the similarity of the aspect ratio, and w gt Indicates the width of the real box, h gtRepresents the height of the real box, W represents the width of the predicted frame, and h represents the height of the predicted frame. The loss function consists of three parts: overlap loss, center distance loss, and width and height loss. The first two parts continue the method in CIOU, but the width and height loss directly minimizes the difference between the width and height of the target box and the anchor box, making the convergence faster.

[0109] Based on EIOU and Focal Loss, a Focal EIOU Loss is proposed. Starting from the gradient, the high-quality anchor boxes are separated from the low-quality anchor boxes. The formula is as follows:

[0110] L Focal-EIoU =IoU γ L EIoU (12)

[0111] Among them, γ is a parameter that controls the degree of outlier suppression. Focal Loss is introduced to optimize the sample imbalance problem in the bounding box regression task, that is, to reduce a large number of anchor boxes that overlap less with the target box, so that the regression process focuses on high-quality anchor boxes, and obtain an improved DETR algorithm network model;

[0112] Step 4.2.3: Combine the CBAM in step 4.2.1 and the Focal EIOU Loss loss function in step 4.2.2 to form a DETR target detection network with better detection effect.

[0113] Step 4.3 is implemented as follows:

[0114] Step 4.3, input the training set images divided in step 3.2 into the improved DETR algorithm network model obtained in step 4.2 for training, set the random gradient descent with sum momentum to 0.9 in the file train.py, train for 400 rounds, set the input image pixel size to 640*640, freeze the training for 150 rounds batch_size32, unfreeze the training for 250 rounds batch_size to 4, num_workers2, Adam optimizer, attenuation weight coefficient 5*10-4 initial learning rate 1*10-5, set the IoU threshold to 0.5 for testing when testing the training set, and fine-tune the learning rate to 0.003 during training to obtain better robustness. The first 150 rounds of frozen training have a fast loss decrease rate, and the next 250 rounds of unfreeze training, the network is continuously fine-tuned, and the loss change of the training set gradually decreases after 350 rounds of the total 400 rounds. Finally, the optimized DETR algorithm model is obtained to obtain the best weight data.

[0115] Step 5: Use the benchmark network with the optimal weight data obtained in step 4 to predict the validation set in step 2 to obtain the corresponding insulator defect category detection result.

[0116] Step 5 is implemented according to the following steps:

[0117] Two files are needed for training result prediction, namely detr.py and predict.py. First, you need to modify the model_path and classes_path in detr.py; model_path points to the trained best weight file, and in the logs folder, classes_path points to the txt file corresponding to the detection category. After completing the modification, start the prediction.

[0118] Example 1

[0119] The present invention is based on an improved DETR algorithm for detecting insulator defects in harsh environments. The flow chart is as follows: Figure 1 As shown, the specific implementation steps are as follows:

[0120] Step 1: Obtain original insulator images in different environments through drone inspection, expand the obtained insulator images, and use the expanded insulator images as the real insulator dataset;

[0121] Step 2: Divide the insulator data set obtained in step 1 into a training set and a validation set, with the ratio of the training set to the validation set being 9:1.

[0122] Step 3: Labelmg software is used to label the insulator defect categories of the training set in step 2, and the VOC mode is selected for image labeling, and the insulator defect image information after labeling is saved to obtain the insulator database;

[0123] Step 4: Integrate the hybrid attention mechanism CBAM (Convolutional Block Attention Module) into the DETR backbone network ResNet50. By adding the CBAM model to the DETR backbone network ResNet50, the training failure rate is reduced. The Focal Loss loss function is introduced to make the regression process focus on high-quality anchor frames. The improved DETR algorithm is used to train the data set annotated in step 3.

[0124] Step 5: Use the benchmark network with the optimal weight data obtained in step 4 to predict the validation set in step 2 to obtain the corresponding insulator defect category detection result.

[0125] Example 2

[0126] The present invention is based on an improved DETR algorithm for detecting insulator defects in harsh environments. The flow chart is as follows: Figure 1 As shown, the specific implementation steps are as follows:

[0127] Step 1: Obtain original insulator images in different environments through drone inspection, expand the obtained insulator images, and use the expanded insulator images as the real insulator dataset;

[0128] Step 1 is implemented as follows:

[0129] Step 1.1, use drone inspection to take insulator images on the transmission line, and perform horizontal flipping, random deduction, rotation transformation, brightness enhancement, and contrast enhancement operations on the obtained insulator images to expand the data set;

[0130] Step 1.2: reintegrate the insulator image captured in step 1.1 and the expanded insulator image into a new data set as a sample library.

[0131] Step 2: Divide the insulator data set obtained in step 1 into a training set and a validation set, with the ratio of the training set to the validation set being 9:1.

[0132] Step 3: Labelmg software is used to label the insulator defect categories of the training set in step 2, and the VOC mode is selected for image labeling, and the insulator defect image information after labeling is saved to obtain the insulator database;

[0133] Step 3 is implemented as follows:

[0134] Step 3.1, select the insulator defect image to be marked, accurately determine and mark the insulator defect area, obtain the marking frame of the insulator defect area, and classify the defect category into two labels: break and explosion according to the insulator defect image in the marking frame, and finally obtain the insulator defect area marking frame with category labels;

[0135] Step 3.2, use Labelmg annotation software to generate the XML tag file corresponding to the insulator defect image, and store the annotated sample data in Pascal VOC format. The sample data folder is VOC devkit, which includes three folders: Annotations, JPEG Images, and Image Sets. Annotations stores all the annotated insulator defect XML tag files. The XML tag file includes the image ID, image path, image name, pixel height and width of the image. The pixel height and width of the image are represented by four coordinates of a rectangular box, including x min ,y min ,x max ,y max , where (x min ,y min) is the coordinate of the upper left vertex of the rectangle, (x max ,y max ) is the coordinate of the lower right vertex of the rectangular box, and each marked file corresponds to the original image in JPEG Images; the JPEG Images folder contains all the marked original images; Image Sets has a Main subfolder, in which the train document contains the names of all the images in the training set, and the val document contains the names of all the images in the validation set.

[0136] Step 4: Integrate the hybrid attention mechanism CBAM (Convolutional Block Attention Module) into the DETR backbone network ResNet50. By adding the CBAM model to the DETR backbone network ResNet50, the training failure rate is reduced. The Focal Loss loss function is introduced to make the regression process focus on high-quality anchor frames. The improved DETR algorithm is used to train the data set annotated in step 3.

[0137] Step 4 is implemented according to the following steps:

[0138] Step 4.1, CBAM hybrid attention mechanism is based on the construction of spatial attention mechanism module spatial and channel attention mechanism module channel. The hybrid attention mechanism CBAM is as follows:

[0139] First, the insulator database in step 3 is moved step by step from top to bottom and from left to right on the feature map through a 3*3 convolution kernel and the coverage area is convolved step by step to obtain the local signal of the image. Then the obtained local signal is first sent to the channel attention module to reduce a feature map to a one-dimensional feature map in a specific field of view space to obtain the key features in the image; secondly, the key nodes of the image information in the channel are accurately identified through the spatial attention module; finally, the next convolution operation is performed;

[0140] Step 4.2, adding the CBAM attention mechanism obtained in step 4.1 between adjacent convolutions of the DETR algorithm backbone network, and introducing the Focal Loss loss function to obtain the improved DETR target detection network;

[0141] Step 4.3: Use the DETR target detection network improved in step 4.2 to train the VOC devkit sample data obtained in step 3.2, and finally obtain the validation set benchmark network with the best weight data.

[0142] Step 4.2 is implemented as follows:

[0143] Step 4.2.1, DETR algorithm uses Hungarian algorithm as the core algorithm of positive sample matching, which is the source of loss calculation. The loss calculation formula is as follows:

[0144]

[0145] Compared with the CNN method, DETR can significantly reduce the complexity of the matching operation, and there is no problem of overlapping matching results, eliminating the need for complicated NMS post-processing. The Hungarian loss formula based on the matching results is:

[0146]

[0147] Where, L box is the marker symbol of the maximum regression loss function, the classification loss function is represented by the cross entropy loss function, and λ iou and λ 11 Indicates the importance of a specific target, that is, the weight coefficient, which is expressed as:

[0148]

[0149]

[0150] The backbone network ResNet50 is divided into 5 stages. After preprocessing the image to be detected, a 224×224 3-channel feature map is obtained. The preprocessed feature map is input into ResNet50. The input image is firstly extracted by a 7×7 convolution kernel. While compressing the feature image size, the feature map is extended in the number of channels in the depth dimension. In the second stage, the image is subjected to the maximum pooling layer and then subjected to 3-size residual convolution for 3 times to extract features and output the feature map. The remaining stages 3, 4, and 5 are all cyclic convolutions of different numbers of feature maps. After multiple stages, the output feature map size is smaller and smaller, and finally a 7*7 feature map with 2048 channels is obtained.

[0151] Improve the DETR algorithm model to keep the original DETR network's Transformer encoder, Transformer decoder, and prediction head unchanged; add a hybrid attention mechanism to the backbone network ResNet50;

[0152] Step 4.2.2: In the prediction layer, select the EIoU loss function with the best performance at this stage to replace the original IOU loss function. The calculation formula of the EIOU loss function is as follows:

[0153]

[0154]

[0155]

[0156]

[0157]

[0158]

[0159] Among them, IoU represents the ratio of the intersection and union of the real box A and the predicted box B, b and b gt are the center points of the predicted box and the real box respectively, c is the diagonal distance of the minimum closure area that can contain both the predicted box and the real box, P is the Euclidean distance between the two center points, α is the weight factor, V is the similarity of the aspect ratio, and w gt Indicates the width of the real box, h gt Represents the height of the real box, W represents the width of the predicted frame, and h represents the height of the predicted frame. The loss function consists of three parts: overlap loss, center distance loss, and width and height loss. The first two parts continue the method in CIOU, but the width and height loss directly minimizes the difference between the width and height of the target box and the anchor box, making the convergence faster.

[0160] Based on EIOU and Focal Loss, a Focal EIOU Loss is proposed. Starting from the gradient, the high-quality anchor boxes are separated from the low-quality anchor boxes. The formula is as follows:

[0161] L Focal-EIoU =IoU γ L EIoU (12)

[0162] Among them, γ is a parameter that controls the degree of outlier suppression. Focal Loss is introduced to optimize the sample imbalance problem in the bounding box regression task, that is, to reduce a large number of anchor boxes that overlap less with the target box, so that the regression process focuses on high-quality anchor boxes, and obtain an improved DETR algorithm network model;

[0163] Step 4.2.3: Combine the CBAM in step 4.2.1 and the Focal EIOU Loss loss function in step 4.2.2 to form a DETR target detection network with better detection effect.

[0164] Step 4.3 is implemented as follows:

[0165] Step 4.3, input the training set images divided in step 3.2 into the improved DETR algorithm network model obtained in step 4.2 for training, set the random gradient descent with momentum of 0.9 in the file train.py, train for 400 rounds, set the input image pixel size to 640*640, freeze the training for 150 rounds of batch_size32, unfreeze the training for 250 rounds of batch_size to 4, num_workers2, Adam optimizer, attenuation weight coefficient 5*10-4 initial learning rate 1*10-5, set the IoU threshold to 0.5 for testing when testing the training set, and fine-tune the learning rate to 0.003 during training to obtain better robustness. The first 150 rounds of frozen training have a fast loss decrease rate, and the next 250 rounds of unfreeze training, the network is continuously fine-tuned, and the loss change of the training set gradually decreases after 350 rounds of the total 400 rounds. Finally, the optimized DETR algorithm model is obtained to obtain the best weight data.

[0166] Step 5: Use the benchmark network with the optimal weight data obtained in step 4 to predict the validation set in step 2 to obtain the corresponding insulator defect category detection result.

[0167] Step 5 is implemented according to the following steps:

[0168] Two files are needed for training result prediction, namely detr.py and predict.py. First, you need to modify the model_path and classes_path in detr.py; model_path points to the trained best weight file, and in the logs folder, classes_path points to the txt file corresponding to the detection category. After completing the modification, start the prediction.

[0169] Example 3

[0170] The obtained detection results are evaluated using precision, recall, and mAP values ​​to efficiently classify insulator defects and the practicality of the improved algorithm.

[0171] The evaluation criteria of this algorithm are mainly based on precision, recall and mean average precision (mAP).

[0172] Based on the detection effect diagram and various evaluation indicators in step 5, the following conclusions are drawn:

[0173] Precision reflects the proportion of positive examples judged by the model and actually positive examples, as shown in formula (13):

[0174]

[0175] Where p represents precision; TP represents the detected positive examples; FP represents the detected negative examples.

[0176] The recall rate reflects the proportion of positive examples judged by the model to all positive test images, as shown in formula (14):

[0177]

[0178] Where R represents the recall rate; TP represents the detected positive examples; and FN represents the undetected positive examples.

[0179] Mean average precision (mAP) means averaging the average precision of each category, as shown in formula (15):

[0180]

[0181] (1) The detection results of the DETR target detection network for insulator damage and self-explosion defects in different environments are shown in the following figure. Figure 6 As shown in the figure, it can be seen that the DETR target detection network can accurately detect both insulator breakage and self-explosion defects in bad weather, complex background, overexposure and small targets, and the detection accuracy and recall rate are higher than other popular algorithms, and the robustness is stronger, which is more suitable for insulator defect detection in harsh environments. Figure 7 The present invention compares the accuracy change curves of insulator defect detection of various comparison algorithms in the transmission line insulator defect detection method under harsh environment based on the improved DETR network, taking insulator breakage as an example; Figure 8 It is a comparison chart of the recall rate variation curves of insulator defect detection of various comparison algorithms in the method for detecting insulator defects of transmission lines under harsh environments based on the improved DETR network of the present invention, taking insulator breakage as an example; Fig. 9 This is a comparison chart of the mAP values ​​of insulator self-explosion and damage detection of various comparison algorithms in the method for detecting defects in transmission line insulators under harsh environments based on the improved DETR network of the present invention.

[0182] (2) The DETR target detection network has a mAP of 74.16% for the detection of insulator self-explosion and damage defects, a precision of 94.74%, and a recall rate of 87.62%. Compared with the traditional yolov7 model, the mAP is increased by 6.59%, the precision is increased by 4.74%, and the recall rate is increased by 62.62%, indicating that the improved DETR target detection network has a relatively high detection accuracy and a low missed detection rate.

Claims

1. An insulator defect detection method in harsh environment based on improved DETR algorithm, characterized in that: Follow the steps below to implement it: Step 1: obtain original insulator images in different environments, expand the obtained insulator images, and use the expanded insulator images as real insulator datasets; Step 2, dividing the insulator data set obtained in step 1 into a training set and a validation set; Step 3: label the insulator defect categories of the training set in step 2, save the labeled insulator defect image information, and obtain the insulator database; Step 4: Integrate the hybrid attention mechanism CBAM into the DETR backbone network ResNet50, and use the improved DETR algorithm to train the dataset annotated in step 3; Step 5: Predict the validation set in step 2 to obtain the corresponding insulator defect category detection results.

2. The insulator defect detection method in harsh environment based on improved DETR algorithm according to claim 1 is characterized in that: The step 1 is specifically implemented according to the following steps: Step 1.1, use drone inspection to take insulator images on the transmission line, and perform horizontal flipping, random deduction, rotation transformation, brightness enhancement, and contrast enhancement operations on the obtained insulator images to expand the data set; Step 1.2: reintegrate the insulator image captured in step 1.1 and the expanded insulator image into a new data set as a sample library.

3. The insulator defect detection method under harsh environment based on improved DETR algorithm according to claim 2 is characterized in that: The step 3 is specifically implemented according to the following steps: Step 3.1, select the insulator defect image to be marked, accurately determine and mark the insulator defect area, obtain the marking frame of the insulator defect area, and classify the defect category into two labels: broken and self-explosion according to the insulator defect image in the marking frame, and finally obtain the insulator defect area marking frame with category labels; Step 3.2, use Labelmg annotation software to generate the XML tag file corresponding to the insulator defect image, and store the annotated sample data in PascalVOC format. The sample data folder is VOC devkit, which includes three folders: Annotations, JPEG Images, and Image Sets. Annotations stores all the annotated insulator defect XML tag files. The XML tag file includes image ID, image path, image name, pixel height and width of the image. The pixel height and width of the image are represented by four coordinates of a rectangular box, including x min ,y min , x max ,y max , where (x min ,y min ) is the coordinate of the upper left vertex of the rectangle, (x max ,y max ) is the coordinate of the lower right vertex of the rectangular box, and each marked file corresponds to the original image in JPEG Images; the JPEGImages folder contains all the marked original images; Image Sets has a Main subfolder, in which the train document contains the names of all the images in the training set, and the val document contains the names of all the images in the validation set.

4. The insulator defect detection method in harsh environment based on improved DETR algorithm according to claim 3 is characterized in that: The step 4 is specifically implemented according to the following steps: Step 4.1, CBAM hybrid attention mechanism is based on the construction of spatial attention mechanism module spatial and channel attention mechanism module channel. The hybrid attention mechanism CBAM is as follows: First, the insulator database in step 3 is moved step by step from top to bottom and from left to right on the feature map through a 3*3 convolution kernel and the coverage area is convolved step by step to obtain the local signal of the image. Then the obtained local signal is first sent to the channel attention module to reduce a feature map to a one-dimensional feature map in a specific field of view space to obtain the key features in the image; secondly, the key nodes of the image information in the channel are accurately identified through the spatial attention module; finally, the next convolution operation is performed; Step 4.2, adding the CBAM attention mechanism obtained in step 4.1 between adjacent convolutions of the DETR algorithm backbone network, and introducing the FocalLoss loss function to obtain the improved DETR target detection network; Step 4.3: Use the DETR target detection network improved in step 4.2 to train the VOC devkit sample data obtained in step 3.2, and finally obtain the validation set benchmark network with the best weight data.

5. The insulator defect detection method in harsh environment based on improved DETR algorithm according to claim 4 is characterized in that: The step 4.1 is specifically implemented according to the following steps: Step 4.1.1: The channel attention module obtains the feature map as follows: The channel attention mechanism can reduce a feature map to a one-dimensional feature map in a specific field of view, and then identify the key features in the map through one-dimensional vector space operations and feature point coordinate operations. In the process of using the channel attention module, the average pooling and maximum pooling characteristics are combined with it. The average pooling needs to consider the impact of all pixels in the feature map on the global; the maximum pooling rule needs to back propagate in the gradient space to calculate the gradient features of each image. The output data of average pooling and maximum pooling contain information about the spatial mapping relationship of image aggregation features. The average pooling feature is usually represented by the symbol Common symbols for representing and max pooling features It means that after these two feature descriptions are input into a shared network composed of multi-layer perceptrons (MLP), a channel attention distribution map can be generated. Then, through the shared fully connected layer, the feature data in the image is parsed, elementwise operations are performed, and sigmoid activation is performed to construct a complete channel attention module feature map. The expression of channel attention is shown in formula (1): Wherein, Avgpool(F) represents the average pooling operation, Maxpool(F) represents the maximum pooling operation, and MLP represents the multi-layer perceptron. Step 4.1.2: The spatial attention module obtains the feature map as follows: The operation steps of spatial structure attention are as follows: first, the input image information is uniformly pooled and max-pooled according to the direction of the pipeline central axis, all pixels on the central axis are connected to obtain a reasonable spatial structure feature description, and all channel information of each feature map is aggregated by two mean pooling methods to obtain two 2D feature maps: and Among them, the first picture describes the channel average pooling characteristics, and the second picture describes the maximum pooling characteristics. The two pictures are connected by a standard convolution layer and then convolved to obtain a two-dimensional spatial attention map. The convolution formula is:

6. The insulator defect detection method in harsh environment based on improved DETR algorithm according to claim 5, characterized in that: The step 4.2 is specifically implemented according to the following steps: Step 4.2.1, the loss calculation formula is as follows: The loss formula based on the matching results is: Where, L box is the marker symbol of the maximum regression loss function, the classification loss function is represented by the cross entropy loss function, and λ iou and λ 11 Indicates the importance of a specific target, that is, the weight coefficient, which is expressed as: The backbone network ResNet50 is divided into 5 stages. After preprocessing the image to be detected, a 224×224 3-channel feature map is obtained. The preprocessed feature map is input into ResNet50. The input image is firstly extracted by a 7×7 convolution kernel. While compressing the feature image size, the feature map is extended in the number of channels in the depth dimension. In the second stage, the image is subjected to the maximum pooling layer and then subjected to 3-size residual convolution for 3 times to extract features and output the feature map. The remaining stages 3, 4, and 5 are all cyclic convolutions of different numbers of feature maps. After multiple stages, the output feature map size is smaller and smaller, and finally a 7*7 feature map with 2048 channels is obtained. Improve the DETR algorithm model to keep the original DETR network's Transformer encoder, Transformer decoder, and prediction head unchanged; add a hybrid attention mechanism to the backbone network ResNet50; Step 4.2.2: In the prediction layer, select the EIoU loss function with the best performance at this stage to replace the original IOU loss function. The calculation formula of the EIOU loss function is as follows: Among them, IoU represents the ratio of the intersection and union of the real box A and the predicted box B, b and b gt are the center points of the predicted box and the real box respectively, c is the diagonal distance of the minimum closure area that can contain both the predicted box and the real box, P is the Euclidean distance between the two center points, α is the weight factor, V is the similarity of the aspect ratio, and w gt Indicates the width of the real box, h gt Represents the height of the real box, W represents the width of the predicted frame, and h represents the height of the predicted frame. The loss function consists of three parts: overlap loss, center distance loss, and width-height loss. The first two parts continue the method in CIOU, but the width-height loss directly minimizes the difference between the width and height of the target box and the anchor box, making the convergence faster. Separate high-quality anchor boxes from low-quality anchor boxes. The formula is as follows: L Focal-EIoU =IoU γ L EIoU (12) Among them, γ is a parameter that controls the degree of outlier suppression. Focal Loss is introduced to optimize the sample imbalance problem in the bounding box regression task, that is, to reduce a large number of anchor boxes that overlap less with the target box, so that the regression process focuses on high-quality anchor boxes, and obtain an improved DETR algorithm network model; Step 4.2.3: Combine the CBAM in step 4.2.1 and the Focal EIOU Loss loss function in step 4.2.2 to form a DETR target detection network with better detection effect.

7. The insulator defect detection method in harsh environment based on improved DETR algorithm according to claim 6, characterized in that: The step 5 is specifically implemented according to the following steps: Two files are needed for training result prediction, namely detr.py and predict.py. First, you need to modify the model_path and classes_path in detr.py; model_path points to the trained best weight file, and in the logs folder, classes_path points to the txt file corresponding to the detection category. After completing the modification, start the prediction.

Citation Information

Cited By

  • Insulator defect identification method

    CN119169489A