Lightweight model improvement-based transformer substation defect identification method and system
By improving the YOLOv5 neural network model, combining ShuffleNetv2 and CBAM modules, class weight and data enhancement technology were introduced, and softening non-maximum suppression was used, which solved the problem of manual inspection dependence and low detection accuracy in traditional substation operation and maintenance, and achieved the The efficient and accurate identification of substation equipment defects has improved the safety and intelligent maintenance capabilities of the power system.
Patent Information
- Application Number
- CN202411371883.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2025-01-10
AI Technical Summary
The traditional substation operation and maintenance model relies heavily on manual inspection, which leads to visual fatigue, misjudgment and missed inspection risks, making it difficult to ensure the safe and stable operation of the power grid.
Adopt the substation defect identification method based on lightweight model, and by building the substation defect data set, the YOLOv5 neural network model is improved, combined with ShuffleNetv2 and CBAM modules, category weight and data enhancement technology are introduced, and softening non-maximum suppression technology is used to improve Detection accuracy and speed.
It significantly improves the detection efficiency and accuracy of substation equipment defects, reduces model complexity and resource consumption, and achieves dual improvements in target detection accuracy and recognition speed, ensuring the safe operation and intelligent maintenance of the power system.
Smart Images

Figure CN119295902A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of transformer substation defect identification, and in particular to a transformer substation defect identification method and system based on lightweight model improvement. Background Art
[0002] In recent years, with the vigorous development of China's economy and the rapid leap forward of science and technology, the power industry has entered a period of expansion. The scale of the power grid has continued to expand, and its safe and stable operation has become the cornerstone supporting the development of various industries in modern society. Substations, as the core hub of the power grid architecture, are responsible for the conversion and efficient distribution of electric energy. The health of their equipment is directly related to the safety and reliability of the entire power grid. Therefore, ensuring the continuous and good operation of substation equipment is of immeasurable value for maintaining the stability of the power grid and promoting economic and social development.
[0003] However, the traditional substation operation and maintenance model is highly dependent on manual inspections. In particular, when faced with complex and ever-changing equipment status and massive amounts of monitoring data, inspectors need to stare at the monitoring screen for a long time, which not only easily causes visual fatigue, but also inevitably increases the risk of misjudgment and missed inspections, burying hidden dangers for the safe and stable operation of the power grid. In this context, the intelligent transformation of substation operation and maintenance management is particularly urgent.
[0004] To meet this challenge, the industry and scientific research institutions are actively exploring new paths for intelligent operation and maintenance of substations, aiming to achieve intelligent monitoring, early warning and fault diagnosis of substation equipment through deep integration of artificial intelligence technology, thereby reducing the workload of inspection personnel, improving inspection efficiency and accuracy, and effectively reducing the incidence of substation accidents, providing strong technical support and guarantee for the safe and stable operation of the power system. This change not only represents the inevitable trend of technological progress in the power industry, but is also a key measure to promote the construction of energy Internet and achieve high-quality development of power. Summary of the invention
[0005] The purpose of the present invention is to provide a substation defect identification method and system based on a lightweight model improvement in order to solve at least one of the above technical problems.
[0006] The present invention achieves the above-mentioned purpose through the following technical solutions:
[0007] A substation defect identification method based on lightweight model improvement includes the following steps:
[0008] Construct substation defect dataset;
[0009] The YOLOv5 neural network model is improved based on the lightweight model to build a substation defect recognition model;
[0010] Setting training super parameters and network parameters, inputting the training set in the substation defect data set into the network, training the substation defect recognition model, and saving the trained weight file;
[0011] Output predicted bounding box information and category probability;
[0012] Use softened non-maximum filtering to filter the detection frame, visualize the detection image, and generate the final target detection frame and recognition result.
[0013] Furthermore, the substation defect data set includes: scene data of the substation field environment under different lighting and weather conditions.
[0014] Furthermore, the method also includes: designing the substation defect data set into a VOC data set format, the VOC data set includes a JPEGImages folder, an Annotations folder and an Imagesets folder, wherein the JPEGImages folder is used to store training set and test set images, the Annotations folder is used to store XML type annotation files, and the Imagesets folder is used to store txt text, each line of the txt text corresponds to the name of a picture, the substation defect recognition model reads the file name according to the txt text, and then searches the JPEGImages folder and the annotations folder for the corresponding pictures and annotation information, finds the annotation information of the substation defects in the found picture annotations, and obtains the border parameters of the annotation information.
[0015] Furthermore, the images in the VOC dataset are randomly divided into different batches. Before being sent to the substation defect recognition model, the images are randomly rotated, cropped, translated, flipped, and subjected to noise disturbance data enhancement to expand the diversity of image scenes.
[0016] Furthermore, the YOLOv5 neural network model is improved based on the lightweight model, including: using ShuffleNetv2 to improve the YOLOv5 neural network model, specifically,
[0017] Use the basic module ShuffleBlock in ShuffleNetv2 to replace the Darknet53 backbone network of the YOLOv5 neural network model;
[0018] The SPP layer is removed and the original PANet neck network of the YOLOv5 neural network model is retained.
[0019] Furthermore, the YOLOv5 neural network model is improved based on the lightweight model, and also includes: introducing the CBAM module into the feature fusion structure of the network model.
[0020] Furthermore, the method further includes: introducing category weights based on the original loss function, specifically,
[0021] Get the number of samples of each category in the training data set; use the following formula to calculate the weight value Class_weight of each category,
[0022] Class_weight = N total / N i
[0023] Among them, N total is the total number of all samples, N i is the number of samples of category i;
[0024] Define the improved loss function and pass the calculated category weight as the pos_weight parameter.
[0025] Furthermore, the method also includes: during the training process, using the regression loss function of the predicted bounding box to calculate the loss, calculating the category score, confidence score, center coordinates and width and height of each predicted corrected box relative to the actual calibration box category, center coordinates and width and height through the loss function, and obtaining the gradient through back propagation to update the weights to obtain the updated weight parameters. Each batch sent to the substation defect recognition model updates the model weights until the loss value converges, and the model parameters are saved every ten thousand iterations, and verified under the verification set at the same time, and the learning rate is adjusted according to the loss curve and the detection effect on the verification set.
[0026] Furthermore, the method also includes: using softened non-maxima to reduce their confidence, specifying a confidence threshold, and finally retaining the detection boxes with scores greater than the threshold, and looping this step in the remaining predicted bounding boxes to finally obtain a predicted bounding box corresponding to each road target.
[0027] A substation defect identification system based on lightweight model improvement, comprising:
[0028] A data set construction module, used to construct a substation defect data set;
[0029] Model building module, which is used to improve the YOLOv5 neural network model based on a lightweight model and build a substation defect recognition model;
[0030] A training module, used to set training super parameters and network parameters, input the training set in the substation defect data set into the network, train the substation defect recognition model, and save the trained weight file;
[0031] The recognition module is used to output the predicted bounding box information and category probability;
[0032] The recognition module is also used to use a softened non-maximum filter detection frame to visualize the detection image and generate a final target detection frame and recognition result.
[0033] The beneficial effects of the present invention are:
[0034] The present invention significantly improves the detection efficiency and accuracy of substation equipment defects. First, the ShuffleBlock module in ShuffleNetv2 is used to replace the original Darknet53 backbone network of the YOLOv5 neural network model, which greatly reduces the model parameters and computational complexity. At the same time, the CBAM module is combined to enhance the feature extraction capability, so that the model maintains high detection accuracy while being lightweight. Secondly, by introducing category weights into the loss function, the problem of imbalanced training data is effectively solved, and the robustness and generalization ability of the model are further improved. In addition, the data enhancement technology and learning rate adjustment strategy used in the training process ensure that the model can still maintain stable detection performance in a complex and changeable substation environment. Finally, combined with the softened non-maximum suppression technology, the accurate positioning and high-confidence output of the detection results are achieved. These optimization measures work together to not only improve the speed and accuracy of substation defect identification, but also reduce the resource consumption of model deployment and operation, providing strong technical support for the safe operation and intelligent maintenance of the power system.
[0035] The present invention achieves a dual improvement in target detection accuracy and recognition speed, which can not only ensure the safe operation of the power system, but also effectively improve the detection and recognition capabilities of various equipment defects, solving the problems of slow detection speed, large model parameters and low detection accuracy in the process of substation equipment defect detection in the current detection algorithm. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 A flow chart of a method for identifying substation defects based on an improved lightweight model according to an embodiment of the present invention;
[0037] Figure 2 This is the structure diagram of the YOLOv5 neural network model;
[0038] Figure 3 It is the basic structure of ShuffleNetV2;
[0039] Figure 4It is the CBAM module diagram;
[0040] Figure 5 The defect identification and monitoring effect of a substation based on a lightweight model improvement according to an embodiment of the present invention is shown in FIG. Figure 1 ;
[0041] Figure 6 The defect identification and monitoring effect of a substation based on a lightweight model improvement according to an embodiment of the present invention is shown in FIG. Figure 2 ;
[0042] Figure 7 The defect identification and monitoring effect of a substation based on a lightweight model improvement according to an embodiment of the present invention is shown in FIG. Figure 3 ;
[0043] Figure 8 This is a structural diagram of a substation defect identification system based on lightweight model improvement according to an implementation mode of the present invention. DETAILED DESCRIPTION
[0044] The content of the present invention will now be discussed with reference to exemplary embodiments. It should be understood that the embodiments discussed are only to enable those skilled in the art to better understand and thus implement the content of the present invention, rather than implying any limitation on the scope of the present invention.
[0045] As used herein, the term “including” and variations thereof are to be interpreted as open-ended terms meaning “including, but not limited to.” The term “based on” is to be interpreted as “based, at least in part, on.” The terms “one embodiment” and “an embodiment” are to be interpreted as “at least one embodiment.”
[0046] The core goal of the present invention is to solve the problem of insufficient precision and accuracy in the current substation equipment defect detection, and propose a real-time detection method and system for substation equipment defects based on an improved YOLOv5 neural network model. The method is first committed to building a comprehensive and detailed substation equipment defect data set, which widely covers the diversity of the substation site environment, including but not limited to actual scenes under various lighting conditions and weather conditions, ensuring the comprehensiveness and representativeness of the data. Through a detailed analysis of the pictures in the data set, 11 main defect types are summarized, and then each type of defect and target is accurately marked manually, laying a solid foundation for subsequent model training. Next, the YOLOv5 neural network model is improved based on a lightweight model, aiming to further improve its performance in the substation equipment defect detection task. Subsequently, the improved YOLOv5 model is deeply trained using the constructed data set to ensure that the model can fully learn and identify various defect features. After the training is completed, the model parameters obtained by the training are efficiently imported into the improved YOLOv5 model to achieve the final solidification of the model. Finally, the model can receive real-time image input from the substation site and quickly and accurately detect equipment defect targets in the images, providing strong technical support and guarantee for the safe operation and maintenance of the substation. The entire process, from the construction of the data set to the training and application of the model, reflects a high degree of logic and systematicity, ensuring the reliability and effectiveness of the detection results.
[0047] Embodiment 1
[0048] Figure 1 FIG. 1 is a flow chart of a method for identifying substation defects based on an improved lightweight model according to an embodiment of the present invention; Figure 1 As shown, according to an embodiment of the present invention, a method for identifying substation defects based on lightweight model improvement includes the following steps:
[0049] Step S102, constructing a substation defect data set;
[0050] Step S104, improving the YOLOv5 neural network model based on the lightweight model to build a substation defect recognition model;
[0051] Step S106, setting training super parameters and network parameters, inputting the training set in the substation defect data set into the network, training the substation defect recognition model, and saving the trained weight file;
[0052] Step S108, outputting predicted bounding box information and category probability;
[0053] Step S110, using the softened non-maximum filtering detection frame to visualize the detection image, and generate the final target detection frame and recognition result.
[0054] In this embodiment, the substation defect recognition method based on the improvement of the lightweight model makes full use of the advantages of the lightweight model and effectively improves the existing YOLOv5 neural network model. First, in step S102, a data set containing various types of substation defects is constructed, which is the basis for training a high-quality recognition model. Subsequently, in step S104, a model designed specifically for substation defect recognition is constructed by lightweight adjustment of the YOLOv5 neural network model architecture. This improvement not only retains the high efficiency of the YOLOv5 neural network model, but also significantly reduces the complexity of the model and improves the computational efficiency. In step S106, detailed training super parameters and network parameters are set, and the training set data in the substation defect data set is input into the improved model for full training, and the trained model weight file is saved for subsequent use. The data in the substation defect data set is divided into a test set and a training set according to a ratio of 0.1:0.9. In step S108, the model can output the predicted defect bounding box information and the corresponding category probability, providing key information for subsequent defect recognition. Finally, in step S110, the softened non-maximum filtering technology is used to optimize the detection frame, further improving the detection accuracy, and the detection results are displayed in a visual form, generating accurate target detection frames and recognition results, which greatly facilitates substation operation and maintenance personnel to quickly and accurately identify and handle defects.
[0055] The present invention optimizes the YOLOv5 neural network model structure, thereby significantly reducing the model complexity and computing requirements while ensuring detection accuracy, thereby improving detection efficiency; the substation defect identification model constructed by this method can quickly and accurately identify various defects in the substation, and present the detection results in a visual manner, providing strong support for the safe operation and efficient maintenance of the substation.
[0056] According to an implementation manner of the present invention, in step S102, the substation defect data set includes: scene data of the substation field environment under different lighting and weather conditions.
[0057] Preferably, the substation defect data set is designed as a VOC data set format, and the VOC data set includes a JPEGImages folder, an Annotations folder, and an Imagesets folder, wherein the JPEGImages folder is used to store training set and test set images, the Annotations folder is used to store XML type annotation files, and the Imagesets folder is used to store txt text, each line of the txt text corresponds to the name of a picture. The substation defect recognition model reads the file name according to the txt text, and then searches the JPEGImages folder and the annotations folder for the corresponding pictures and annotation information, finds the annotation information of the substation defects in the found picture annotations, and obtains the border parameters of the annotation information.
[0058] Preferably, the images in the VOC dataset are randomly divided into different batches. Before being sent to the substation defect recognition model, the images are randomly rotated, cropped, translated, flipped, and subjected to noise disturbance data enhancement to expand the diversity of image scenes.
[0059] In this embodiment, the substation defect dataset not only covers the substation field environment scenes under different lighting conditions and weather conditions, but also ensures the breadth and representativeness of the data. In order to improve the usability and compatibility of the dataset, the standard VOC dataset format is used for organization. Specifically, the JPEGImages folder is used to store high-quality images used as training and testing benchmarks, and the Annotations folder contains detailed annotation files written in XML format corresponding to each image. These annotation files record the specific location and category information of the substation defects in detail. The txt text file in the Imagesets folder serves as an index, listing the names of all images, so that the model can easily find the corresponding images and their annotation information based on these indexes. In addition, in order to further improve the generalization ability of the model, the images in the VOC dataset were randomly transformed in the data preprocessing stage, including rotation, cropping, translation, flipping, and adding noise and other enhancement methods, which effectively expanded the scene diversity of the images.
[0060] The present invention constructs a substation defect dataset containing a variety of lighting and weather conditions and organizes it in the VOC standard format, which not only provides rich and high-quality data support for model training, but also ensures the usability and compatibility of the data; by implementing a series of data enhancement strategies, the generalization ability of the model and its adaptability to complex scenarios are significantly improved; under the combined effect of these measures, the substation defect recognition model trained based on the dataset can more accurately and stably identify various defects in the substation, providing a strong guarantee for the safe and stable operation of the power system.
[0061] Figure 2 This is the structure diagram of the YOLOv5 neural network model; Figure 3 It is the basic structure of ShuffleNetV2; Figure 4 is a CBAM module diagram. According to an embodiment of the present invention, Figure 2-4 As shown, step S104 includes: using ShuffleNetv2 to improve the YOLOv5 neural network model, specifically,
[0062] Use the basic module ShuffleBlock in ShuffleNetv2 to replace the Darknet53 backbone network of the YOLOv5 neural network model;
[0063] The SPP layer is removed and the original PANet neck network of the YOLOv5 neural network model is retained.
[0064] Preferably, step S104 further includes: introducing the CBAM module into the feature fusion structure of the YOLOv5 neural network model.
[0065] In this implementation, the ShuffleNetv2 network structure is used to optimize the YOLOv5 target detection model, especially the backbone network part is deeply modified. By introducing the ShuffleBlock (SFB) module in ShuffleNetv2, the original Darknet53 backbone network of the YOLOv5 neural network model is replaced, aiming to significantly reduce the computational complexity and memory access cost, while improving the detection accuracy of the model. In order to maintain the simplicity and feature extraction capability of the network, the SPP layer is also removed, and the efficient PANet neck network is retained for fusing multi-scale features and predicting the head. Specifically,
[0066] First, the input and output layers of the YOLOv5 neural network model are kept unchanged to ensure the compatibility of the model's input and output interfaces. Then, the original CSPDarknet53 module is removed, and the ShuffleBlock module in ShuffleNetv2 is added layer by layer to build a new backbone network architecture. The ShuffleBlock module effectively reduces the computational complexity and memory access cost by combining channel grouping (Channel Shuffle) and depthwise grouped convolution (Depthwise Separable Convolution) technology. Then, the parameters of the newly added ShuffleBlock module are initialized, and the He initialization method is used to ensure the stability of training and the rapid convergence of the model. Finally, the ShuffleBlock module is connected to the PANet neck network of the YOLOv5 neural network model to ensure that the feature map can be efficiently transmitted to the detection head, thereby further improving the accuracy and efficiency of target detection.
[0067] The CBAM (Convolutional Block Attention Module) module is introduced into the feature fusion structure of the YOLOv5 neural network model. By combining the channel attention and spatial attention mechanisms, the CBAM module can adaptively adjust the importance of different channels and spatial positions in the feature map, thereby enhancing the model's ability to capture key information. In the feature fusion stage, the CBAM module is embedded in the PANet neck network. By performing refined attention weighting processing on multi-scale feature maps, the model can focus more on areas and features that have an important impact on the detection task when fusing features. This improvement not only improves the detection accuracy of the model, but also enhances the model's adaptability and robustness to complex scenes.
[0068] The present invention replaces the Darknet53 backbone network of YOLOv5 with the ShuffleBlock module in ShuffleNetv2 and introduces the CBAM module to optimize the feature fusion structure, which significantly reduces the computational complexity and memory access cost, while improving the detection accuracy and efficiency of the model, enhancing the adaptability and robustness of the model to complex scenarios, and providing a more efficient and accurate solution for real-time identification of substation defects.
[0069] According to an embodiment of the present invention, the method further includes: introducing category weights based on the original loss function, specifically,
[0070] Get the number of samples of each category in the training data set; use the following formula to calculate the weight value Class_weight of each category,
[0071] Class_weight = N total / N i
[0072] Among them, N total is the total number of all samples, N i is the number of samples of category i;
[0073] Define the improved loss function and pass the calculated category weight as the pos_weight parameter.
[0074] Preferably, during the training process, the loss is calculated using the regression loss function of the predicted bounding box. The category score, confidence score, center coordinates and width and height of each predicted corrected box are calculated using the loss function relative to the true category, center coordinates and width and height of the calibrated box. The weights are updated by obtaining the gradient through back propagation to obtain the updated weight parameters. The model weights are updated for each batch sent to the substation defect recognition model until the loss value converges. The model parameters are saved every ten thousand iterations and verified on the validation set at the same time. The learning rate is adjusted according to the loss curve and the detection effect on the validation set.
[0075] Preferably, a softened non-maximum value is used to reduce its confidence, a confidence threshold is specified, and finally the detection boxes with scores greater than the threshold are retained. This step is repeated in the remaining predicted bounding boxes, and finally a predicted bounding box corresponding to each road target is obtained.
[0076] In this implementation, class weights are introduced during the training process to deal with the problem of data imbalance. The inverse ratio of the number of samples in each class is calculated as the weight and integrated into the loss function to ensure that the minority class receives more attention during the training process. At the same time, a regression loss function is used to evaluate the difference between the predicted bounding box and the true calibration box, and the model weights are continuously optimized through back propagation to improve the model's ability to identify substation defects. In addition, the detection results are further optimized by softening non-maximum suppression (NMS) and confidence threshold processing to ensure that each target corresponds to only one high-confidence predicted bounding box.
[0077] The invention introduces category weights and optimized loss functions to effectively alleviate the challenges brought by data imbalance and improve the stability and efficiency of model training; combines the regression loss function and weight update strategy to significantly improve the accuracy and robustness of substation defect identification; finally, through softening non-maximum suppression and confidence threshold processing, the accuracy and uniqueness of the detection results are ensured, providing reliable technical support for the automated identification and monitoring of substation defects.
[0078] Embodiment 2
[0079] like Figure 1 As shown, according to an embodiment of the present invention, a method for identifying substation defects based on an improved lightweight model includes the following steps:
[0080] Step 1: Build a substation defect dataset;
[0081] The substation defect dataset mainly comes from the substation. The dataset covers most of the scenes in the substation field environment, and also covers different lighting, different weather conditions and other situations. By statistically summarizing the types of defects in the pictures, 11 types of defects are obtained, and then the targets in the dataset are manually labeled according to the targets and defect categories. The labeling tool is LabelImg, and finally converted into the VOC format required for training. The dataset contains a total of 3178 labeled equipment defect images, and the dataset is divided into test sets and training sets according to the ratio of 0.1 and 0.9. There are 11 categories of GT box labels in the dataset, namely: open pressure plate, closed pressure plate, hanging suspended objects, bird's nest, broken insulator, damaged dial shell, blurred dial, abnormal door closure, discoloration of respirator silicone, damaged cover, and no work clothes. The dataset is organized into the VOC dataset format. The VOC dataset includes three folders, namely the JPEGImages folder, the Annotations folder, and the Imagesets folder. Among these three folders, the JPEGImages folder stores the training set and test set images, the Annotations folder stores the XML type annotation files, and the Imagesets folder stores the txt text. Each line of the txt text corresponds to the name of a picture. The improved YOLOV5 network model reads the file name according to the txt text, and then searches the JPEGImages and annotations folders for the corresponding pictures and annotation information to obtain the border parameters of the annotation information. Next, the pictures are randomly divided into different batches. Before being sent to the improved YOLOv5 network model, the pictures are randomly rotated, cropped, translated, flipped, and subjected to noise disturbance and other data enhancement methods to expand the diversity of picture scenes.
[0082] Step 2: Use ShuffleNetv2 to improve the YOLOv5 neural network model;
[0083] The substation defect recognition model is an improved YOLOv5 neural network model. Compared with the original YOLOv5 network architecture, channel grouping and deep group convolution operations are introduced into the design of the target detector to minimize the memory access cost and computational complexity. Based on YOLOv5 as the basic target detection, the basic module ShuffleBlock (SFB) in ShuffleNetv2 replaces the Darknet53 backbone network of YOLOv5. At the same time, in order to make full use of the feature extraction capability of SFB and maintain the simplicity of the network, the SPP layer is removed, and the original PANet neck network of YOLOv5 is retained for fusing multi-scale features and predicting the head. Compared with the original YOLOv5 target detector, the improved YOLOv5 neural network model can significantly improve the detection speed.
[0084] After comparing and analyzing the two lightweight network structures, ShuffleNetv1 and MobileNetv2, four lightweight network design principles can be summarized: first, use 1x1 convolution to balance the size of input and output channels; second, pay attention to the selection of the number of groups when using group convolution; third, avoid network fragmentation; and finally, minimize the number of element-level operations. ShuffleNetv2 uses a 3x3 depthwise separable convolution method, which reduces the amount of calculation by about 88% compared to the traditional 3x3 standard convolution, while also reducing the loss of accuracy. Depthwise separable convolution combines depthwise convolution and 1x1 pointwise convolution. The former applies a fixed-size convolution kernel to each input channel, while the latter fuses the output features of the depthwise convolution with a 1x1 convolution, thereby improving the network's expressiveness while maintaining the size of the output feature map.
[0085] Specifically, step two includes:
[0086] First, keep the input and output layers of YOLOv5 unchanged and replace the middle Darknet53 backbone network with the ShuffleBlock module of ShuffleNetv2.
[0087] Secondly, remove the original backbone network module (CSPDarknet53) of YOLOv5. Add ShuffleBlock in ShuffleNetv2 to the new backbone network layer by layer. The specific structure of ShuffleBlock includes channel grouping (ChannelShuffle) and depthwise grouped convolution (Depthwise Separable Convolution).
[0088] Next, the parameters of the newly added ShuffleBlock module are initialized, and the He initialization method is used to ensure the stability of training and the convergence speed of the model. The ShuffleBlock module is reconnected with the PANet neck network of YOLOv5 to ensure that the feature map can be smoothly transferred to the detection head. PANet is used to fuse multi-scale features, which helps to improve the accuracy of target detection.
[0089] Replacing the backbone network of YOLOv5 with ShuffleNetv2 can significantly reduce the amount of computation, especially using 3x3 depthwise separable convolution, which reduces the amount of computation by about 88% compared to traditional 3x3 convolution while maintaining high feature extraction capabilities. Channel grouping (Channel Shuffle) further reduces the memory access cost in convolution operations, thereby improving the inference speed of the model.
[0090] The present invention uses YOLOv5 as the basic target detection, and replaces the Darknet53 backbone network of YOLOv5 with the basic module ShuffleBlock (SFB) in ShuffleNetv2; at the same time, in order to make full use of the feature extraction capability of SFB and maintain the simplicity of the network, the SPP layer is removed, and the original PANet neck network of YOLOv5 is retained for fusing multi-scale features and predicting the head. Compared with the original YOLOv5 target detector, the improved YOLOv5 model can significantly improve the detection speed.
[0091] Step 3: Use the CBAM module to improve the YOLOv5 neural network model;
[0092] The CBAM module is introduced into the feature fusion structure of the YOLOv5 network model to enhance the feature fusion capability of the model.
[0093] CBAM (Convolutional block attention module) is a lightweight attention mechanism module that is easy to embed into the network. Studies have shown that applying CBAM on small models can significantly improve performance. By introducing the CBAM module, the network can pay more attention to the essential characteristics of objects. CBAM mainly consists of two parts: channel attention and spatial attention. The channel attention mechanism generates a one-dimensional channel weight, which aims to enable the input feature map to learn to "express meaningful information". The spatial attention mechanism integrates the maximum and average features of each channel through average pooling and maximum pooling operations to generate a new two-dimensional feature map. Among them, CONV7 represents a convolutional layer with a convolution kernel size of 7×7. The specific steps are as follows:
[0094] First, we add CBAM modules to several convolutional layers in the PANet network of YOLOv5 that have the greatest impact on feature fusion. Usually, these convolutional layers are the key locations for feature map downsampling or fusion.
[0095] Each CBAM module consists of two sub-modules: Channel Attention Module (CAM) and Spatial Attention Module (SAM). These two sub-modules focus on the important information of the image input in the channel dimension and the position information of the image input in the spatial dimension. In implementation, the global features in the channel direction are first obtained through average pooling and maximum pooling operations, and then the channel attention map is generated using 1x1 convolution and sigmoid activation function. Next, the spatial information is processed using a convolution operation with a convolution kernel size of 7×7 to generate a spatial attention map. After the channel and spatial attention maps are generated, they are element-wise multiplied with the input feature map, and the resulting feature map is passed to the subsequent convolution layer.
[0096] The present invention introduces the CBAM module into the feature fusion structure of the network model to enhance the feature fusion capability of the model; through the attention mechanism of CBAM, the focus of each output feature layer is adjusted, so that each feature layer pays more attention to features such as spatter and molten pool while having a unique perspective, further enhancing the ability of each feature layer to focus on the same task in different ways; through the integration of features, the "unique" focus mode of each feature layer is fully utilized, thereby improving the network performance. The present invention introduces the CBAM module to enable the network to focus on important features more accurately during the feature fusion process, thereby improving the performance of the model.
[0097] Step 4: Introduce category weights and optimize the loss function
[0098] The training set images and validation set images are trained through the YOLOv5 neural network to obtain the final YOLOv5-based network weight model.
[0099] When processing data with an unbalanced number of categories, existing target detection models usually use a binary cross entropy loss function (nn.BCEWithLogitsLoss) to calculate the predicted probability of the target category. The traditional loss function does not take into account the difference in the number of categories, which leads to the model easily ignoring minority class targets in the case of unbalanced categories, thereby affecting the detection effect. In order to overcome this problem, the present invention introduces category weights based on the original loss function, and adjusts the loss weights of each category by setting the pos_weight parameter. This improvement effectively enhances the influence of minority class targets, avoids the excessive dominance of majority class targets on the overall loss, and improves the detection accuracy of minority class targets.
[0100] First, calculate the corresponding class weight by counting the number ratio of each class in the statistical data set. The specific steps are as follows: first obtain the number of samples of each class in the training data set; calculate the weight of each class, and the calculation formula of the weight value Class_weight is:
[0101] Class_weight = N total / N i
[0102] Among them, N total is the total number of all samples, N i is the number of samples of category i.
[0103] In the target detection model, the binary cross entropy loss function (nn.BCEWithLogitsLoss) is used to predict the target category. In order to solve the problem of imbalanced number of categories, category weights are introduced in the loss function, and the loss weights of each category are adjusted by setting the pos_weight parameter. The specific implementation steps are as follows:
[0104] Define the improved loss function and pass the calculated category weight as the pos_weight parameter:
[0105] self.bce=nn.BCEWithLogitsLoss(reduction='none',pos_weight=torch.FloatTensor(class_weights))
[0106] During the training process, when calculating the loss for each prediction box, the loss function automatically adjusts the contribution of each category according to the category weight, increasing the loss weight of the minority class and reducing the loss weight of the majority class. Using the back propagation algorithm, the gradient is calculated based on the adjusted loss and the model weight is updated. In this way, the model can pay more attention to minority class targets during training, improve the detection accuracy of these targets, and avoid majority class targets dominating the overall loss, thereby improving the overall detection performance of the model.
[0107] The present invention introduces category weights. When calculating the loss of each category, the improved loss function adjusts it according to the category weights, thereby paying more attention to minority class targets during the training process and balancing the loss contributions between categories. By increasing the loss weights of minority class targets, the model can pay more attention to these targets during the training process and significantly improve their detection accuracy. At the same time, it can also prevent the majority class targets from excessively dominating the overall loss, ensuring that the minority class targets can also have a significant impact on the update of the model, thereby improving the overall detection performance of the model.
[0108] Step 5: Training Settings and Strategies
[0109] Training settings: During the training process, first set the training hyper parameters and network parameters. Input the training set into the network, train the improved YOLOv5 network, and save the trained weight file. The improved YOLOv5 model uses the regression loss function of the predicted bounding box to calculate the loss. The loss function calculates the category score, confidence score, center coordinates and width and height of each predicted box (predicted corrected box) relative to the category, center coordinates and width and height of the real calibration box. The weights are updated by back-propagation to obtain the gradient and obtain the updated weight parameters. In order to gradually reduce the loss, each batch sent to the improved neural network model will update the model weights until the loss value converges. Verify on the validation set and adjust the learning rate according to the loss curve and detection effect. Finally, the model converges, the training stops, and the final detection model based on the improved YOLOv5 neural network is obtained.
[0110] Step 6: Output the predicted bounding box information and category probability.
[0111] Import the model parameters saved in step 5 into the improved YOLOv5 model, send the test image into the improved YOLOv5 model, use the logistic function to activate the network's predicted x, y, confidence, and category probability, and obtain the coordinates, confidence, and category probability of all predicted boxes after threshold judgment; output the predicted bounding box information and category probability.
[0112] At this time, the detection image has multiple predicted bounding boxes. Traditional non-maximum suppression sorts the detection boxes by score, then retains the box with the highest score, and deletes other boxes whose overlapping area with the box is greater than a certain ratio. This is likely to cause missed detection of the target. Therefore, in order to reduce the missed detection rate of the model, softened non-maximum is used. Instead of rudely deleting all boxes with IOU greater than the threshold, its confidence is reduced, and a confidence threshold is specified. Then, the detection boxes with scores greater than the threshold are retained. This step is repeated in the remaining predicted bounding boxes, and finally a predicted bounding box corresponding to each road target is obtained. Finally, the detection image is visualized to generate the final target detection box and recognition result, such as Figure 5-7 As shown, Figure 5 The defect identification and monitoring effect of a substation based on a lightweight model improvement according to an embodiment of the present invention is shown in FIG. Figure 1 ; Figure 6 The defect identification and monitoring effect of a substation based on a lightweight model improvement according to an embodiment of the present invention is shown in FIG. Figure 2 ; Figure 7 The defect identification and monitoring effect of a substation based on a lightweight model improvement according to an embodiment of the present invention is shown in FIG. Figure 3 .
[0113] The present invention uses softened non-maximum suppression to eliminate redundant prediction boundary boxes, thereby improving the positioning accuracy and detection accuracy of the network.
[0114] Detection accuracy comparison
[0115] The algorithm of the present invention adopts two indicators, mean average precision (mAP) and frames per second (FPS), for evaluation. The mean average precision is actually the mean of the average precision (AP) of various defective devices. The frames per second (FPS) is an important indicator of detection speed, reflecting the real-time detection performance of the algorithm.
[0116] The detection result indicators of each category are precision, that is, the percentage of correctly detected equipment defects in the total detection area, and its calculation method is shown in formula (1); recall, that is, the percentage of correctly detected equipment defects in the total equipment defects, and its calculation method is shown in formula (2). A curve is drawn based on the precision and recall of each category of detection results. The area under the curve is the average precision, and its calculation formula is shown in formula (3).
[0117]
[0118] Where TP is the number of correctly detected device defects; FP is the number of device defects detected as background; FN is the number of device defects detected as background; p is the precision on the vertical axis; and r is the recall on the horizontal axis.
[0119] In order to verify the superiority of the proposed method, the detection performance of the improved YOLOv5 detection network is compared with that of the current mainstream detection algorithm. The test data set used is the substation equipment defect test set. The results are shown in Table 1.
[0120]
[0121]
[0122] Table 1 Comparison results
[0123] The two-stage detection algorithms represented by Faster RCNN and Cascade RCNN have good detection accuracy in the test set, but the two-stage detection algorithms often do not have real-time performance. For example, the FPS of Faster RCNN is only 10.1, which cannot meet the real-time requirements of the detection algorithm for smart substations. As shown in Table 1, the detection algorithm with the highest detection accuracy is the improved YOLOv5 detection algorithm of the present invention, which not only has a detection accuracy of 0.873 (better than all the detection algorithms listed in Table 1), but also has a significantly improved detection speed compared to the original YOLOv5.
[0124] Embodiment 3
[0125] Figure 8 FIG. 1 is a structural diagram of a substation defect identification system based on a lightweight model improvement according to an embodiment of the present invention. Figure 8 As shown, according to an embodiment of the present invention, a substation defect identification system based on lightweight model improvement includes:
[0126] A data set construction module 10 is used to construct a substation defect data set;
[0127] A model building module 20 is used to improve the YOLOv5 neural network model based on a lightweight model to build a substation defect recognition model;
[0128] The training module 30 is used to set the training super parameters and network parameters, input the training set in the substation defect data set into the network, train the substation defect recognition model, and save the trained weight file;
[0129] Recognition module 40, used to output predicted bounding box information and category probability;
[0130] The recognition module 40 is also used to use the softened non-maximum filtering detection frame to visualize the detection image and generate a final target detection frame and recognition result.
[0131] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0132] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the invention involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the inventive concept. For example, the above features are replaced with (but not limited to) technical features with similar functions disclosed in the present application.
[0133] It should be understood that the size of the serial numbers of each step in the content of the invention and the embodiments of the present invention does not absolutely mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
Claims
1. A substation defect identification method based on lightweight model improvement, characterized in that: The following steps are involved: Construct substation defect dataset; The YOLOv5 neural network model is improved based on the lightweight model to build a substation defect recognition model; Setting training super parameters and network parameters, inputting the training set in the substation defect data set into the network, training the substation defect recognition model, and saving the trained weight file; Output predicted bounding box information and category probability; Use softened non-maximum filtering to filter the detection frame, visualize the detection image, and generate the final target detection frame and recognition result.
2. The substation defect identification method based on lightweight model improvement according to claim 1 is characterized in that: The substation defect data set includes: scene data of the substation field environment under different lighting and weather conditions.
3. The substation defect identification method based on lightweight model improvement according to claim 2 is characterized in that: The method also includes: designing the substation defect data set into a VOC data set format, the VOC data set includes a JPEGImages folder, an Annotations folder and an Imagesets folder, wherein the JPEGImages folder is used to store training set and test set images, the Annotations folder is used to store XML type annotation files, and the Imagesets folder is used to store txt text, each line of the txt text corresponds to the name of a picture, the substation defect recognition model reads the file name according to the txt text, and then searches for the corresponding pictures and annotation information in the JPEGImages folder and the annotations folder, obtains the annotation information of the substation defects in the found picture annotations, and obtains the border parameters of the annotation information.
4. The substation defect identification method based on lightweight model improvement according to claim 3 is characterized in that: The images in the VOC dataset are randomly divided into different batches. Before being sent to the substation defect recognition model, the images are randomly rotated, cropped, translated, flipped, and subjected to noise disturbance data enhancement to expand the diversity of image scenes.
5. The substation defect identification method based on lightweight model improvement according to claim 1 is characterized in that: The YOLOv5 neural network model is improved based on a lightweight model, including: using ShuffleNetv2 to improve the YOLOv5 neural network model, specifically, Use the basic module ShuffleBlock in ShuffleNetv2 to replace the Darknet53 backbone network of the YOLOv5 neural network model; The SPP layer is removed and the original PANet neck network of the YOLOv5 neural network model is retained.
6. The substation defect identification method based on lightweight model improvement according to claim 5 is characterized in that: The YOLOv5 neural network model is improved based on a lightweight model, and also includes: introducing the CBAM module into the feature fusion structure of the network model.
7. The substation defect identification method based on lightweight model improvement according to claim 1 is characterized in that: The method further includes: introducing category weights based on the original loss function, specifically, Get the number of samples of each category in the training data set; use the following formula to calculate the weight value Class_weight of each category, Class_weight=N total / N i Among them, N total is the total number of all samples, N i is the number of samples of category i; Define the improved loss function and pass the calculated category weight as the pos_weight parameter.
8. The method for identifying substation defects based on lightweight model improvement according to claim 1 is characterized in that: The method also includes: during the training process, using the regression loss function of the predicted bounding box to calculate the loss, calculating the category score, confidence score, center coordinates and width and height of each predicted correction box relative to the real calibration box category, center coordinates and width and height through the loss function, obtaining the gradient through back propagation to update the weight, and obtaining the updated weight parameters, each batch sent to the substation defect recognition model updates the model weights until the loss value converges, saving the model parameters every 10,000 iterations, and verifying it under the verification set at the same time, and adjusting the learning rate according to the loss curve and the detection effect on the verification set.
9. The method for identifying substation defects based on lightweight model improvement according to claim 1 is characterized in that: The method also includes: using softened non-maxima to reduce their confidence, specifying a confidence threshold, and finally retaining the detection boxes with scores greater than the threshold, and looping this step in the remaining predicted bounding boxes to finally obtain a predicted bounding box corresponding to each road target.
10. A substation defect identification system based on lightweight model improvement, characterized in that: include: A data set construction module, used to construct a substation defect data set; Model building module, which is used to improve the YOLOv5 neural network model based on a lightweight model and build a substation defect recognition model; A training module, used to set training super parameters and network parameters, input the training set in the substation defect data set into the network, train the substation defect recognition model, and save the trained weight file; The recognition module is used to output the predicted bounding box information and category probability; The recognition module is also used to use a softened non-maximum filter detection frame to visualize the detection image and generate a final target detection frame and recognition result.