An insulator fault detection method based on improved YOLOv5

By constructing the MB-YOLOv5 model and re-parameterization of structure, the problem of low efficiency of traditional insulator inspection is solved, and more efficient insulator fault detection is achieved.

CN116148609BActive Publication Date: 2025-07-29FUZHOU UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211737430.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-31
Publication Date
2025-07-29
Estimated Expiration
2042-12-31

AI Technical Summary

Technical Problem

The traditional artificial insulator patrol method is time-consuming and inefficient, and is subjectively affected. The inspection accuracy and speed of existing automatic detection technologies need to be improved.

Method used

Build the MB-YOLOv5 model, combine MobileOne, BoTNet and YOLOv5 to optimize the model structure through structural reparameterization, improve detection accuracy and reduce parameter volume.

Benefits of technology

While maintaining or improving the detection accuracy, the parameter quantity and detection time of the model are significantly reduced and the detection speed is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116148609B_ABST
    Figure CN116148609B_ABST
Patent Text Reader

Abstract

The present invention relates to an insulator fault detection method based on improved YOLOv5, comprising the following steps: Step 1: Preprocess the insulator dataset and divide it into a training set, a validation set, and a test set according to a set ratio; Step 2: Combine MobileOne, BoTNet, and YOLOv5 to construct an MB-YOLOv5 model; Step 3: Input the training set and the validation set into the MB-YOLOv5 model for model training; Step 4: Perform structural reparameterization on the trained MB-YOLOv5 model; Step 5: Input the test set into the MB-YOLOv5 model after structural reparameterization to test the model performance; Step 6: Use the finally obtained MB-YOLOv5 model for insulator fault detection. This method is beneficial to improving the detection accuracy and detection speed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of insulator fault detection, and in particular to an insulator fault detection method based on improved YOLOv5. Background Art

[0002] Insulators are crucial components in power systems, supporting transmission lines and providing electrical insulation. They play a vital role in the operation of transmission lines. Due to their long-term exposure to harsh outdoor conditions, including temperature and humidity, lightning, strong electric fields, pollution, and natural disasters, insulators are prone to spontaneous explosion and fallout, seriously impacting the safe operation of power systems. Therefore, insulator fault detection, particularly spontaneous explosion detection, has become a pressing issue.

[0003] With the rapid development of drones, the use of drone inspections is becoming increasingly widespread, as traditional manual inspection methods are time-consuming and dangerous. However, the inspection of insulator inspection images has traditionally relied on manual labor, which is inefficient and subject to significant subjective influence. To overcome the challenges of manual inspection, numerous automated inspection technologies have been developed. With the rapid advancement of computer vision and deep learning technologies, the use of deep learning, using image acquisition devices as a medium, has become a viable solution for detecting defects in insulator equipment. Summary of the Invention

[0004] The present invention aims to provide an insulator fault detection method based on improved YOLOv5, which is conducive to improving detection accuracy and detection speed.

[0005] To achieve the above object, the technical solution adopted by the present invention is: an insulator fault detection method based on improved YOLOv5, comprising the following steps:

[0006] Step 1: Preprocess the insulator dataset and divide it into training set, validation set and test set according to the set ratio;

[0007] Step 2: Combine MobileOne, BoTNet, and YOLOv5 to build the MB-YOLOv5 model;

[0008] Step 3: Input the training set and validation set into the MB-YOLOv5 model for model training;

[0009] Step 4: Reparameterize the structure of the trained MB-YOLOv5 model;

[0010] Step 5: Input the test set into the reparameterized MB-YOLOv5 model to test the model performance.

[0011] Step 6: Use the final MB-YOLOv5 model to detect insulator faults.

[0012] Further, in step 2, the MB-YOLOv5 model is constructed as follows:

[0013] Step 2.1: Combine the C3 module of YOLOv5 and MobileOne to construct the C3_MobileOne module. The C3_MobileOne module includes two module structures: C3_MobileOne_1_X and C3_MobileOne_2_X;

[0014] In the C3_MobileOne_1_X module, the input is split into two paths. One path is sequentially input into the Concat module through the CBS module and the MobileOneBlock_1 module, and the other path is directly input into the Concat module through the CBS module. The Concat module is connected to the CBS module, and the output of the CBS module is the output of the C3_MobileOne_1_X module; the parameter X in the C3_MobileOne_1_X module represents the number of MobileOneBlock_1 modules therein;

[0015] In the C3_MobileOne_2_X module, the input is split into two paths. One path is sequentially input into the Concat module through the CBS module and the MobileOneBlock_2 module, and the other path is directly input into the Concat module through the CBS module. The Concat module is connected to the CBS module, and the output of the CBS module is the output of the C3_MobileOne_1_X module; the parameter X in the C3_MobileOne_1_X module represents that there are X MobileOneBlock_1 modules connected in series therein;

