Improved YOLOv7 method for defect detection of power equipment in substations
By introducing the Ghost module and multi-scale attention mechanism in the YOLOv7 model, combined with the Slim-neck structure of GSConv, the problem of slow in inference and detection speed in the detection of defects of substation power equipment is solved, and efficient and lightweight detection capabilities are achieved.
Patent Information
- Application Number
- CN202411828403.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-12
- Publication Date
- 2025-04-08
AI Technical Summary
In the detection of substation power equipment defects, due to limited computing power and large number of detection model parameters, the inference and detection speed are slow, which cannot meet the needs of efficient inspection of substations.
The YOLOv7 method is improved, and the Ghost module is introduced into the feature extraction network and the traditional convolution is replaced to form the G-ELAN module; the multi-scale attention mechanism and the Slim-neck structure of GSConv are used in the feature enhancement network to reduce the calculation complexity and parameter amount.
It significantly improves the recognition ability of the target detection model in complex contexts, reduces the calculation complexity and parameter quantity of the model, improves the detection speed, and is suitable for resource-constrained substation environments.
Smart Images

Figure CN119782960A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of power equipment maintenance, and specifically relates to an improved YOLOv7 method for defect detection of power equipment in a substation. Background Art
[0002] The rapid development of new energy has become the key to the transformation of energy structure. In particular, the rapid increase in installed capacity of renewable energy such as wind and solar energy has posed new challenges to the stability and operation efficiency of the power system. As a key node of the power system, the reliability and safety of the operation of the substation are crucial to the stability of the entire power network. The uncertainty and complexity introduced by the access of new energy to the power grid have put forward higher requirements for the management and operation and maintenance of substations, making inspection work more difficult.
[0003] Common types of defects in substation equipment include, but are not limited to, box doors not closed, transformer oil leakage, damaged or unclear instruments, and hanging foreign objects. If these defects are not discovered and handled in a timely manner, they may lead to equipment failure, abnormal system operation or even shutdown, and in serious cases, may also cause power accidents. For example, if the transformer is damp, its insulation performance may be reduced, and then fail; if the switch cabinet door is not closed, it may cause electric shock to personnel; damaged monitoring equipment may cause operational errors; and foreign objects in the station, such as bird nests, may cause short circuits and other faults. Therefore, to ensure the safe and reliable operation of the new power system, any abnormal conditions and equipment defects in the substation must be discovered in a timely manner through more effective inspection methods.
[0004] Traditional substation inspections mainly rely on regular manual inspections, which is not only inefficient but also costly. For large substations, manual inspections may take more than two hours, and traditional monitoring equipment has a high risk of false detection and missed detection in early warning and fault tracking. With the rapid development of the power industry, this traditional inspection method can no longer meet the operation, maintenance and safety management needs of substations and power systems. Therefore, intelligent inspections have gradually become an inevitable trend in the development of substations and even the entire power industry. Summary of the invention
[0005] In view of the shortcomings of the existing substation power equipment defect detection method, the present invention provides an improved YOLOv7 method for substation power equipment defect detection, which is used to solve the "slow reasoning and slow detection" problems caused by the limited computing power of the substation and the large number of detection model parameters.
[0006] In order to solve the above technical problems, the technical solution adopted by the present invention is:
[0007] An improved YOLOv7 method for defect detection of power equipment in a substation includes the following steps:
[0008] In the feature extraction network of the YOLOv7 model, while keeping the overall architecture of the ELAN module unchanged, the traditional convolutions in the third and fourth layers are replaced with Ghost modules to form the G-ELAN module.
[0009] In the feature enhancement network of the YOLOv7 model, an EMA module is placed in front of the re-parameterized RepConv module based on the multi-scale attention mechanism, and it is arranged in branches with different numbers of channels. At the same time, the Slim-neck structure is used to improve the feature enhancement network.
[0010] Furthermore, in the YOLOv7 backbone network framework with the Ghost module, the model input is X, with size X∈R h×w×m , and the size of the output feature map Y′ is Y′∈R h′×w′×m , where m is smaller than n to reduce the number of channels;
[0011] The output Y′ is linearly transformed as shown below to supplement the features. The number of channels of the new feature map finally generated is s:
[0012] Y′ ij =Φ i,j (Y′ i )
[0013] In the formula, Y′ i represents the i-th feature map, Y′ ij represents the jth feature map obtained from the i-th feature map, Φ i,j Represents a linear transformation.
[0014] Furthermore, the G-ELAN module includes two consecutive Ghost modules, the first Ghost module expands the output of the feature layer, and the second Ghost module is responsible for reducing the number of channels.
[0015] Furthermore, in order to ensure that the number of output channels after the transformation is the same as that of the traditional convolution, the number of channels of the Ghost module is set to s = n / m, where n is the number of input channels of the original convolution and s is the number of output channels of the Ghost module;
[0016] The specific reduction ratio of the amount of calculation after using the Ghost module is R s as follows:
[0017]
[0018]
[0019] Where h and w represent the size of the input image, and c represents the number of input and output channels of the original convolution, the size of the original convolution kernel is k, and each linear transformation is completed through a d×d convolution operation.
[0020] Furthermore, after replacing the original ELAN module with the G-ELAN module, the parameter compression ratio P s as follows:
[0021]
[0022] Furthermore, the EMA module specifically includes two parallel 1×1 convolution branches and one 3×3 convolution branch. The two 1×1 branches use one-dimensional average pooling along different directions, and tensor multiplication is used to integrate the two 1×1 branches to realize different cross-channel feature interactions.
[0023] Global 2D pooling is introduced in both 1×1 and 3×3 convolution branches to fully learn global information and model channel information, and the output results are transformed by Softmax activation function and matrix dot multiplication fusion;
[0024] At the end of the EMA module, the global spatial attention map obtained by the 3×3 branch is weightedly merged with the fused spatial attention map, and the weights are calculated by the features of each output group;
[0025] The output of the EMA module is fused with feature maps of other scales and the original feature maps to further enhance feature richness.
[0026] Furthermore, the GSConv structure starts by performing a standard convolution operation on the substation power equipment feature map, concatenates the outputs of the two after a depth-wise separable convolution calculation, and performs a random rearrangement to ensure that the concatenated channels are evenly distributed in the result.
[0027] Furthermore, the VoV-GSCSP module based on GSConv replaces some stacked convolutional layers of the feature enhancement network.
[0028] Compared with the prior art, the present invention has the following beneficial effects:
[0029] Based on GhostNet, this paper significantly improves the recognition ability of the target detection model in complex backgrounds through lightweight improvement, multi-scale fusion attention mechanism and the application of GSConv's Slim-neck structure, while reducing the computational complexity and parameter quantity of the model. This innovative research result provides new ideas for the development of computer vision and has broad application prospects and practical value. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1This is a diagram of the Ghost module architecture of an embodiment of the present invention;
[0031] Figure 2 This is a diagram of the Ghost bottleneck module architecture of an embodiment of the present invention;
[0032] Figure 3 This is a G-ELAN module architecture diagram according to an embodiment of the present invention;
[0033] Figure 4 This is a G-YOLOv7 model architecture diagram of an embodiment of the present invention;
[0034] Figure 5 This is a diagram of the architecture of the multi-scale fusion attention mechanism of an embodiment of the present invention;
[0035] Figure 6 This is a GE-YOLOv7 model architecture diagram of an embodiment of the present invention;
[0036] Figure 7 This is a diagram of the GSConv module architecture of an embodiment of the present invention;
[0037] Figure 8 This is a diagram of the VoV-GSCSP module architecture of an embodiment of the present invention;
[0038] Fig. 9 This is a diagram of the G-Sn-YOLOv7 model architecture of an embodiment of the present invention. DETAILED DESCRIPTION
[0039] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0040] Example
[0041] See also Figure 1-9 ,The improved YOLOv7 method for substation power equipment defect detection includes the following steps:
[0042] 1) Improvement of lightweight feature extraction network based on Ghost module.
[0043] The backbone network structure of YOLOv7 is based on CSPDarknet-53. With the deepening of the network structure and the stacking of modules, the model becomes more and more complex, and the number of parameters increases significantly. The number of parameters of the basic model reaches 35.6M, and the computational requirements for each iteration are as high as 116.7GFLOPs. It is particularly difficult to deploy such a model in a resource-limited environment, such as a substation or low-computing power device.
[0044] If the model input is X∈R h×w×c , the output feature map is Y∈R h′×w′×n , the convolution kernel is f∈R c×k×k×n , then the ordinary convolution operation is shown in formula (1):
[0045] Y=X×f+b (1)
[0046] Traditional convolution operations usually involve a large amount of computation, where the total computation is n×h′×w′×c×k×k. Although the computation of a single convolution operation is small, the computational cost increases significantly when the number of channels n and c reaches 32, 64 or more.
[0047] In this regard, this embodiment adopts a lightweight strategy, introduces the Ghost module, optimizes the YOLOv7 backbone network, generates feature maps through ordinary convolution and linear operation expansion, effectively retains the original feature information without changing the size and number of channels of the output feature map, and significantly reduces the number of parameters and calculations of the model, ensuring that it can run effectively on devices with limited computing resources. In this framework, the input of the model is X, with size X∈R h×w×m , and the size of the output feature map Y′ is Y′∈R h′×w′×m , where m is less than n to reduce the number of channels. Next, the output Y′ is linearly transformed as shown in formula (2) to supplement the features, and the number of channels of the new feature map finally generated is s.
[0048] Y′ ij =Φ i,j (Y′ i ) (2)
[0049] In the formula, Y′ i represents the i-th feature map, Y′ ij represents the jth feature map obtained from the i-th feature map, Φ i,j Represents a linear transformation.
[0050] The Ghost module design includes a mapping that keeps the number of channels unchanged and m×(s-1) linear transformations. Each linear transformation in this embodiment is completed through a d×d convolution operation. In order to ensure that the number of output channels after the transformation is the same as the number of output channels of the traditional convolution, the number of channels of the Ghost module is set to s=n / m. In this way, the use of the Ghost module can significantly reduce the amount of calculation of the model. The specific reduction in the proportion of calculation is R s Calculate according to formula (3):
[0051]
[0052] Where h and w represent the size of the input image, while n and c represent the number of input and output channels of the original convolution, respectively. The size of the original convolution kernel is k, while the number of output channels of the Ghost module is s = n / m. In addition, the size of the convolution kernel d used for linear transformation is close to the size of the original convolution kernel k. This setting aims to maintain the validity of the transformed features while optimizing the computational efficiency. Similar to the above calculation method, the parameter compression ratio P s It can be expressed as formula (4):
[0053]
[0054] In this architecture, the Ghost bottleneck module (G-bneck) consists of two consecutive Ghost modules. The first Ghost module expands the output of the feature layer, while the second Ghost module is responsible for reducing the number of channels after the activation function is applied to the output of the first module. In addition, when using a stride of 2, in order to achieve downsampling, a deep convolutional layer with a stride of 2 is inserted between the two Ghost modules, effectively connecting the two modules.
[0055] On the basis of keeping the overall architecture of the ELAN module unchanged, the G-ELAN module is designed by replacing the traditional convolution of the original third and fourth layers with the Ghost module with smaller calculation and parameter volume. This module is used to replace the original ELAN module in the YOLOv7 model to reduce the parameter volume and calculation burden of the model while retaining the effective fusion between feature layers. This improvement enhances the robustness of the model and solves the parameter expansion problem caused by the stacking of multi-layer convolution modules in the original model to a certain extent. Based on this improvement, this embodiment proposes a lightweight version of the model, called G-YOLOv7.
[0056] 2) Feature enhancement network improvements.
[0057] (1) Multi-scale Attention Mechanism
[0058] For the effective feature layers extracted by the feature extraction network, the feature enhancement network will perform upsampling and downsampling respectively. In order to capture deep features, convolutional neural networks (CNNs) are often implemented by stacking multiple convolutional layers, which not only consumes a lot of computing resources and memory, but may also introduce unnecessary redundant or misleading information into the network. As an optimization strategy, the attention mechanism can effectively enhance the network's learning of key features through its flexible structure, thereby improving the discriminability of features.
[0059] The Efficient Multi-scale Attention (EMA) mechanism abandons the traditional method of allocating attention weights by uniform aggregation, and instead adopts a cross-space learning method to fuse the attention weights of parallel paths in the sub-network, thereby providing more refined feature regulation. The core of this mechanism is to carefully process the grouped feature maps. In this mechanism, g represents the number of groups, and Group Norm (GN) is similar to batch normalization, but it normalizes the feature maps within a single group. In addition, the matrix multiplication (Matmul) operation is used to calculate the pairwise relationship between pixels within the feature map, thereby capturing local pixel features.
[0060] The multi-scale attention mechanism uses three branches to extract the attention weights within the group, including two parallel 1×1 convolution branches and one 3×3 convolution branch. The two 1×1 branches use one-dimensional average pooling along different directions, while the 3×3 branch uses a 3×3 convolution kernel to capture a wider range of scale features. In addition, in order to achieve different cross-channel feature interactions in the two 1×1 branches, tensor multiplication is used to integrate the feature maps of the two channels to enhance the interaction between channels. This mechanism can effectively capture target features of different scales and improve the model's recognition ability in complex backgrounds. By fusing feature maps at different levels, the model can simultaneously focus on the detailed information and overall structure of the target, thereby better identifying the target.
[0061] This mechanism achieves dynamic update of channel weights by finely processing the interaction information between channels, while preserving spatial information during the process. In order to fully learn global information and model channel information, the mechanism introduces global two-dimensional pooling (Avg Pool) in both branches including 1×1 and 3×3 convolutions, and then transforms the output through the Softmax activation function. In order to integrate the spatial attention information, matrix dot multiplication is used to fuse the outputs of the two branches. At the end of the EMA module, the global spatial attention map obtained by the 3×3 branch is weightedly merged with the fused spatial attention map, and these weights are calculated by the features of each output group.
[0062] Based on this mechanism, this embodiment retains a series of structures for feature enhancement in the feature enhancement network of the G-YOLOv7 model, introduces the EMA module, and designs the GE-YOLOv7 model to enhance the feature extraction and recognition capabilities of the model.
[0063] In this embodiment, in order to ensure the integrity of feature information and improve the overall robustness of the model, an EMA module is placed before the re-parameterized RepConv module and arranged in branches with different numbers of channels. The output of the EMA module is fused with feature maps of other scales and the original feature map to further enhance the richness of features.
[0064] (2) Slim-neck structure
[0065] Depthwise separable convolution (DWConv) is applied to reduce the computational complexity of the model and is widely used in various convolutional neural networks. Although DWConv can effectively reduce the consumption of computing resources in many cases, it also has some limitations. First, DWConv cannot replace the traditional convolution operation (Conv) in some cases without sacrificing model performance. Secondly, in the process of speeding up model training, the image input must undergo information conversion from spatial dimension to channel dimension when passing through the backbone network. This process of spatial compression and channel expansion may lead to the loss of semantic information. Each spatial compression and channel expansion of the feature map may lose important semantic content to a certain extent.
[0066] The Group Shuffle Convolution (GSConv) structure starts with a standard convolution operation on the substation power equipment feature map, concatenates the outputs of the two after a depthwise separable convolution (DWConv) calculation, and finally performs a random shuffle (Shuffle) to ensure that the concatenated channels are evenly distributed in the result.
[0067] Widely using GSConv in all stages of the network will reduce the network's reasoning speed and significantly increase the network depth. However, in the stage of feature enhancement network, the input feature map is large in channel dimension but small in spatial size. Such "slender" feature maps should not be transformed too much. Therefore, this embodiment chooses to selectively use GSConv in the feature enhancement network.
[0068] The VoV-GSCSP module designed based on GSConv is used to replace some stacked convolutional layers in the feature enhancement network. In this way, the module can effectively extract richer features from feature maps with many channels but small size without increasing the amount of calculation and parameters, thereby enhancing the overall performance of the model.
[0069] Based on the above ideas, the GSConv and VoV-GSCSP modules are applied to the EMA-G-OLOv7 model, and the G-Sn-YOLOv7 model is proposed.
[0070] 3) Testing experiments and results.
[0071] This embodiment uses Grad-CAM technology to compare the improved model with the original YOLOv7 model and its improved version G-YOLOv7. It is found that the introduction of the EMA module can well solve the problem that the background of some images in the data set is difficult to distinguish. The average accuracy of the GE-YOLOv7 model is higher than that of G-YOLOv7. Table 1 shows the comparative experimental results of adding EMA modules in different layers.
[0072] Table 1 EMA module experimental results
[0073] EMA module layer number Accuracy Recall Average accuracy / % Increase parameter quantity / M — 0.7 0.67 68.3 0
[0074] Table 1 EMA module experimental results
[0075] EMA module layer number Accuracy Recall Average accuracy / % Increase parameter quantity / M 40 0.72 0.671 68.3 0.05 50 0.74 0.645 68.6 0.30 65 0.722 0.677 68.7 0.78 40、50 0.735 0.675 68.4 0.72 40、65 0.738 0.686 68.9 1.98 50、65 0.73 0.646 68.7 2.09 40、50、65 0.736 0.655 68.5 2.53
[0076] The present invention is based on an improved model that introduces the EMA module in layers 40 and 65, and further constructs a Slim-neck structure in the feature enhancement network through the VoV-GSCSP module and the new convolution GSConv. Table 2 shows the performance of each improved model.
[0077] Table 2 EMA module ablation experiment
[0078] Model Accuracy Recall Average accuracy / % Parameter quantity / M Detection speed / FPS YOLOv7 0.704 0.694 69.1 35.64 63.7 G-YOLOv7 0.702 0.696 69.3 27.56 92.3 GE-YOLOv7 0.741 0.688 69.1 24.33 90.4 G-Sn-YOLOv7 0.745 0.675 69.9 20.89 96.5
[0079] According to the data analysis results in Table 2, the G-Sn-YOLOv7 model proposed in this embodiment has a significant improvement in detection speed, and the frame rate (FPS) has increased by 32.8. Although the recall rate of this model is slightly lower than that of the original YOLOv7 model by 0.19, its precision rate has increased to 0.745, which is 0.41 higher than the original model. In addition, the improved model successfully reduced the number of parameters by 14.75M while sacrificing only 0.4% of the mean average precision (mAP), achieving lightweight model while maintaining high detection performance.
[0080] Finally, it should be noted that the above embodiments are only preferred embodiments of the present invention, which are only used to illustrate the technical solution of the present invention rather than to limit it. Any modification, improvement, other modification or equivalent replacement made to the technical solution of the present invention by ordinary technicians in this field, as long as they do not depart from the spirit and scope of the technical solution of the present invention, should be included in the protection scope of the present invention.
Claims
1. An improved YOLOv7 method for defect detection of power equipment in substations, characterized by: The steps include: In the feature extraction network of the YOLOv7 model, while keeping the overall architecture of the ELAN module unchanged, the traditional convolutions in the third and fourth layers are replaced with Ghost modules to form the G-ELAN module. In the feature enhancement network of the YOLOv7 model, an EMA module is placed in front of the re-parameterized RepConv module based on the multi-scale attention mechanism, and it is arranged in branches with different numbers of channels. At the same time, the Slim-neck structure is used to improve the feature enhancement network.
2. The improved YOLOv7 method for substation power equipment defect detection according to claim 1 is characterized in that: In the YOLOv7 backbone network framework with the Ghost module, the input of the model is X, with size X∈R h×w×m , and the size of the output feature map Y′ is Y′∈R h′×w′×m , where m is smaller than n to reduce the number of channels; The output Y′ is linearly transformed as shown below to supplement the features. The number of channels of the new feature map finally generated is s: AND' ij =Φ i,j (AND' i ) In the formula, Y′ i represents the i-th feature map, Y′ ij represents the jth feature map obtained from the i-th feature map, Φ i,j Represents a linear transformation.
3. The improved YOLOv7 method for substation power equipment defect detection according to claim 2 is characterized in that: The G-ELAN module contains two consecutive Ghost modules, the first Ghost module expands the output of the feature layer, and the second Ghost module is responsible for reducing the number of channels.
4. The improved YOLOv7 method for substation power equipment defect detection according to claim 3 is characterized in that: In order to ensure that the number of output channels after transformation is the same as that of traditional convolution, the number of channels of Ghost module is set to s=n / m, where n is the number of input channels of original convolution and s is the number of output channels of Ghost module; The specific reduction ratio of the amount of calculation after using the Ghost module is R s as follows: Where h and w represent the size of the input image, and c represents the number of input and output channels of the original convolution, the size of the original convolution kernel is k, and each linear transformation is completed through a d×d convolution operation.
5. The improved YOLOv7 method for substation power equipment defect detection according to claim 4 is characterized in that: After G-ELAN module is used to replace the original ELAN module, the parameter compression ratio P s as follows:
6. The improved YOLOv7 method for substation power equipment defect detection according to claim 5 is characterized in that: The EMA module specifically consists of two parallel 1×1 convolution branches and one 3×3 convolution branch. The two 1×1 branches use one-dimensional average pooling along different directions, and tensor multiplication is used to integrate the two 1×1 branches to achieve different cross-channel feature interactions. Global 2D pooling is introduced in both 1×1 and 3×3 convolution branches to fully learn global information and model channel information, and the output results are transformed by Softmax activation function and matrix dot multiplication fusion; At the end of the EMA module, the global spatial attention map obtained by the 3×3 branch is weightedly merged with the fused spatial attention map, and the weights are calculated by the features of each output group; The output of the EMA module is fused with feature maps of other scales and the original feature maps to further enhance feature richness.
7. The improved YOLOv7 method for substation power equipment defect detection according to claim 6 is characterized in that: The GSConv structure starts with performing a standard convolution operation on the substation power equipment feature map, concatenates the outputs of the two after a depth-wise separable convolution calculation, and performs a random rearrangement to ensure that the concatenated channels are evenly distributed in the result.
8. The improved YOLOv7 method for substation power equipment defect detection according to claim 7, characterized in that: The VoV-GSCSP module based on GSConv replaces some stacked convolutional layers of the feature enhancement network.
Citation Information
Cited By
Information identification method and information identification system of transformer substation protection device
CN122023407A
Information identification method and information identification system for substation protection device
CN122023407B