Lightweight power transmission line insulator defect detection algorithm based on SGA and SE-F
By introducing attention mechanism and a same-scale weighted fusion module in the YOLOv5 model, combined with channel pruning and knowledge distillation technology, the problem of insufficient feature extraction capability and large model calculation volume of insulator defect detection in complex background is solved, and efficient Real-time insulator defect detection.
Patent Information
- Application Number
- CN202411394401.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-08
- Publication Date
- 2024-12-31
AI Technical Summary
The existing deep learning-based transmission line insulator defect detection algorithm has insufficient feature extraction capabilities in complex backgrounds, and the model calculation is large, making it difficult to realize real-time detection in drone terminals.
Introducing attention mechanism SGA and homoscale weighted fusion module SE-f, combining channel pruning and knowledge distillation technology, the YOLOv5 model is optimized to improve detection accuracy and real-time.
In the complex context, the accurate and rapid detection of insulator defects is achieved, with an average detection accuracy of 93.4%, and the number of frames per second can reach 140.3, taking into account both detection accuracy and real-timeness.
Smart Images

Figure CN119228777A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of deep learning technology, and in particular to a lightweight transmission line insulator defect detection algorithm based on SGA and SE-F. Background Art
[0002] As a key component to ensure the transmission of electric energy, the maintenance and repair of transmission lines is an important step to ensure the safe and stable operation of the power grid. Transmission line components mainly include conductors, insulators, towers, etc. Among them, insulators are the most widely used and basic components in transmission lines, and their failure is also one of the main causes of line failures. Therefore, regular inspection of transmission line insulator failures is particularly important for the safe operation of the power system. In recent years, the use of drones to inspect transmission lines has become an important mode of transmission line inspection at home and abroad. This inspection mode has significantly improved the efficiency and safety of power system inspections and reduced labor costs. However, with the continuous expansion of the scale of the transmission network, the data collected by drones has shown a doubling trend, which has added a huge workload to relevant technical personnel. At present, in the field of transmission line inspection, the use of drones to inspect high-voltage transmission lines and the real-time and accurate detection of fault targets in the inspection data based on computer vision technology have become an important research direction, and it is also a very challenging topic.
[0003] At present, object detection based on deep learning has become the main research direction in the field of computer vision, and it is also a research hotspot that has attracted much attention. This method can effectively overcome the problems of low detection accuracy, susceptibility to environmental interference, and insufficient generalization ability in traditional manual object detection. Object detection algorithms based on deep learning can be divided into two types:
[0004] One is a two-stage algorithm, which first generates candidate boxes, and then classifies and locates these boxes to provide higher accuracy while effectively distinguishing different categories of targets. This method has advantages in target location accuracy and multi-category recognition. Representative algorithms include R-CNN, Fast R-CNN, Faster R-CNN, etc. However, the two-stage target detection algorithm has the disadvantage of relatively low real-time performance. It requires two processing stages, resulting in a slow overall detection speed and cannot meet real-time requirements. At the same time, due to its complex network structure and large model parameters, it is difficult to deploy efficiently on mobile terminals with limited computing resources. In addition, the two-stage algorithm is relatively difficult to handle small targets, which can easily lead to missed detections and false detections, and it has a high dependence on a large amount of labeled data. Insufficient data or inaccurate labeling will affect the performance of the algorithm.
[0005] The other is a one-stage detection algorithm based on regression. Its main idea is to divide the image into S×S cells. Each cell is responsible for detecting the target whose center point falls within the cell and predicting the bounding box and target category information. Typical algorithms include SSD
[18] and YOLO series. Xuan L et al. improved the feature fusion part of the SSD algorithm to detect insulators and spacers in transmission lines. Finally, the experiment proved that the detection accuracy of the improved algorithm is better than the initial algorithm. Ang G et al. detected extreme weld noise based on the YOLOv5 detection framework, introduced the re-parameterized convolutional neural network RepVGG to optimize the network structure
[30] , and used the lightweight attention mechanism module NAM
[31] to enhance the network's perception of feature points. The improved model has greatly improved the detection accuracy compared with the initial YOLOv5 model and the traditional CNN method. Hulin Li et al. combined the standard convolution SC and the depthwise separable convolution DWConv to propose a new convolution GSConv
[32] to replace the standard convolution layer in YOLOv5 to reduce the model calculation amount while ensuring sufficiently high accuracy. Experiments show that the improved detection efficiency is higher in the unmanned driving road detection task. Xingkui Zhu et al. designed a new detection head TPH based on Transformer Encoder for drone road detection tasks. Experiments show that the improved model has higher detection accuracy for various targets on the road. Bao W et al. proposed a defect detection method for insulators and shock absorbers based on YOLOv5. This study introduced the CA attention mechanism into the YOLOv5 network, enhancing the network's ability to detect insulators and shock absorbers under complex backgrounds. At the same time, BiFPN was used instead of the original PANet feature fusion framework to enhance the network's detection ability for small targets. Experiments show that the model has improved the detection ability of both defects compared to the initial model.
[0006] In summary, existing research on the improvement of the algorithm can be divided into two directions. The first is to improve the model detection accuracy by introducing modules or improving the network structure, but at the same time it will increase the complexity of the network, increase the number of model parameters and the amount of calculation, resulting in poor real-time detection. The second is to use a lightweight network to replace the original structure to improve the model detection speed, but it cannot guarantee a sufficiently high detection accuracy.
[0007] YOLOv5 is one of the one-stage detection models with a low training threshold in the You Only Look Once (YOLO) series. Among many models, this model achieves the best balance between detection speed and accuracy. It is currently the most widely used transmission line insulator defect detection model.
[0008] Although YOLOv5 inherits many improvement strategies from previous versions, it still has poor feature extraction capabilities for defective targets and smaller targets in complex backgrounds. In addition, since the location information and semantic information of such targets are not clear enough, the feature fusion method of FPN+PAN alone cannot achieve effective fusion of features. The model has too much computational complexity, making it impossible to effectively deploy it on drone terminals for real-time detection.
[0009] To solve the above problems and combining the characteristics of the transmission line insulator defect dataset, the present invention first improves the initial model by introducing the attention mechanism and constructing a new feature fusion method, then combines the channel pruning algorithm to realize model lightweight, and finally constructs a knowledge distillation model to improve the detection accuracy of the pruned model. Summary of the invention
[0010] The purpose of the present invention is to provide a lightweight transmission line insulator defect detection algorithm based on SGA and SE-F to address the shortcomings and defects in the prior art. The present invention first improves the initial model by introducing an attention mechanism and constructing a new feature fusion method, and then combines the channel pruning algorithm to achieve model lightweight, and finally constructs a knowledge distillation model to improve the detection accuracy of the pruned model.
[0011] To achieve the above-mentioned purpose, the present invention adopts the following technical scheme: a lightweight transmission line insulator defect detection algorithm based on SGA and SE-F, which specifically includes the following steps: first, a new attention mechanism SGA is introduced on the basis of the YOLOv5 network to enhance the saliency of the defect target to be detected, so as to solve the problem that the features of tiny insulator defects are difficult to extract; secondly, a same-scale weighted fusion module SE-f is proposed to replace the Concat module in the feature fusion network, thereby improving the network's ability to fuse the features of low-level position information and high-level semantic information; thirdly, the improved YOLOv5 is further optimized through sparse training and channel pruning; at the same time, knowledge distillation is used to guide the model to learn knowledge and improve detection accuracy; finally, a classification cycle training method is used to solve the problem of low model learning efficiency caused by unbalanced sample quantity and differences in background complexity.
[0012] Furthermore, the attention mechanism SGA is specifically: x'=f 1×1 (GN(x)×Softmax(SDA(Q,K,V))); Where W1, W2, and W3 are the weight matrices obtained by x passing through three fully connected layers respectively;
[0013] In the feature normalization stage, the attention mechanism SGA uses GroupNorm instead of BatchNorm used in the original NAM. This is because in actual model training, BatchNorm needs to use a sufficiently large Batch Size. If the Batch Size is too small, the false detection rate of the model will be greatly increased. However, in actual tasks, the input image data is very large, and a larger Batch Size will cause video memory overflow. The normalization method of GroupNorm avoids the influence of Batch size on the model. First, the channels are grouped, and then the mean and variance of each group in the channel direction are calculated. The calculation process is as follows: Among them, μ ng (x) represents the mean of the current group with n dimensions retained; σ ng (x) represents the variance of the current group; ε is a value as small as possible; γ and β are scaling factors and translation factors respectively;
[0014] In the attention weight calculation stage, the scaled dot product attention mechanism in the single-head self-attention model is used to redesign a branch to calculate the attention weight. First, three fully connected layers are used to extract the Query, Key, and Value vectors from the input x. Then, the scaled dot product is performed on the Query and Key vectors, and the similarity between each Query vector and the Key vector is calculated to obtain the score matrix scores. Then, the score matrix is normalized by Softmax to obtain the weight matrix of the Value vector. Finally, the weight matrix is multiplied by the Value vector to obtain the attention weight.
[0015] Furthermore, the same-scale weighted fusion module SE-f is specifically as follows: the original network adopts the FPN+PAN structure in the feature fusion part, which is conducive to the mutual transmission between high-level semantic information and low-level position information, thereby enhancing the positioning ability and semantic expression at multiple scales. However, when there are target occlusion, shadow, noise and other factors in a complex background, which leads to unclear position information and semantic information of the detected target, it is impossible to effectively fuse the features. A same-scale weighted fusion module SE-f is proposed. When performing feature layer fusion, the module first compresses the spatial dimension of each channel of the input tensor into a value through global average pooling, and then uses a fully connected layer to learn the weight of each channel, generates weight vectors α and β and weights the input feature vector; finally, the weighted features are concat fused; the final feature fusion result Output is expressed as follows Output=α×H+β×L, where Output represents the output feature map, and α and β represent the attention weights obtained by the input feature map through the SE attention mechanism.
[0016] Furthermore, the model optimization of the improved YOLOv5 includes structure optimization and accuracy optimization.
[0017] Furthermore, the structural optimization is specifically as follows: after the initial YOLOv5s network is improved, its computational complexity is slightly increased compared to the initial YOLOv5s network, and the model size is large after training. Excessive computational complexity will cause the algorithm reasoning to take a long time, thereby affecting the real-time performance of the detection, and the large-volume model is not conducive to the deployment of the algorithm on mobile terminals. In order to compress the model volume, it is necessary to screen unimportant channels and take model pruning operations. In order to maintain network integrity and reduce hardware costs, the model is compressed by channel pruning, which finds and deletes minor channels through sparse training, thereby reducing the computational complexity; first, the sparsity of the scaling factor γ in the BN layer is adjusted by adjusting the sparse coefficient sr, wherein the specific operations of the BN layer are as follows Output y i Depend on Calculate, where x1,x2,...,x k is the output of the previous layer, k is the batch size, μ B and σ B is the mean and variance of each batch of data, ε is the regularization parameter used to prevent the denominator from being zero during calculation, and the scaling factor γ and translation factor β are both learnable parameters; after sparsely expressing the set C of scaling factors γ corresponding to each channel in each convolutional layer, the feature channels with γ values close to 0 are secondary channels, and the regularization formula of C is introduced into the network loss function as follows: Where (x, y) is the input and output of the training, W is the model weight, L(f(x, W), y) is the initial model loss, λ is the balance factor, and g(γ) is the coefficient loss;
[0018] The scaling factor γ after sparse training is connected to its corresponding feature channel and sorted by absolute value. The pruning threshold S is determined by customizing the pruning ratio. If the γ value corresponding to the channel is less than S, it is judged as a secondary channel and pruned. The S value should be less than the maximum value of γ in the BN layer.
[0019] Furthermore, the precision optimization is specifically as follows: knowledge distillation is to use the idea of transfer learning to guide the training of small models with the knowledge learned by the high-precision large model, thereby accelerating the convergence of the smaller model. Considering that the improved YOLOv5 model has the problem of reduced precision after the channel pruning operation, the pruned model is fine-tuned by knowledge distillation to maintain a high detection accuracy; wherein, the teacher model uses the improved YOLOv5s before channel pruning; the YOLOv5s after channel pruning is used as the student model, Sl is the soft label Soft label output by the teacher model, Sp is the soft prediction Softprediction output by the student model, Hp is the hard prediction Hard prediction output by the student model, and Hl is the hard label Hard label; the loss function L between the student network and the teacher network is constructed by setting the distillation temperature T = t. dist , set T = 1 to construct the loss function L between the student network and the true value label stu , and finally the weighted sum of the two is taken as the final network loss; First, the target loss function is as shown in formula (11), where o i T is the target prediction value of the teacher network, is the target prediction value of the student network, λ D is the balance coefficient: The category loss function is as follows, introducing the updated teacher network target prediction value into the category and bounding box loss function If the prediction box contains only background information, then The value of will be very low, making the distillation loss close to 0, which can effectively prevent the student network from incorrectly learning background information: in, Predict values for the student model categories; is the teacher model category prediction value; similarly, the bounding box loss function is expressed as follows, in, Predicted values for the student model bounding box; is the bounding box prediction value of the teacher model; the final loss of the model is as follows, Loss = L stu +λ D L dist .
[0020] After adopting the above technical solution, the beneficial effects of the present invention are: the present invention has at least the following advantages:
[0021] (1) To address the problem that the original network has poor ability to extract features of smaller targets, the present invention designs a new attention mechanism module SGA to enhance the prominence of defective targets in images and improve the feature extraction capability of the network in the early stage.
[0022] (2) In the dataset, the location information and semantic information of some images are unclear due to the complex background, which makes the network unable to achieve effective feature fusion. The present invention designs a same-scale weighted fusion module SE-f based on the SE attention mechanism to improve the feature fusion ability of the network under complex backgrounds.
[0023] (3) In order to further optimize the model and take into account the real-time and accuracy of target detection, sparse training and channel pruning are used to process structural redundancy in the improved YOLOv5, and knowledge distillation learning is used to ensure the detection accuracy of the optimized model.
[0024] (4) In order to solve the problem of unbalanced sample numbers among different types of insulator defects in the data set and different background complexities of various insulators, which leads to low learning efficiency of the model and unbalanced detection effect, an experimental method of classification training is proposed to ensure the learning effect of the model for each defect type. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0026] Figure 1 It is a diagram of the YOLOv5 network structure in the present invention.
[0027] Figure 2 It is the structural diagram of the attention mechanism SGA in the present invention.
[0028] Figure 3 It is a diagram of the normalization method of BatchNorm and GroupNorm.
[0029] Figure 4 This is a comparison chart of the initial YOLOv5 network.
[0030] Figure 5 This is a comparison chart of the improved YOLOv5+NAM network.
[0031] Figure 6 This is a comparison chart of the improved YOLOv5+SGA network.
[0032] Figure 7 It is the structural diagram of the SE-f module in the present invention.
[0033] Figure 8 It is a graph showing the change of the scaling factor γ under different sparse coefficients in the present invention.
[0034] Fig. 9 It is a schematic diagram of the channel pruning process in the present invention.
[0035] Fig.10 This is a diagram of the YOLOv5s insulator detection algorithm that combines channel pruning and knowledge distillation.
[0036] Fig.11 It is a graph of partial insulator fault data set.
[0037] Fig.12 It is a schematic diagram of the changes in network evaluation indicators under different pruning rates.
[0038] Fig.13 This is a comparison chart of model parameters before pruning.
[0039] Fig.14 This is a comparison chart of model parameters after pruning.
[0040] Fig.15 It is a graph showing the difference in training loss and recall rate for different schemes.
[0041] Fig.16 This is the initial YOLOv5 detection result graph.
[0042] Fig.17 1 is a diagram of the detection results of the present invention. DETAILED DESCRIPTION
[0043] See also Figure 1 As shown, the technical solution adopted in this specific implementation is: it specifically includes the following steps:
[0044] S1, firstly, a new attention mechanism SGA is introduced based on the YOLOv5 network to enhance the prominence of the defect target to be detected, so as to solve the problem that the characteristics of tiny insulator defects are difficult to extract;
[0045] S2, secondly, a same-scale weighted fusion module SE-f is proposed to replace the Concat module in the feature fusion network, which improves the network's ability to fuse the features of low-level position information and high-level semantic information;
[0046] S3 again optimizes the model structure of the improved YOLOv5 through sparse training and channel pruning. At the same time, knowledge distillation is used to guide the model to learn knowledge and improve detection accuracy.
[0047] S4,Finally, the classification cycle training method is used to solve the problem of low model learning efficiency caused by unbalanced sample number and differences in background complexity.
[0048] Experimental results show that the algorithm of the present invention can realize accurate and rapid detection of insulator defects under complex backgrounds, with an average detection accuracy of 93.4% and a frame rate of 140.3 per second.
[0049] See also Figure 2 As shown, the attention mechanism SGA in S1 is specifically as follows:
[0050] x'=f 1×1 (GN(x)×Softmax(SDA(Q,K,V))) (1)
[0051]
[0052] Where W1, W2, and W3 are the weight matrices obtained by x passing through three fully connected layers respectively;
[0053] In the feature normalization stage, the attention mechanism SGA uses GroupNorm instead of BatchNorm used in the original NAM. This is because in actual model training, BatchNorm needs to use a sufficiently large Batch Size. If the Batch Size is too small, the false detection rate of the model will be greatly increased. However, in actual tasks, the input image data is very large, and a larger Batch Size will cause video memory overflow. The normalization method of GroupNorm avoids the influence of Batch size on the model. First, the channels are grouped, and then the mean and variance of each group in the channel direction are calculated. The calculation process is as follows. The normalization methods of BatchNorm and GroupNorm are as follows: Figure 3 As shown:
[0054]
[0055] Among them, μ ng (x) represents the mean of the current group with n dimensions retained; σ ng (x) represents the variance of the current group; ε is a value as small as possible, such as 1×10 -8 ;γ and β are scaling factors and translation factors respectively;
[0056] In the attention weight calculation stage, the scaled dot product attention mechanism in the single-head self-attention model is used to redesign a branch to calculate the attention weight, such as Figure 2First, three fully connected layers are used to extract the Query, Key, and Value vectors from the input x. Then, the scaled dot product is performed on the Query and Key vectors, and the similarity between each Query vector and the Key vector is calculated to obtain the score matrix scores. Then, the score matrix is normalized by Softmax to obtain the weight matrix of the Value vector. Finally, the weight matrix is multiplied by the Value vector to obtain the attention weight.
[0057] See also Figure 4-Figure 6 As shown in Figure 2, to verify the effectiveness of SGA, the study makes a visualization comparison of the 9th layer of the initial YOLOv5 network, the improved YOLOv5 network with NAM introduced in the 10th layer, and the improved YOLOv5 network with SGA introduced in the 10th layer. Figure 5 ,The results show that the contribution of SGA in this experiment is better than that of NAM.
[0058] The same-scale weighted fusion module SE-f in S2 is specifically:
[0059] The original network uses the FPN+PAN structure in the feature fusion part. This structure is conducive to the mutual transmission between high-level semantic information and low-level position information, thereby enhancing the positioning ability and semantic expression at multiple scales. However, when there are factors such as target occlusion, shadow, noise, etc. in a complex background, which leads to unclear position information and semantic information of the detected target, it is impossible to effectively fuse the features.
[0060] A weighted fusion module SE-f between the same scales is proposed, and its structure is as follows Figure 7 As shown, H represents features with high-level semantic information, L represents features with low-level position information, and H' and L' represent weighted features. When this module performs feature layer fusion, it first compresses the spatial dimension of each channel of the input tensor into a value through global average pooling, then uses a fully connected layer to learn the weight of each channel, generates weight vectors α and β, and weights the input feature vector; finally, the weighted features are concat fused; the final feature fusion result Output is expressed as follows (7):
[0061] Output = α × H + β × L (7)
[0062] Among them, Output represents the output feature map, α and β represent the attention weights obtained by the input feature map through the SE attention mechanism.
[0063] The model optimization of improving YOLOv5 in S3 includes structure optimization and accuracy optimization.
[0064] The structural optimization is specifically as follows: after the initial YOLOv5s network is improved, its computational complexity is slightly increased compared to the initial YOLOv5s network, and the model volume is large after training. Excessive computational complexity will cause the algorithm reasoning to take a long time, thereby affecting the real-time performance of the detection, and the large-volume model is not conducive to the deployment of the algorithm on mobile terminals. In order to compress the model volume, it is necessary to screen unimportant channels and take model pruning operations. In order to maintain network integrity and reduce hardware costs, the model is compressed by channel pruning, which finds and deletes minor channels through sparse training, thereby reducing the computational complexity;
[0065] First, the sparsity of the scaling factor γ in the BN layer is adjusted by adjusting the sparsification coefficient sr, as Figure 8 , where the specific operation of the BN layer is as shown in formula (8), and the output y i Calculated by formula (9), the details are as follows:
[0066]
[0067] where x1,x2,...,x k is the output of the previous layer, k is the batch size, μ B and σ B is the mean and variance of each batch of data, ε is the regularization parameter used to prevent the denominator from being zero during calculation, and the scaling factor γ and translation factor β are both learnable parameters;
[0068] After sparsely expressing the set C of scaling factors γ corresponding to each channel in each convolutional layer, the feature channels with γ values close to 0 are secondary channels. The regularization formula of C is introduced into the network loss function as shown in formula (10), which is as follows:
[0069]
[0070] Where (x, y) is the input and output of the training, W is the model weight, L(f(x, W), y) is the initial model loss, λ is the balance factor, and g(γ) is the coefficient loss;
[0071] The scaling factor γ after sparse training is connected to its corresponding feature channel and sorted by absolute value. The pruning threshold S is determined by customizing the pruning ratio. If the γ value corresponding to the channel is less than S, it is judged as a secondary channel and pruned. The S value should be less than the maximum value of γ in the BN layer. The process of channel pruning is as follows: Fig. 9 shown.
[0072] The precision optimization is specifically as follows: knowledge distillation is to use the idea of transfer learning to guide the training of small models with the knowledge learned by the high-precision large model, thereby accelerating the convergence of the smaller model. Considering that the improved YOLOv5 model has a problem of reduced precision after channel pruning, the pruned model is fine-tuned by knowledge distillation to maintain a high detection accuracy; the specific process is as follows Fig.10 As shown;
[0073] The teacher model uses the improved YOLOv5s before channel pruning; the YOLOv5s after channel pruning is used as the student model, Sl is the soft label output by the teacher model, Sp is the soft prediction output by the student model, Hp is the hard prediction output by the student model, and Hl is the hard label;
[0074] By setting the distillation temperature T = t, the loss function L between the student network and the teacher network is constructed. dist , set T = 1 to construct the loss function L between the student network and the true value label stu , and finally the weighted sum of the two is taken as the final loss of the network;
[0075] First, the objective loss function is as shown in formula (11), where is the target prediction value of the teacher network, is the target prediction value of the student network, λ D is the balance coefficient:
[0076]
[0077] The category loss function is as shown in formula (12), which introduces the updated teacher network target prediction value into the category and bounding box loss functions If the prediction box contains only background information, then The value of will be very low, making the distillation loss close to 0, which can effectively prevent the student network from incorrectly learning background information:
[0078]
[0079] in, Predict values for the student model categories; Predict values for the teacher model categories;
[0080] Similarly, the bounding box loss function is expressed as formula (13):
[0081]
[0082] in, Predicted values for the student model bounding box; Predicted value for the teacher model bounding box;
[0083] The final loss of the model is as follows:
[0084] Loss = L stu +λ D L dist (14).
[0085] The following are the relevant experimental results and analysis of the present invention
[0086] Platform construction and data set
[0087] The software and hardware environment configurations used for model training and testing of the present invention are: Windows 11v22621.2428 operating system, pytorch deep learning framework, CUDA v11.3, Opencv v4.7.0, CPU 12th Gen Intel (R) Core (TM) i7-12700H, GPU NVIDIA GeForce RTX 3050Ti.
[0088] The data used in the experiment is the data obtained by a certain inspection department using drones to inspect 500kV transmission lines in the past four years. The targets selected in the experiment include broken insulators, missing insulators, insulator flashovers, and normal insulators. Some fault targets are as follows: Fig.11 shown.
[0089] Four types of detection samples, including normal insulators, totaling 1,200 images, were intercepted from the inspection video data. The definitions of each type of detection samples are shown in Table 1. 1 / 5 of the number of samples of each type of fault, that is, 240 images, were selected as test samples, and the remaining 960 images were used as training samples. In order to expand the number of training samples and improve the accuracy of network detection, the 1,200 training samples were randomly rotated 45° clockwise and counterclockwise, brightness enhanced, and contrast enhanced, and a total of 4,800 training samples were obtained.
[0090] Table 1 Fault type and quantity
[0091]
[0092]
[0093] Network model training
[0094] When training the model, the classification training method + cycle training method is used. First, the size of the sample images of one category of detection is uniformly adjusted to 640×640, and each batch of training batches is 8 sample images. The number of training rounds is set to 300 rounds, and the learning rate in the first 200 rounds of training is set to 0.01, and the learning rate in the last 100 rounds of training is set to 0.001. When the number of training rounds reaches 300 rounds, the loss size and accuracy reach a stable state.
[0095] Classification cycle training method
[0096] (1) Classification training method
[0097] Due to the imbalance in the number of defect samples among different types of insulator defects and the different background complexity of various samples, the model learning efficiency and training accuracy are low.
[0098] In view of this problem, the present invention proposes an experimental method of classification training method which can effectively solve the above problem: in the process, an improved YOLOv5s network is selected, and the labeled data set is first classified according to the category, and then one type of defects is trained first to obtain weight one. In the second step, weight one is used as the initial weight, and the yaml file and train file of the data set are adjusted to correspond to the data set and the second type of defects, and the weight file that has learned two types of defects at the same time is trained again. And so on, the operation is performed more than four times to obtain the final weight file. The comparison with the traditional training method is shown in Table 2.
[0099] Table 2: Comparison between initial training method and classification cycle training method
[0100]
[0101] From the analysis of Table 2, it can be concluded that, using the classification cycle training method proposed in this study, the training accuracy of the two defect categories of insulator breakage and insulator flashover, which have a small number of samples and a more complex background, is improved by 7.11% and 9.19% respectively compared with the initial training method, and the single-sheet detection speed of the model is also improved by 77.3% compared with the initial training method, while the training time consumption is greatly reduced.
[0102] (2) Circuit training
[0103] In order to further optimize the image recognition accuracy, this study once again combined the cyclic training method and used the weight file that had learned all categories of defects as the initial weight file to perform repeated cyclic training on the entire data set. During the training process, the result weight of the previous training was read, and the position of the insulator and its defects was estimated in advance according to the weight. The prediction box drawing was accelerated to speed up the training. At the same time, the image loss value of the previous time was read to achieve the optimization accuracy. The process is shown in Table 3.
[0104] Table 3: Effect of cyclic training method on model accuracy
[0105]
[0106] From the analysis of Table 3, it can be concluded that after repeated cyclic training of the model, the single-sheet detection speed of the model has been significantly improved, and the detection accuracy of various defects has also been improved to a certain extent. In addition, since each training will read the various indicator information of the previous training, the time consumed by training has also been reduced.
[0107] Evaluation indicators
[0108] In order to more objectively evaluate the advantages of the algorithm of the present invention, the accuracy, floating point computing capacity, recall, mAP@50, and frames per second (FPS) are selected as evaluation indicators, and the calculation formula involved is as follows:
[0109]
[0110] Among them, formula (15) and formula (16) indicate that the samples with annotation boxes near the prediction box and IOU values greater than the set IOU threshold are considered to be correctly predicted samples. TP represents the number of samples that should be classified as positive and are correctly classified as positive, and FP represents the number of samples that should be classified as negative but are incorrectly classified as positive. FN represents the number of samples that should be classified as positive but are incorrectly classified as negative. In formula (17), N represents the number of categories, the average precision (AP) is the area enclosed by the precision-recall (PR) curve, and i represents the category. mAP represents the average accuracy of the model when detecting N categories, where mAP@0.5 represents the mAP value when the IOU threshold is 0.5, and mAP@0.5:0.95 represents the mAP value when the IOU threshold increases from 0.5 to 0.95. mAP fully reflects the accuracy and recall of the detection.
[0111] Determination of channel pruning ratio
[0112] During the training process, a larger pruning rate can obtain a model with higher frame rate and less computational effort. However, this setting may reduce the detection accuracy of the model. In order to better prune the model, this section discusses the impact of the pruning rate on the model performance through experiments. Different pruning rates are set, and the changes of various model indicators with the pruning rate are as follows: Fig.12 shown.
[0113] As the pruning rate gradually increases, the mAP value of the network initially remains stable, but when the pruning rate increases to a certain threshold, the mAP value drops sharply. On the other hand, the computational amount FLOPs continues to decrease with the increase of the pruning rate, and the network's frames per second FPS increases accordingly. Compared with the unpruned state, the computational amount of the network is reduced by 38%, 55% and 59% when the pruning rates are 0.4, 0.5 and 0.7, respectively. However, when the pruning rate is 0.7, mAP@50 drops to 38.4%, which is a 60% decrease compared to the network before pruning. This phenomenon is because the pruned network is too shallow, resulting in low detection accuracy. In order to achieve the purpose of reducing the model, improving the real-time performance of model detection, and ensuring sufficiently high accuracy, the detection accuracy of the pruned network should be controlled within the fine-tunable range, so this study sets the pruning rate to 0.45. Comparison of model parameter quantities before and after pruning Figure 13-Figure 14 .
[0114] Ablation experiment
[0115] In order to verify the effectiveness of the modules and strategies designed by the present invention, ablation experiment schemes were designed, as shown in Table 4. Scheme 1 is YOLOv5s; Scheme 2 is to add an SGA attention mechanism module to the backbone network on the basis of Scheme 1; Scheme 3 is to replace Concat with a SE-f module in the feature fusion network on the basis of Scheme 1; Scheme 4 is to replace Concat with a SE-f module in the feature fusion network on the basis of Scheme 2; Scheme 5 is based on Scheme 4, combined with the channel pruning algorithm, and the pruned model is used to detect defective data, and the experimental results are calculated; Scheme 6 is based on Scheme 5, and the model of Scheme 4 is used to guide the model of Scheme 5 to perform knowledge distillation learning. The results of the five ablation experiments are shown in Table 5. In addition, in order to further verify the performance of the SGA and SE-f modules, the present invention compares the loss curves and recall curves obtained in Scheme 1, Scheme 2, and Scheme 4. Fig.15 .
[0116] Table 4. Ablation experimental plan
[0117]
[0118] Table 5. Ablation experiment results
[0119]
[0120] From the data in Scheme 2 of Table 5, it can be seen that after adding the SGA attention mechanism module to the backbone network, the network mAP value increased by 1.7%, and the AP values of various defects were improved, indicating that the network's feature extraction ability was enhanced by introducing the SGA attention mechanism. From Scheme 3, it can be concluded that after introducing the SE-f module in the feature fusion network, the network mAP value increased by 1.4%, and the AP values of various defects were also improved compared with the original network. It is worth noting that the two types of defects, insulator breakage and insulator flashover, were improved by 6.7% and 12.5% respectively compared with the original network, which shows that the SE-f module can effectively improve the network's detection ability for smaller defect targets and defect targets under complex backgrounds. On the other hand, from Scheme 5, it can be seen that after the experiment performed channel pruning on the improved network, the network's detection accuracy for various defects decreased significantly, but the single-image detection speed increased by 43% compared with before pruning, indicating that channel pruning can greatly improve the detection speed of the model. Finally, the results of Scheme 6 show that after guiding the pruned model to learn knowledge through distillation, the mAP value has been greatly improved while keeping the network detection speed unchanged.
[0121] Depend on Fig.15 By comparing the three loss curves in , it can be concluded that after the SGA and SE-f modules are introduced into the model, the loss convergence rate during training is significantly accelerated, and the loss value is lower than that of the initial model, which shows that the SGA and SE-f modules designed in the present invention can effectively reduce the impact of complex background on the model detection performance. On the other hand, the improved model has a higher recall rate than the initial model, indicating that the module designed in the present invention can effectively reduce the false detection rate of the model.
[0122] Comparative experiment
[0123] For further comparative experiments, the algorithm of the present invention is compared with other target detection algorithms, including the one-stage target detection algorithms YOLOv4, YOLOv5s, YOLOv5n, and the lightweight versions of the YOLO series YOLOv3-tiny, YOLOv4-tiny, and the YOLOv5s models MobileNetv3-YOLOv5, YOLOv5+slim-neck, and YOLOv5+slim-backbone-neck with lightweight structure improvements. The above algorithms are trained and tested on the public Chinese power line insulator dataset CPLID, and the three indicators of mean average precision mAP, frames per second FPS, and floating point calculation FLOPs are selected to evaluate the algorithms. Table 6 shows the experimental results of different algorithms on the CPLID dataset.
[0124] Table 6: Comparison of the improved algorithm with other target detection algorithms
[0125]
[0126] As can be seen from Table 6, the average accuracy of the improved YOLOv5 algorithm reached 93.4%, which is 7.6% higher than the accuracy of the initial YOLOv5s model. The computational FLOPs was reduced to 4.7B, which was 70% less than the initial YOLOv5s model. The FPS reached 140.3, which was 12.3% higher than the initial YOLOv5s model.
[0127] Among them, the model with the smallest amount of calculation and the fastest detection speed is YOLOv3-tiny, which compresses the original YOLOv3 network to a great extent and does not use the residual layer, so this model is suitable for detection scenarios that do not require strict detection accuracy. The model with the highest mean average precision mAP is YOLOv5n, which has more network layers and parameters than YOLOv5s, requires more computing resources, and is suitable for small target detection tasks with relatively dense detection. Compared with the algorithms in the comparison table, the algorithm of the present invention achieves a higher mean average precision and a lighter model while having a higher detection speed.
[0128] At the same time, it can be seen that the MobileNetv3-YOLOv5s model has achieved significant improvements in the number of frames per second and the amount of computation compared to the initial YOLOv5s, but it has sacrificed detection accuracy to a certain extent. Therefore, although this structure is very efficient for performing certain detection tasks, it may not be the best choice for tasks that require high-precision detection. For the YOLOv5+slim-neck structure, it combines the deep separable convolution DWConv with the standard convolution SC to achieve lightweight convolution layers while minimizing the loss of accuracy. It has also improved the number of frames per second FPS and the amount of computation FLOPs. However, for detection tasks where there is blur and noise in the data, resulting in inconspicuous targets and complex backgrounds, its detection accuracy is still lacking to a certain extent.
[0129] Comparison of detection results
[0130] In order to prove the superiority of the improved algorithm in this study, we use the improved model in this study to compare the detection effect with the initial YOLOv5s model. First, the data set is classified by defect category, and then a picture is randomly selected from each category as the picture to be detected. Finally, the selected three pictures are used as the input of the two network detects. The detection results are as follows: Figure 16-Figure 17 ,in Fig.16 is the initial YOLOv5s detection result, Fig.17 This is the detection result of the improved network.
[0131] By comparing the first set of results, it can be seen that the improved network has significantly improved the detection effect of smaller insulator targets in the pictures; the detection accuracy of insulator damage defects in the second set of pictures has been significantly improved; in the third set of detection of insulator flashover defects, not only the detection accuracy of insulator flashover defects has been significantly improved, but also the problem of false detection caused by insignificant defects has been overcome.
[0132] The above description is only used to illustrate the technical solution of the present invention rather than to limit it. Other modifications or equivalent substitutions made to the technical solution of the present invention by ordinary technicians in this field should be included in the scope of the claims of the present invention as long as they do not depart from the spirit and scope of the technical solution of the present invention.
Claims
1. A lightweight transmission line insulator defect detection algorithm based on SGA and SE-F, characterized by: It specifically includes the following steps: S1, firstly, a new attention mechanism SGA is introduced based on the YOLOv5 network to enhance the prominence of the defect target to be detected, so as to solve the problem that the characteristics of tiny insulator defects are difficult to extract; S2, secondly, a same-scale weighted fusion module SE-f is proposed to replace the Concat module in the feature fusion network, which improves the network's ability to fuse the features of low-level position information and high-level semantic information; S3 again optimizes the model structure of the improved YOLOv5 through sparse training and channel pruning. At the same time, knowledge distillation is used to guide the model to learn knowledge and improve detection accuracy. S4,Finally, the classification cycle training method is used to solve the problem of low model learning efficiency caused by unbalanced sample number and differences in background complexity.
2. The lightweight transmission line insulator defect detection algorithm based on SGA and SE-F according to claim 1 is characterized in that: The details of the attention mechanism SGA in S1 are: x'=f 1×1 (GN(x)×Softmax(SDA(Q,K,V))) (1) Where W1, W2, and W3 are the weight matrices obtained by x passing through three fully connected layers respectively; In the feature normalization stage, the attention mechanism SGA uses GroupNorm instead of BatchNorm used in the original NAM. This is because in actual model training, BatchNorm needs to use a sufficiently large Batch Size. If the Batch Size is too small, the false detection rate of the model will be greatly increased. However, in actual tasks, the input image data is very large, and a larger Batch Size will cause video memory overflow. The normalization method of GroupNorm avoids the influence of Batch size on the model. First, the channels are grouped, and then the mean and variance of each group in the channel direction are calculated. The calculation process is as follows: Among them, μ ng (x) represents the mean of the current group with n dimensions retained; σ ng (x) represents the variance of the current group; ε is a value as small as possible; γ and β are scaling factors and translation factors respectively; In the attention weight calculation stage, the scaled dot product attention mechanism in the single-head self-attention model is used to redesign a branch to calculate the attention weight. First, three fully connected layers are used to extract the Query, Key, and Value vectors from the input x. Then, the scaled dot product is performed on the Query and Key vectors, and the similarity between each Query vector and the Key vector is calculated to obtain the score matrix scores. Then, the score matrix is normalized by Softmax to obtain the weight matrix of the Value vector. Finally, the weight matrix is multiplied by the Value vector to obtain the attention weight.
3. The lightweight transmission line insulator defect detection algorithm based on SGA and SE-F according to claim 1 is characterized in that: The same-scale weighted fusion module SE-f in S2 is specifically: The original network uses the FPN+PAN structure in the feature fusion part. This structure is conducive to the mutual transmission between high-level semantic information and low-level position information, thereby enhancing the positioning ability and semantic expression at multiple scales. However, when there are factors such as target occlusion, shadow, noise, etc. in a complex background, which leads to unclear position information and semantic information of the detected target, it is impossible to effectively fuse the features. A weighted fusion module SE-f between the same scales is proposed. When performing feature layer fusion, the module first compresses the spatial dimension of each channel of the input tensor into a value through global average pooling, and then uses a fully connected layer to learn the weight of each channel, generate weight vectors α, β and weight the input feature vector; finally, the weighted features are concat fused; the final feature fusion result Output is expressed as follows (7): Output = α × H + β × L (7) Among them, Output represents the output feature map, α and β represent the attention weights obtained by the input feature map through the SE attention mechanism.
4. The lightweight transmission line insulator defect detection algorithm based on SGA and SE-F according to claim 1 is characterized in that: The model optimization of improving YOLOv5 in S3 includes structure optimization and accuracy optimization.
5. The lightweight transmission line insulator defect detection algorithm based on SGA and SE-F according to claim 1 is characterized in that: The structural optimization is specifically as follows: after the initial YOLOv5s network is improved, its computational complexity is slightly increased compared to the initial YOLOv5s network, and the model volume is large after training. Excessive computational complexity will cause the algorithm reasoning to take a long time, thereby affecting the real-time performance of the detection, and the large-volume model is not conducive to the deployment of the algorithm on mobile terminals. In order to compress the model volume, it is necessary to screen unimportant channels and take model pruning operations. In order to maintain network integrity and reduce hardware costs, the model is compressed by channel pruning, which finds and deletes minor channels through sparse training, thereby reducing the computational complexity; First, the sparsity of the scaling factor γ in the BN layer is adjusted by adjusting the sparsification coefficient sr. The specific operation of the BN layer is as shown in formula (8), and the output y i Calculated by formula (9), the details are as follows: where x1,x2,...,x k is the output of the previous layer, k is the batch size, μ B and σ B is the mean and variance of each batch of data, ε is the regularization parameter used to prevent the denominator from being zero during calculation, and the scaling factor γ and the translation factor β are both learnable parameters; After sparsely expressing the set C of scaling factors γ corresponding to each channel in each convolutional layer, the feature channels with γ values close to 0 are secondary channels. The regularization formula of C is introduced into the network loss function as shown in formula (10), which is as follows: Where (x, y) is the input and output of the training, W is the model weight, L(f(x, W), y) is the initial model loss, λ is the balance factor, and g(γ) is the coefficient loss; The scaling factor γ after sparse training is connected to its corresponding feature channel and sorted by absolute value. The pruning threshold S is determined by customizing the pruning ratio. If the γ value corresponding to the channel is less than S, it is judged as a secondary channel and pruned. The S value should be less than the maximum value of γ in the BN layer.
6. The lightweight transmission line insulator defect detection algorithm based on SGA and SE-F according to claim 1 is characterized in that: The precision optimization is specifically as follows: knowledge distillation uses the idea of transfer learning to guide the training of small models with the knowledge learned by the high-precision large model, thereby accelerating the convergence of the smaller model. Considering that the improved YOLOv5 model has a problem of decreased precision after channel pruning, the pruned model is fine-tuned by knowledge distillation to maintain a high detection accuracy. The teacher model uses the improved YOLOv5s before channel pruning; the YOLOv5s after channel pruning is used as the student model, Sl is the soft label output by the teacher model, Sp is the soft prediction output by the student model, Hp is the hard prediction output by the student model, and Hl is the hard label; By setting the distillation temperature T = t, the loss function L between the student network and the teacher network is constructed. dist , set T = 1 to construct the loss function L between the student network and the true value label stu , and finally the weighted sum of the two is taken as the final loss of the network; First, the objective loss function is as shown in formula (11), where is the target prediction value of the teacher network, is the target prediction value of the student network, λ D is the balance coefficient: The category loss function is as shown in formula (12), which introduces the updated teacher network target prediction value into the category and bounding box loss functions If the prediction box contains only background information, then The value of will be very low, making the distillation loss close to 0, which can effectively prevent the student network from incorrectly learning background information: in, Predict values for the student model categories; Predict values for the teacher model categories; Similarly, the bounding box loss function is expressed as formula (13): in, Predicted values for the student model bounding box; Predicted value for the teacher model bounding box; The final loss of the model is as follows: Loss=L stu +λ D L dist (14).
Citation Information
Cited By
Target detection model lightweight method for satellite-borne edge calculation
CN119849580A
Sparse point cloud and GCN fused citrus defect detection method and system
CN119850635A
Edge degradation defect detection method
CN122089732A