[0016] The MobileOneBlock_2 module consists of a 3x3 depth convolution and a 1x1 point convolution, uses a reparameterizable residual connection with BN, and the activation function uses the SiLU function; the MobileOneBlock_2 module has two different structures during training and inference. During training, it is a multi-branch model structure, and after structure reparameterization during inference, it becomes a single-path model structure; the MobileOneBlock_1 module has one more residual connection than the MobileOneBlock_2 module, and the rest are the same;

[0017] The MobileOneBlock_1 module has two different structures during training and inference. During training, it is a multi-branch model structure, and during inference, it becomes a single-path model structure after structural re-parameterization. The MobileOneBlock_1 module is mainly divided into two layers. During training, the first layer of the MobileOneBlock_1 module is a parallel kBlocks module and a residual connection with BN. The 1×1 Conv layer and the BN layer form a 1×1 CB module. The kBlocks module in the first layer consists of k parallel 1×1 CB modules, where k is a hyperparameter that varies from 1 to 5. The outputs of the kBlocks module and the residual connection with BN are added together, and the output after passing through the SiLU activation function is the output of the first layer. During training, the second layer of the MobileOneBlock_1 module is a parallel 1×1 CB module, kBlocks module, and a residual connection with BN. The 3×3 Conv layer and the BN layer form a 3×3 CB module. The kBlocks module in the second layer consists of k parallel 3×3 CB modules, where k is a hyperparameter that varies from 1 to 5. The outputs of the 1×1 CB module, kBlocks module, and the residual connection with BN are added together, and the output after passing through the SiLU activation function is the output of the second layer. The output obtained after the input of the MobileOneBlock_1 module passes through the first layer and the second layer in sequence, plus the input of the MobileOneBlock_1 module, is the output of the MobileOneBlock_1 module. During inference, the MobileOneBlock_1 module becomes a single-path model structure after structural re-parameterization. The output obtained after the input of the MobileOneBlock_1 module passes through the 1×1 Conv layer, SiLU activation function, 3×3 Conv layer, and SiLU activation function in sequence, plus the input of the MobileOneBlock_1 module, is the output of the MobileOneBlock_1 module;

[0018] The MobileOneBlock_2 module has two different structures during training and inference. During training, it is a multi-branch model structure, and after structure re-parameterization during inference, it becomes a single-path model structure. The MobileOneBlock_2 module is mainly divided into two layers. During training, the first layer of the MobileOneBlock_2 module is a parallel kBlocks module and a residual connection with BN. The 1×1 Conv layer and the BN layer form a 1×1 CB module. The kBlocks module in the first layer is composed of k parallel 1×1 CB modules, where k is a hyperparameter that varies from 1 to 5. The outputs of the kBlocks module and the residual connection with BN are added together, and the output after passing through the SiLU activation function is the output of the first layer. During training, the second layer of the MobileOneBlock_2 module is a parallel 1×1 CB module, kBlocks module, and a residual connection with BN. The 3×3 Conv layer and the BN layer form a 3×3 CB module. The kBlocks module in the second layer is composed of k parallel 3×3 CB modules, where k is a hyperparameter that varies from 1 to 5. The outputs of the 1×1 CB module, kBlocks module, and the residual connection with BN are added together, and the output after passing through the SiLU activation function is the output of the second layer. The output obtained by passing the input of the MobileOneBlock_2 module through the first layer and then the second layer in sequence is the output of the MobileOneBlock_2 module. During inference, the MobileOneBlock_2 module becomes a single-path model structure after structure re-parameterization. The output obtained by passing the input of the MobileOneBlock_2 module through the 1×1 Conv layer, SiLU activation function, 3×3 Conv layer, and SiLU activation function in sequence is the output of the MobileOneBlock_2 module.

[0019] Step 2.2: Replace the C3 structure in the Backbone with C3_MobileOne_1_X, and replace the C3 structure in the Neck with C3_MobileOne_2_X.

[0020] Step 2.3: Delete the C3_MobileOne_1_X module before SPPF, and add a C3_BoT module after SPPF.

[0021] Furthermore, the implementation method in the C3_BoT module is as follows:

[0022] In the C3_BoT module, the input is divided into two paths. One path is sequentially input into the Concat module through the CBS module and the BottleneckTransformer module, and the other path is directly input into the Concat module through the CBS module. The Concat module is connected to the CBS module, and the output of the CBS module is the output of the C3_BoT module; the BottleneckTransformer module is obtained by replacing the 3×3 Conv in the Bottleneck with the multi-head attention mechanism MHSA.

[0023] Further, in step 4, the trained MB-YOLOv5 model is structurally reparameterized as follows:

[0024] Step 4.1: Traverse the CBS modules in the MB-YOLOv5 model and fuse the Conv and BN in them into one Conv;

[0025] Step 4.2: Traverse the MobileOneBlock modules in the MB-YOLOv5 model, including the MobileOneBlock_1 module and the MobileOneBlock_2 module, and fuse their multi-branch structure into a single-path structure through structural reparameterization.

[0026] Further, the implementation method of fusing Conv and BN is as follows:

[0027] For the convolutional layer, the number of channels of each convolutional kernel is the same as the number of channels of the input feature map, and the number of convolutional kernels determines the number of channels of the output feature map; for the BN layer in the inference mode, it mainly includes 4 parameters: mean μ, variance σ, γ, and β, where μ and σ are statistically obtained during the training process, and γ and β are two learnable parameters obtained through training; the calculation formula for BN of the i-th channel of the feature map is as follows:

[0028]

[0029] where, x i is the data of the i-th channel of the feature map, that is, the input of BN for the i-th channel of the feature map, y i is the output; ∈ is a very small constant to prevent the denominator from being zero;

[0030] For the i-th channel, the BN function during inference is as follows:

[0031]

[0032] where, M represents the feature map input to the BN layer, and ∈ is ignored here;

[0033] Therefore, fusing Conv and BN into a single Conv with bias, for the \(i\)-th convolutional kernel, the formula for calculating the weights of the new convolutional layer after transformation is as follows:

[0034]

[0035] where \(W'\) and \(b'\) are the new weights and bias, and \(W\) is the weight of the original Conv.

[0036] Furthermore, the implementation method for structural reparameterization of the MobileOneBlock module is as follows:

[0037] (1) Fuse the first layer of the MobileOneBlock module into a \(1\times1\) Conv layer;

[0038] (1.1) Fuse the \(1\times1\) Conv layer and BN layer in the \(k\) parallel branches in \(kBlocks\) into a \(1\times1\) Conv layer with bias; construct a \(1\times1\) Conv layer in the residual connection with BN, which only performs an identity mapping, i.e., the input and output feature maps remain unchanged, and fuse this Conv layer and BN layer into a new \(1\times1\) Conv layer;

[0039] (1.2) Add the parameters of the \(1\times1\) Conv layers in each branch and merge them into a single-path \(1\times1\) Conv layer;

[0040] (2) Fuse the second layer of the MobileOneBlock module into a \(3\times3\) Conv layer;

[0041] (2.1) Fuse the \(1\times1\) Conv layer and BN layer into a \(1\times1\) Conv layer with bias; fuse the \(3\times3\) Conv layer and BN layer in the \(k\) parallel branches in \(kBlocks\) into a \(3\times3\) Conv layer with bias; construct a \(3\times3\) Conv layer in the residual connection with BN, which only performs an identity mapping, i.e., the input and output feature maps remain unchanged, and fuse this Conv layer and BN layer into a new \(3\times3\) Conv layer;

[0042] (2.2) Pad the convolutional kernel of the \(1\times1\) Conv layer with a circle of 0s to become a \(3\times3\) Conv layer;

[0043] (2.3) Add the parameters of the \(3\times3\) Conv layers in each branch and merge them into a single-path \(3\times3\) Conv layer. At the same time, to ensure that the height and width of the input and output feature maps remain unchanged, set the padding of the Conv layer to 1.

[0044] Compared with the prior art, the present invention has the following beneficial effects: It provides an insulator fault detection method based on improved YOLOv5. This method combines MobileOne, BoTNet, and YOLOv5 to construct an improved MB-YOLOv5 model, and performs structural reparameterization on the MB-YOLOv5 model, thereby improving the detection accuracy, reducing the number of parameters, and increasing the detection speed. Description of the Drawings

[0045] Figure 1 It is a structural diagram of the C3_MobileOne module in an embodiment of the present invention;

[0046] Figure 2 It is a structural diagram of the MobileOneBlock_1 module in an embodiment of the present invention;

[0047] Figure 3 It is a structural diagram of the MobileOneBlock_2 module in an embodiment of the present invention;

[0048] Figure 4 It is a schematic diagram of the structural reparameterization process of the first layer of the MobileOneBlock module in an embodiment of the present invention;

[0049] Figure 5 It is a schematic diagram of the structural reparameterization process of the second layer of the MobileOneBlock module in an embodiment of the present invention;

[0050] Figure 6 It is a structural diagram of the C3_BoT module in an embodiment of the present invention;

[0051] Figure 7 It is a structural diagram of the MHSA in an embodiment of the present invention;

[0052] Figure 8 It is a flowchart of the method implementation in an embodiment of the present invention;

[0053] Figure 9 It is a structural diagram of the MB-YOLOv5 model in an embodiment of the present invention. Detailed Embodiments

[0054] The present invention will be further described below in conjunction with the drawings and embodiments.

[0055] It should be noted that the following detailed description is exemplary and is intended to provide further explanation of the present application. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the technical field to which the present application belongs.

[0056] Note that the terms used herein are for the purpose of describing specific embodiments only and are not intended to limit the exemplary embodiments according to the present application. As used herein, unless the context clearly indicates otherwise, the singular forms are also intended to include the plural forms. In addition, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they specify the presence of features, steps, operations, devices, components, and / or combinations thereof.

[0057] As Figure 8 shown, this embodiment provides an insulator fault detection method based on improved YOLOv5, including the following steps:

[0058] Step 1: Preprocess the insulator dataset and divide it into a training set, a validation set, and a test set according to 7:2:1.

[0059] Step 2: Combine MobileOne, BoTNet, and YOLOv5 to construct the MB-YOLOv5 model. The structure of the MB-YOLOv5 model is as Figure 9 shown.

[0060] Step 2.1: Combine the C3 module of YOLOv5 and MobileOne to construct the C3_MobileOne module. The C3_MobileOne module includes two module structures, C3_MobileOne_1_X and C3_MobileOne_2_X.

[0061] Step 2.2: Replace the C3 structure in the Backbone with C3_MobileOne_1_X and replace the C3 structure in the Neck with C3_MobileOne_2_X.

[0062] Step 2.3: Delete the C3_MobileOne_1_X module before SPPF and add the C3_BoT module after SPPF.

[0063] Step 3: Input the training set and the validation set into the MB-YOLOv5 model for model training.

[0064] Step 4: Perform structural reparameterization on the trained MB-YOLOv5 model.

[0065] Step 4.1: Traverse the CBS modules in the MB-YOLOv5 model and fuse the Conv and BN in them into one Conv.

[0066] Step 4.2: Traverse the MobileOneBlock modules in the MB-YOLOv5 model, including the MobileOneBlock_1 module and the MobileOneBlock_2 module, and fuse them from a multi-branch structure into a single-path structure through structural re-parameterization.

[0067] Step 5: Input the test set into the MB-YOLOv5 model after structural re-parameterization to test the model performance.

[0068] Step 6: Use the finally obtained MB-YOLOv5 model for insulator fault detection.

[0069] C3_MobileOne module

[0070] According to some existing experiences, generally, parallelizing multiple branches can increase the representational ability of the model and improve the model performance. However, the number of parameters increases and the running speed slows down. While a single-path model is faster, more memory-efficient, and more flexible, but its performance is poor.

[0071] The present invention combines the C3 module of YOLOv5 and MobileOne to construct a C3_MobileOne module. The structure of the C3_MobileOne module is as Figure 1 shown, including two module structures: C3_MobileOne_1_X and C3_MobileOne_2_X. In the C3_MobileOne_1_X module, the input is split into two paths. One path sequentially passes through the CBS module, the MobileOneBlock_1 module and then inputs into the Concat module, and the other path directly passes through the CBS module and also inputs into the Concat module. The Concat module is connected to the CBS module, and the output of the CBS module is the output of the C3_MobileOne_1_X module; the parameter X in the C3_MobileOne_1_X module represents the number of MobileOneBlock_1 modules therein. In the C3_MobileOne_2_X module, the input is split into two paths. One path sequentially passes through the CBS module, the MobileOneBlock_2 module and then inputs into the Concat module, and the other path directly passes through the CBS module and also inputs into the Concat module. The Concat module is connected to the CBS module, and the output of the CBS module is the output of the C3_MobileOne_1_X module; the parameter X in the C3_MobileOne_1_X module represents that there are X MobileOneBlock_1 modules connected in series.

[0072] The structures of the MobileOneBlock_1 module and the MobileOneBlock_2 module are respectively as Figure 2 and Figure 3As shown, the MobileOneBlock_2 module consists of a 3x3 depth convolution and a 1x1 point convolution, uses a reparameterizable residual connection with BN, and the activation function is the SiLU function; the MobileOneBlock_2 module has two different structures during training and inference, Figure 3 (left) the multi-branch model structure, which becomes Figure 3 (right) the single-path model structure after structure reparameterization during inference. It realizes reducing the number of model parameters and improving the inference speed of the model without affecting the model accuracy. The MobileOneBlock_1 module has one more residual connection than the MobileOneBlock_2 module, and the rest are the same.

[0073] The MobileOneBlock_1 module has two different structures during training and inference. During training, it is a multi-branch model structure, and it becomes a single-path model structure after structure reparameterization during inference; the MobileOneBlock_1 module is mainly divided into two layers. During training, the first layer of the MobileOneBlock_1 module is a parallel kBlocks module and a residual connection with BN. The 1×1 Conv layer and the BN layer form a 1×1 CB module. The kBlocks module in the first layer consists of k parallel 1×1 CB modules, where k is a hyperparameter that varies from 1 to 5. The outputs of the kBlocks module and the residual connection with BN are added together, and the output after passing through the SiLU activation function is the output of the first layer; during training, the second layer of the MobileOneBlock_1 module is a parallel 1×1 CB module, kBlocks module, and a residual connection with BN. The 3×3 Conv layer and the BN layer form a 3×3 CB module. The kBlocks module in the second layer consists of k parallel 3×3 CB modules, where k is a hyperparameter that varies from 1 to 5. The outputs of the 1×1 CB module, kBlocks module, and the residual connection with BN are added together, and the output after passing through the SiLU activation function is the output of the second layer; the output obtained by passing the input of the MobileOneBlock_1 module through the first layer and the second layer in sequence, plus the input of the MobileOneBlock_1 module, is the output of the MobileOneBlock_1 module; during inference, the MobileOneBlock_1 module becomes a single-path model structure after structure reparameterization. The output obtained by passing the input of the MobileOneBlock_1 module through the 1×1 Conv layer, SiLU activation function, 3×3 Conv layer, and SiLU activation function in sequence, plus the input of the MobileOneBlock_1 module, is the output of the MobileOneBlock_1 module.

[0074] The MobileOneBlock_2 module has two different structures during training and inference. During training, it is a multi-branch model structure, and during inference, it becomes a single-path model structure after structural reparameterization. The MobileOneBlock_2 module is mainly divided into two layers. During training, the first layer of the MobileOneBlock_2 module consists of parallel kBlocks modules and a residual connection with BN. The 1×1 Conv layer and the BN layer form a 1×1 CB module. The kBlocks module in the first layer is composed of k parallel 1×1 CB modules, where k is a hyperparameter that varies from 1 to 5. The outputs of the kBlocks module and the residual connection with BN are added together, and the output after passing through the SiLU activation function is the output of the first layer. During training, the second layer of the MobileOneBlock_2 module consists of parallel 1×1 CB modules, kBlocks modules, and a residual connection with BN. The 3×3 Conv layer and the BN layer form a 3×3 CB module. The kBlocks module in the second layer is composed of k parallel 3×3 CB modules, where k is a hyperparameter that varies from 1 to 5. The outputs of the 1×1 CB module, the kBlocks module, and the residual connection with BN are added together, and the output after passing through the SiLU activation function is the output of the second layer. The output obtained by passing the input of the MobileOneBlock_2 module through the first layer and then the second layer in sequence is the output of the MobileOneBlock_2 module. During inference, the MobileOneBlock_2 module becomes a single-path model structure after structural reparameterization. The output of the MobileOneBlock_2 module is obtained by passing the input of the MobileOneBlock_2 module through the 1×1 Conv layer, the SiLU activation function, the 3×3 Conv layer, and the SiLU activation function in sequence.

[0075] Fusion of Conv and BN

[0076] Since both the Conv and BN operators perform linear operations, they can be fused into one operator. For the convolutional layer, the number of channels of each convolutional kernel is the same as the number of channels of the input feature map, and the number of convolutional kernels determines the number of channels of the output feature map. For the BN layer in the inference mode, it mainly contains four parameters: mean μ, variance σ, γ, and β. Among them, μ and σ are obtained by statistics during the training process, and γ and β are two learnable parameters that are obtained through training and will be continuously optimized as the model is trained. The calculation formula for BN of the i-th channel of the feature map is as follows:

[0077]

[0078] where, x i is the data of the i-th channel of the feature map, that is, for the i-th channel of the feature map, the input of BN, yi is the output; ∈ is a very small constant to prevent the denominator from being zero.

[0079] The BN function during inference is as follows (for the i-th channel):

[0080]

[0081] where M represents the feature map input to the BN layer, and ∈ is ignored here.

[0082] Therefore, fusing Conv and BN into a Conv with bias, the calculation formula for the weights of the new convolutional layer after conversion is as follows (for the i-th convolutional kernel):

[0083]

[0084] where W′ and b′ are the new weights and bias, and W is the weight of the original Conv.

[0085] The output of Conv is the input of BN. The i-th convolutional kernel of Conv obtains the i-th channel of the output feature map. The weight parameter of the i-th convolutional kernel of the original Conv and the parameters of BN for the i-th channel of the feature map are fused into the parameters of the i-th convolutional kernel of the new Conv.

[0086] W i,:,:,: represents the weight parameter of the i-th convolutional kernel of the original Conv, W' i,:,:,: and b' i represent the weight and bias of the i-th convolutional kernel of the new Conv after fusion, M :,i,:,: is the data of the i-th channel of the feature map input to BN.

[0087] Other parameters in formulas (2) and (3) are the parameters of BN for the i-th channel of the feature map.

[0088] Reparameterization of MobileOneBlock Structure

[0089] The implementation method for reparameterizing the structure of the MobileOneBlock module is as follows:

[0090] (1) As Figure 4 shown, fuse the first layer of the MobileOneBlock module into a 1×1 Conv layer.

[0091] (1.1)Fuse the 1×1 Conv layer and BN layer in k parallel branches in kBlocks into a 1×1 Conv layer with bias; construct a 1×1 Conv layer in the residual connection with BN, which only performs an identity mapping, that is, the input and output feature maps remain unchanged, and fuse this Conv layer and BN layer into a new 1×1 Conv layer.

[0092] (1.2)Add the parameters of the 1×1 Conv layers of each branch and merge them into a single-path 1×1 Conv layer.

[0093] (2)As Figure 5 shown, fuse the second layer of the MobileOneBlock module into a 3×3 Conv layer.

[0094] (2.1)Fuse the 1×1 Conv layer and BN layer into a 1×1 Conv layer with bias; fuse the 3×3 Conv layers and BN layers in k parallel branches in kBlocks into 3×3 Conv layers with bias; construct a 3×3 Conv layer in the residual connection with BN, which only performs an identity mapping, that is, the input and output feature maps remain unchanged, and fuse this Conv layer and BN layer into a new 3×3 Conv layer.

[0095] (2.2)Pad a circle of 0s around the convolution kernel of the 1×1 Conv layer to become a 3×3 Conv layer.

[0096] (2.3)Add the parameters of the 3×3 Conv layers of each branch and merge them into a single-path 3×3 Conv layer. At the same time, to ensure that the height and width of the input and output feature maps remain unchanged, set the padding of the Conv layer to 1.

[0097] Attention mechanism C3_BoT module

[0098] BoTNet is a conceptually simple but powerful backbone that incorporates self-attention into various computer vision tasks, including image classification, object detection, and instance segmentation. This method significantly improves the baseline in instance segmentation and object detection while also reducing the number of parameters, thereby minimizing latency.

[0099] The present invention combines the C3 module of YOLOv5 and BoTNet to construct a C3_BoT module. The structure of the C3_BoT module is as Figure 6 shown. Replace the 3×3 Conv in the Bottleneck of the C3 module with a multi-head self-attention mechanism (MHSA) to obtain the C3_BoT module. The MHSA structure is asFigure 7 As shown, the input size of MHSA is H×W×d, representing the height, width, and dimension of the input feature matrix, respectively. R h and R w are two learnable parameter vectors, representing the position encodings at different positions in height and width respectively. W Q 、W K and W V are three different 1×1 point convolutions respectively.

[0100] Specifically, the structure of the C3_BoT module is as follows: In the C3_BoT module, the input is divided into two paths. One path passes through the CBS module and the BottleneckTransformer module in sequence and then enters the Concat module, and the other path directly enters the Concat module through the CBS module. The Concat module is connected to the CBS module, and the output of the CBS module is the output of the C3_BoT module; the BottleneckTransformer module is obtained by replacing the 3×3 Conv in the Bottleneck with the multi-head attention mechanism MHSA.

[0101] Experimental verification

[0102] Experimental environment configuration: The Windows 10 operating system is adopted, the GPU model is NVIDIA GeForce GTX 1650Ti, the video memory size is 4G, the CPU model is Intel(R) Core(TM) i5-10200H CPU @ 2.40GHz, the memory size is 16G, and the pytorch 1.10 deep learning framework is used.

[0103] The experimental insulator dataset comes from the China Power Line Insulator Dataset (CPLID). The insulator dataset is annotated by the Labelimg tool. The insulators are labeled as insulator, and the defect positions are labeled as defect. The annotated insulator dataset is divided into a training set, a validation set, and a test set according to 7:2:1. The number of training rounds is 150, and the batch size is 16. The performance of YOLOv5 and the structure reparameterized MB-YOLOv5 is shown in Table 1.

[0104] Table 1 Comparison of the performance of YOLOv5 and MB-YOLOv5

[0105] Network model mAP (%) Number of parameters (M) FLOPs (G) Detection time (ms) YOLOv5 96.6 7.016 15.8 17.7 MB-YOLOv5 97.2 5.251 10.8 15.8

[0106] It can be seen that compared with the YOLOv5 algorithm, the method of the present invention has an increase of 0.6% in mAP, a decrease of 25.1% in the number of parameters, a decrease of 31.6% in GFLOPs, and a decrease of 10.7% in the detection time on the GPU. The method of the present invention reduces the number of parameters of the model and improves the detection speed while maintaining a slight increase in accuracy.

[0107] The above are only the preferred embodiments of the present invention, and are not intended to limit the present invention in any other form. Any person skilled in the art may use the technical content disclosed above to make changes or modifications into equivalent embodiments with equivalent changes. However, any simple modifications, equivalent changes, and modifications made to the above embodiments based on the technical essence of the present invention without departing from the technical solution content of the present invention still fall within the protection scope of the technical solution of the present invention.

Claims

1. An insulator fault detection method based on improved YOLOv5, characterized in that, It includes the following steps: Step 1: Preprocess the insulator dataset and divide it into a training set, a validation set, and a test set according to a set ratio; Step 2: Combine MobileOne, BoTNet, and YOLOv5 to build the MB-YOLOv5 model; Step 3: Input the training set and the validation set into the MB-YOLOv5 model for model training; Step 4: Perform structural reparameterization on the trained MB-YOLOv5 model; Step 5: Input the test set into the MB-YOLOv5 model after structural reparameterization to test the model performance; Step 6: Use the finally obtained MB-YOLOv5 model for insulator fault detection; In Step 4, the trained MB-YOLOv5 model is structurally reparameterized as follows: Step 4.1: Traverse the CBS modules in the MB-YOLOv5 model and fuse the Conv and BN in them into one Conv; Step 4.2: Traverse the MobileOneBlock modules in the MB-YOLOv5 model, including the MobileOneBlock_1 module and the MobileOneBlock_2 module, and fuse them from a multi-branch structure into a single-path structure through structural reparameterization; The implementation method of fusing Conv and BN is as follows: For the convolutional layer, the number of channels of each convolutional kernel is the same as the number of channels of the input feature map, and the number of convolutional kernels determines the number of channels of the output feature map; for the BN layer in the inference mode, it mainly includes 4 parameters: mean μ, variance σ, γ, and β, where μ and σ are statistically obtained during the training process, and γ and β are two learnable parameters obtained through training; the calculation formula for BN of the i-th channel of the feature map is as follows: where x i is the data of the i-th channel of the feature map, that is, for the i-th channel of the feature map, the input of BN, y i is the output; ∈ is a very small constant to prevent the denominator from being zero; For the i-th channel, the BN function during inference is as follows: where M represents the feature map input to the BN layer, and ∈ is ignored here; Therefore, fuse Conv and BN into one Conv with a bias. For the i-th convolutional kernel, the calculation formula for the new convolutional layer weights after conversion is as follows: where W′ and b′ are the new weights and biases, and W is the weight of the original Conv.

2. The insulator fault detection method based on improved YOLOv5 according to claim 1, wherein, In Step 2, the MB-YOLOv5 model is built as follows: Step 2.1: Combine the C3 module of YOLOv5 and MobileOne to build the C3_MobileOne module, and the C3_MobileOne module includes two module structures: C3_MobileOne_1_X and C3_MobileOne_2_X; In the C3_MobileOne_1_X module, the input is divided into two paths. One path is sequentially input into the Concat module through the CBS module and the MobileOneBlock_1 module, and the other path is directly input into the Concat module through the CBS module. The Concat module is connected to the CBS module, and the output of the CBS module is the output of the C3_MobileOne_1_X module; the parameter X in the C3_MobileOne_1_X module indicates that there are X MobileOneBlock_1 modules in series; In the C3_MobileOne_2_X module, the input is divided into two paths. One path sequentially passes through the CBS module and the MobileOneBlock_2 module and then enters the Concat module, and the other path directly passes through the CBS module and also enters the Concat module. The Concat module is connected to the CBS module, and the output of the CBS module is the output of the C3_MobileOne_1_X module; the parameter X in the C3_MobileOne_2_X module represents the number of MobileOneBlock_2 modules therein; The MobileOneBlock_2 module consists of a 3x3 depth convolution and a 1x1 point convolution, uses a reparameterizable residual connection with BN, and the activation function uses the SiLU function; the MobileOneBlock_2 module has two different structures during training and inference. During training, it is a multi-branch model structure, and during inference, it becomes a single-path model structure after structural reparameterization; the MobileOneBlock_1 module has one more residual connection than the MobileOneBlock_2 module, and the rest are the same; The MobileOneBlock_1 module has two different structures during training and inference. During training, it is a multi-branch model structure, and during inference, it becomes a single-path model structure after structural re-parameterization. The MobileOneBlock_1 module is mainly divided into two layers. During training, the first layer of the MobileOneBlock_1 module is a parallel k Blocks module and a residual connection with BN. The 1×1 Conv layer and the BN layer form a 1×1 CB module. The k Blocks module in the first layer is composed of k parallel 1×1 CB modules, where k is a hyperparameter that varies from 1 to 5. The outputs of the k Blocks module and the residual connection with BN are added together, and the output after passing through the SiLU activation function is the output of the first layer. During training, the second layer of the MobileOneBlock_1 module is a parallel 1×1 CB module, a k Blocks module, and a residual connection with BN. The 3×3 Conv layer and the BN layer form a 3×3 CB module. The k Blocks module in the second layer is composed of k parallel 3×3 CB modules, where k is a hyperparameter that varies from 1 to 5. The outputs of the 1×1 CB module, the k Blocks module, and the residual connection with BN are added together, and the output after passing through the SiLU activation function is the output of the second layer. The output obtained by passing the input of the MobileOneBlock_1 module through the first layer and the second layer in sequence, plus the input of the MobileOneBlock_1 module, is the output of the MobileOneBlock_1 module. During inference, the MobileOneBlock_1 module becomes a single-path model structure after structural re-parameterization. The output obtained by passing the input of the MobileOneBlock_1 module through the 1×1 Conv layer, the SiLU activation function, the 3×3 Conv layer, and the SiLU activation function in sequence, plus the input of the MobileOneBlock_1 module, is the output of the MobileOneBlock_1 module; The MobileOneBlock_2 module has two different structures during training and inference. During training, it is a multi-branch model structure, and during inference, it becomes a single-path model structure after structural reparameterization. The MobileOneBlock_2 module is mainly divided into two layers. During training, the first layer of the MobileOneBlock_2 module is a parallel k Blocks module and a residual connection with BN. The 1×1 Conv layer and the BN layer form a 1×1 CB module. The k Blocks module in the first layer consists of k parallel 1×1 CB modules, where k is a hyperparameter that varies from 1 to 5. The outputs of the k Blocks module and the residual connection with BN are added together, and the output after passing through the SiLU activation function is the output of the first layer. During training, the second layer of the MobileOneBlock_2 module is a parallel 1×1 CB module, k Blocks module, and a residual connection with BN. The 3×3 Conv layer and the BN layer form a 3×3 CB module. The k Blocks module in the second layer consists of k parallel 3×3 CB modules, where k is a hyperparameter that varies from 1 to 5. The outputs of the 1×1 CB module, k Blocks module, and the residual connection with BN are added together, and the output after passing through the SiLU activation function is the output of the second layer. The output obtained by passing the input of the MobileOneBlock_2 module through the first layer and then the second layer in sequence is the output of the MobileOneBlock_2 module. During inference, the MobileOneBlock_2 module becomes a single-path model structure after structural reparameterization. The output obtained by passing the input of the MobileOneBlock_2 module through the 1×1 Conv layer, SiLU activation function, 3×3 Conv layer, and SiLU activation function in sequence is the output of the MobileOneBlock_2 module. Step 2.2: Replace the C3 structure in the Backbone with C3_MobileOne_1_X and replace the C3 structure in the Neck with C3_MobileOne_2_X. Step 2.3: Delete the C3_MobileOne_1_X module before the SPPF and add a C3_BoT module after the SPPF.

3. The insulator fault detection method based on improved YOLOv5 according to claim 2, wherein, The implementation method in the C3_BoT module is as follows: In the C3_BoT module, the input is split into two paths. One path passes through the CBS module, BottleneckTransformer module, and then enters the Concat module, and the other path directly passes through the CBS module and also enters the Concat module. The Concat module is connected to the CBS module, and the output of the CBS module is the output of the C3_BoT module. The BottleneckTransformer module is obtained by replacing the 3×3 Conv in the Bottleneck with the multi-head attention mechanism MHSA.

4. The insulator fault detection method based on improved YOLOv5 according to claim 1, characterized in that, The implementation method for structural reparameterization of the MobileOneBlock module is as follows: (1)Fuse the first layer of the MobileOneBlock module into a 1×1 Conv layer; (1.1)Fuse the 1×1 Conv layer and BN layer in the k parallel branches of k Blocks into a 1×1 Conv layer with bias; Construct a 1×1 Conv layer in the residual connection with BN. This Conv layer only performs an identity mapping, that is, the input and output feature maps remain unchanged. Fuse this Conv layer and BN layer into a new 1×1 Conv layer; (1.2)Add the parameters of the 1×1 Conv layers in each branch and merge them into a single-path 1×1 Conv layer; (2)Fuse the second layer of the MobileOneBlock module into a 3×3 Conv layer; (2.1)Fuse the 1×1 Conv layer and BN layer into a 1×1 Conv layer with bias; Fuse the 3×3 Conv layer and BN layer in the k parallel branches of k Blocks into a 3×3 Conv layer with bias; Construct a 3×3 Conv layer in the residual connection with BN. This Conv layer only performs an identity mapping, that is, the input and output feature maps remain unchanged. Fuse this Conv layer and BN layer into a new 3×3 Conv layer; (2.2)Pad the convolution kernel of the 1×1 Conv layer with a circle of 0s to become a 3×3 Conv layer; (2.3)Add the parameters of the 3×3 Conv layers in each branch and merge them into a single-path 3×3 Conv layer. At the same time, to ensure that the height and width of the input and output feature maps remain unchanged, set the padding of the Conv layer to 1.

Citation Information

Patent Citations

  • YOLO-based insulator infrared fault positioning diagnosis method and device

    CN110780164A

  • Insulator insulation state evaluation method based on 3D-CNN and LSTM of ultraviolet video

    CN111289854A