A method and device for detecting defects of key equipment in a clean energy station based on improved YOLOv7
By improving the YOLOv7 model and introducing the GAMATtention attention module and the Inner-PIoU fusion loss function, the problem of insufficient accuracy in small target detection in clean energy power plants was solved, achieving more efficient equipment defect identification and improving the intelligent inspection level of clean energy power plants.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ANHUI NANRUI JIYUAN POWER GRID TECH CO LTD
- Filing Date
- 2026-03-18
- Publication Date
- 2026-06-05
AI Technical Summary
Existing intelligent inspection systems lack the accuracy and robustness in identifying equipment defects in clean energy power plants, especially in detecting small-scale defects and minor anomalies in complex environments.
An improved YOLOv7 model is adopted, introducing the GAMATtention attention module and the Inner-PIoU fusion loss function. By improving the network structure and loss function of the YOLOv7 model, the detection capability of small targets is improved, computational redundancy is reduced, and the detection accuracy and feature extraction capability of the model are enhanced.
It significantly improves the ability to identify small target defects that are low-resolution, lack information, and are susceptible to noise interference, achieving more accurate and robust intelligent defect detection and supporting the safe and stable operation of clean energy power plants.
Smart Images

Figure CN122157263A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of power equipment inspection and target detection technology, and in particular to a method and equipment for detecting defects in key equipment of clean energy power plants based on an improved YOLOv7. Background Technology
[0002] With the transformation of the global energy structure, clean energy has become a key force driving future energy development. The rapid development of clean energy technologies such as wind, solar, and hydropower has brought about numerous challenges in power plant maintenance. Clean energy power plants are typically widely distributed and located in complex environments. Traditional manual inspections are not only time-consuming and costly, but also difficult to cover all equipment, especially in large-scale clean energy power plants, where manual inspections are often limited by environmental factors (such as severe weather and geographical location). To address these maintenance challenges, the introduction of intelligent inspection has significantly improved inspection efficiency and equipment reliability through modern technology, providing a strong guarantee for the safe and stable operation of clean energy. With continuous technological advancements and the expansion of power plant scale, intelligent inspection will play an even more important role in the future clean energy industry, promoting the intelligent and green development of power systems.
[0003] However, in practice, defect detection in clean energy power plant equipment still faces challenges such as insufficient training of intelligent identification algorithms and low accuracy. While current intelligent inspection systems have made some progress in improving inspection efficiency and reducing labor costs, there is still significant room for improvement in the accuracy and robustness of defect detection. Existing intelligent analysis models are often constrained by insufficient training data and low model accuracy, resulting in limited ability to identify equipment faults in complex environments, particularly for small-scale defects and minor anomalies. Therefore, there is an urgent need to develop and optimize more efficient and reliable intelligent identification models to improve the accuracy of equipment defect detection, thereby promoting the improvement of intelligent inspection capabilities in clean energy power plants and contributing to the intelligent operation and maintenance and healthy and stable operation of new power systems. Summary of the Invention
[0004] To address the issues of low accuracy and insufficient ability to detect small targets in existing detection technologies, the primary objective of this invention is to provide a method for identifying key equipment defects in clean energy power plants based on an improved YOLOv7. This method can accurately focus on the defect features of small targets, while reducing computational redundancy, significantly improving the detection accuracy and feature extraction capabilities of the model, and greatly enhancing the ability to identify defects in small targets that are low-resolution, lack information, and are susceptible to noise interference.
[0005] To achieve the above objectives, the present invention adopts the following technical solution: a method for addressing key equipment defects in clean energy power plants based on improved YOLOv7, the method comprising the following sequential steps:
[0006] (1) Take and collect images of key equipment in clean energy power stations, and perform annotation and preprocessing on the collected images to obtain preprocessed images and form a dataset. Divide the dataset into training set, test set and validation set.
[0007] (2) Improve the YOLOv7 model: Based on the YOLOv7 model, introduce the GAMATtention attention module and replace the Inner-IoU loss function with the Inner-PIoU fusion loss function to obtain the improved YOLOv7 model;
[0008] (3) The improved YOLOv7 model is trained using the training set to obtain the trained model, which is the object detection model;
[0009] (4) Input the substation equipment image to be inspected into the target detection model, and output the location and defect information of the defects in the substation equipment image to be inspected.
[0010] Step (1) specifically refers to: using the open-source annotation tool LabelImg to draw the bounding box of the target object in the dataset and to annotate the type of the target object, and then dividing the annotated dataset into a training set, a test set and a validation set.
[0011] In step (2), the introduction of the GAMATtention attention module on the basis of the YOLOv7 model specifically means: adding the GAMATtention attention module between the SPCSPC module and the CBS module, with the input of the GAMATtention attention module connected to the output of the SPCSPC module, and the output of the GAMATtention attention module connected to the inputs of the CBS module and the ELAN module respectively.
[0012] In step (2), the Inner-PIoU fusion loss function specifically refers to:
[0013] The Inner-IoU loss function introduces an auxiliary box that has the same geometric center as its original box. The size of the auxiliary box is controlled by a scaling factor. When the scaling factor is less than 1, the auxiliary box is smaller than the original box. When the scaling factor is greater than 1, the auxiliary box is larger than the original box. The scaling factor ranges from 0.5 to 1.5.
[0014] If the center points of the ground truth bounding box and the predicted bounding box are respectively and b The frame dimensions are respectively and Then the top corner of the actual auxiliary box The calculation formula is:
[0015] = - , = + ;
[0016] = - , = + ;
[0017] in, It is the x-coordinate of the left boundary of the actual auxiliary box; It is the x-coordinate of the right boundary of the actual auxiliary box; It is the y-coordinate of the upper boundary of the actual auxiliary bounding box; It is the y-coordinate of the lower boundary of the actual auxiliary bounding box; x and y are the coordinates of the center point of the ground truth bounding box; x and y are the coordinates of the center point of the predicted bounding box. These are the width and height of the ground truth bounding box, respectively; w and h are the width and height of the predicted bounding box, respectively. It is a scaling factor used to control the size of the auxiliary box;
[0018] Predict the top corner of the auxiliary box The calculation method is similar to that of the ground truth bounding box. Formula (1) calculates the degree of intersection between the ground truth bounding box and the predicted bounding box by the relative position of the top corners of the two bounding boxes. Formula (2) represents the union of the two bounding boxes.
[0019] inter = (1);
[0020] union = (2);
[0021] in, It is the x-coordinate of the left boundary of the predicted auxiliary box. It is the x-coordinate of the right boundary of the predicted auxiliary box. It is the y-coordinate of the upper boundary of the predicted auxiliary box. It is the ordinate of the lower boundary of the predicted auxiliary box;
[0022] The penalty factor P and the loss value are calculated using an improved loss function PloU adapted to the target size by a penalty factor P. :
[0023] P = / 4;
[0024] = +1- ;
[0025] In the formula, It is the absolute value of the distance between the left edge of the predicted bounding box and the left edge of the ground truth bounding box; The absolute value of the distance between the right edge of the predicted bounding box and the right edge of the ground truth bounding box; It is the absolute value of the distance between the top edge of the predicted bounding box and the top edge of the ground truth bounding box; It is the absolute value of the distance between the bottom edge of the predicted bounding box and the bottom edge of the ground truth bounding box; Basic IoU loss;
[0026] Adjustment factor An improved loss function, PloU, is introduced to adjust the strength of the penalty term, specifically the loss value. for:
[0027] = +1- ;
[0028] In the formula, It is an introduction The subsequent PIOU loss value;
[0029] The improved loss function PloU and the inner-IoU of the auxiliary box are fused to obtain the inner-PIoU fused loss function. :
[0030] = +1-r +(1-r) ;
[0031] In the formula, r is the fusion weight.
[0032] Another object of the present invention is to provide an electronic device comprising:
[0033] Processor; and
[0034] A memory storing computer program instructions that, when executed by the processor, cause the processor to perform the method for addressing critical equipment defects in clean energy plants based on the improved YOLOv7, as described above.
[0035] The present invention also provides a computer-readable storage medium having stored thereon computer program instructions, which, when executed by a processor, cause the processor to perform the method for addressing critical equipment defects in clean energy power plants based on the improved YOLOv7 as described above.
[0036] As can be seen from the above technical solution, the beneficial effects of the present invention are as follows: First, the present invention introduces the GAMATtention attention mechanism based on YOLOv7, which captures cross-dimensional interactions in the channel and spatial dimensions through a three-dimensional attention structure, effectively suppressing noise interference in complex backgrounds, enabling the network to accurately focus on the defect features of small targets, while reducing computational redundancy and significantly improving the detection accuracy and feature extraction capability of the model; Second, the present invention applies an Inner-PIoU fusion loss function based on auxiliary boxes and adjustment factors, which refines the constraints on the original bounding boxes by introducing auxiliary boxes, optimizes the regression process, and designs dynamic adjustment factors to balance the contribution weights of high-quality and low-quality samples to the loss function, thereby effectively alleviating the problem of excessively large detection box size and unbalanced loss contribution between samples that is easily caused by the classic IoU loss function during training; Third, the two improvements work together to significantly enhance the model's ability to identify small target defects that are low-resolution, lack information, and are susceptible to noise interference while maintaining the original detection speed, ultimately achieving more accurate and robust intelligent defect detection for clean energy station equipment, providing reliable technical support for actual operation and maintenance scenarios. Attached Figure Description
[0037] Figure 1 This is a flowchart of the method of the present invention;
[0038] Figure 2 This is the schematic diagram of Inner-IoU.
[0039] Figure 3 PIOU parameter graph;
[0040] Figure 4 This is a schematic diagram of the improved YOLOv7 model. Detailed Implementation
[0041] like Figure 1 As shown, a method for addressing key equipment defects in clean energy power plants based on an improved YOLOv7 is described. This method includes the following sequential steps:
[0042] (1) Take and collect images of key equipment in clean energy power stations, and perform annotation and preprocessing on the collected images to obtain preprocessed images and form a dataset. Divide the dataset into training set, test set and validation set.
[0043] (2) Improvement of the YOLOv7 model: Based on the YOLOv7 model, the GAMATtention attention module is introduced, and the Inner-PIoU fusion loss function is replaced with the Inner-IoU loss function to obtain the improved YOLOv7 model, such as... Figure 4As shown, the introduced GAMATtention attention module improves the detection capability of small targets and applies an Inner-PioU fusion loss function based on auxiliary boxes and adjustment factors to alleviate the imbalance of contributions of different quality samples to the loss function.
[0044] (3) The improved YOLOv7 model is trained using the training set to obtain the trained model, which is the object detection model;
[0045] (4) Input the substation equipment image to be inspected into the target detection model, and output the location and defect information of the defects in the substation equipment image to be inspected.
[0046] Step (1) specifically refers to: using the open-source annotation tool LabelImg to draw bounding boxes for target objects in the dataset and label the types of target objects, and then dividing the labeled dataset into training, testing, and validation sets. Images of equipment at actual clean energy power plants are taken, mainly including images of wind, hydro, and photovoltaic power plants. The collected images are then labeled using annotation tools. The main annotation content involves drawing bounding boxes for target objects in each image and labeling the category of the target objects.
[0047] In step (2), the introduction of the GAMATtention attention module on the basis of the YOLOv7 model specifically means: adding the GAMATtention attention module between the SPCSPC module and the CBS module, with the input of the GAMATtention attention module connected to the output of the SPCSPC module, and the output of the GAMATtention attention module connected to the inputs of the CBS module and the ELAN module respectively.
[0048] The GAMAttention attention module allows the model to focus more on the location of small targets rather than background information, thereby improving its ability to detect small targets. It can also adaptively learn the size and position of each small target to further improve the accuracy of small target detection. GAMAttention is a global attention mechanism that combines channel attention and spatial attention mechanisms in its overall structure. For the input feature map, the GAMAttention module first performs a dimensionality transformation to adjust the dimensions of the feature map, aiming to reduce computational complexity and the number of parameters. The dimensionality-transformed feature map is then input into a multilayer perceptron for further processing. The processed feature map is then transformed back to its original dimensions and finally processed by the sigmoid function before being output. Compared to the spatial attention module, GAMAttention primarily handles channel attention through convolutional operations.
[0049] In step (2), the Inner-PIoU fusion loss function specifically refers to:
[0050] like Figure 2 As shown, the auxiliary box introduced by the Inner-IoU loss function has the same geometric center as its corresponding original box, and the size of the auxiliary box is controlled by a scaling factor. When the scaling factor is less than 1, the auxiliary box is smaller than the original box, and when the scaling factor is greater than 1, the auxiliary box is larger than the original box. The value of the scaling factor is between 0.5 and 1.5.
[0051] If the center points of the ground truth bounding box and the predicted bounding box are respectively and b The frame dimensions are respectively and Then the top corner of the actual auxiliary box The calculation formula is:
[0052] = - , = + ;
[0053] = - , = + ;
[0054] in, It is the x-coordinate of the left boundary of the actual auxiliary box; It is the x-coordinate of the right boundary of the actual auxiliary box; It is the y-coordinate of the upper boundary of the actual auxiliary bounding box; It is the y-coordinate of the lower boundary of the actual auxiliary bounding box; x and y are the coordinates of the center point of the ground truth bounding box; x and y are the coordinates of the center point of the predicted bounding box. These are the width and height of the ground truth bounding box, respectively; w and h are the width and height of the predicted bounding box, respectively. It is a scaling factor used to control the size of the auxiliary box;
[0055] Predict the top corner of the auxiliary box The calculation method is similar to that of the ground truth bounding box. Formula (1) calculates the degree of intersection between the ground truth bounding box and the predicted bounding box by the relative position of the top corners of the two bounding boxes. Formula (2) represents the union of the two bounding boxes.
[0056] inter = (1);
[0057] union = (2);
[0058] in, It is the x-coordinate of the left boundary of the predicted auxiliary box. It is the x-coordinate of the right boundary of the predicted auxiliary box. It is the y-coordinate of the upper boundary of the predicted auxiliary box. It is the ordinate of the lower boundary of the predicted auxiliary box;
[0059] like Figure 3 As shown, the penalty factor P and the loss value are calculated using the improved loss function PloU, which is adapted to the target size by the penalty factor P. :
[0060] P = / 4;
[0061] = +1- ;
[0062] In the formula, It is the absolute value of the distance between the left edge of the predicted bounding box and the left edge of the ground truth bounding box; The absolute value of the distance between the right edge of the predicted bounding box and the right edge of the ground truth bounding box; It is the absolute value of the distance between the top edge of the predicted bounding box and the top edge of the ground truth bounding box; It is the absolute value of the distance between the bottom edge of the predicted bounding box and the bottom edge of the ground truth bounding box; Basic IoU loss;
[0063] Adjustment factor An improved loss function, PloU, is introduced to adjust the strength of the penalty term, specifically the loss value. for:
[0064] = +1- ;
[0065] In the formula, It is an introduction The subsequent PIOU loss value;
[0066] The improved loss function PloU and the inner-IoU of the auxiliary box are fused to obtain the inner-PIoU fused loss function. :
[0067] = +1-r +(1-r) ;
[0068] In the formula, r is the fusion weight.
[0069] Traditional IoU-based bounding box regression methods typically focus on improving model convergence by adding new loss terms, such as aspect ratio similarity, center point distance, and bounding box area ratio. While traditional IoU can accelerate convergence by measuring various differences between the ground truth bounding box and the predicted bounding box, it still fails to account for the potential loss of some samples during training. To address this issue, this invention employs a fusion of auxiliary bounding boxes and adjustment factors—Inner-IoU—aimed at handling such cases more effectively.
[0070] The Inner-IoU principle is as follows: the introduced auxiliary box has the same geometric center as its corresponding original box, and the size of the auxiliary box is controlled by the scaling factor ratio. When the ratio is less than 1, the auxiliary box is smaller than the original box, and when the ratio is greater than 1, the auxiliary box is larger than the original box. The value of ratio is usually between 0.5 and 1.5.
[0071] In summary, this invention introduces the GAMATtention attention mechanism based on YOLOv7. Through a three-dimensional attention structure, it captures cross-dimensional interactions in both channel and spatial dimensions, effectively suppressing noise interference in complex backgrounds. This allows the network to accurately focus on the defect features of small targets while reducing computational redundancy, significantly improving the model's detection accuracy and feature extraction capabilities. Furthermore, this invention applies an Inner-PIoU fusion loss function based on auxiliary boxes and adjustment factors. By introducing auxiliary boxes to refine the constraints on the original bounding boxes and optimize the regression process, and designing a dynamic adjustment factor to balance the contribution weights of high-quality and low-quality samples to the loss function, it effectively alleviates the problems of excessively large detection box sizes and unbalanced loss contributions among samples that are easily caused by the classic IoU loss function during training. These two improvements work synergistically to significantly enhance the model's ability to identify small target defects that are low-resolution, lack information, and are susceptible to noise interference, while maintaining the original detection speed. Ultimately, this achieves more accurate and robust intelligent defect detection for clean energy power station equipment, providing reliable technical support for practical operation and maintenance scenarios.
[0072] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely principles of the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the claimed invention. The scope of protection claimed by the appended claims and their equivalents is defined.
Claims
1. A method for addressing key equipment defects in clean energy power plants based on an improved YOLOv7, characterized in that: The method includes the following steps in sequence: (1) Take and collect images of key equipment in clean energy power stations, and perform annotation and preprocessing on the collected images to obtain preprocessed images and form a dataset. Divide the dataset into training set, test set and validation set. (2) Improve the YOLOv7 model: Based on the YOLOv7 model, introduce the GAMATtention attention module and replace the Inner-IoU loss function with the Inner-PIoU fusion loss function to obtain the improved YOLOv7 model; (3) The improved YOLOv7 model is trained using the training set to obtain the trained model, which is the object detection model; (4) Input the substation equipment image to be inspected into the target detection model, and output the location and defect information of the defects in the substation equipment image to be inspected.
2. The method for addressing key equipment defects in clean energy power plants based on improved YOLOv7 according to claim 1, characterized in that: Step (1) specifically refers to: using the open-source annotation tool LabelImg to draw the bounding box of the target object in the dataset and to annotate the type of the target object, and then dividing the annotated dataset into a training set, a test set and a validation set.
3. The method for addressing key equipment defects in clean energy power plants based on improved YOLOv7 according to claim 1, characterized in that: In step (2), the introduction of the GAMATtention attention module on the basis of the YOLOv7 model specifically means: adding the GAMATtention attention module between the SPCSPC module and the CBS module, with the input of the GAMATtention attention module connected to the output of the SPCSPC module, and the output of the GAMATtention attention module connected to the inputs of the CBS module and the ELAN module respectively.
4. The method for addressing key equipment defects in clean energy power plants based on improved YOLOv7 according to claim 1, characterized in that: In step (2), the Inner-PIoU fusion loss function specifically refers to: The Inner-IoU loss function introduces an auxiliary box that has the same geometric center as its original box. The size of the auxiliary box is controlled by a scaling factor. When the scaling factor is less than 1, the auxiliary box is smaller than the original box. When the scaling factor is greater than 1, the auxiliary box is larger than the original box. The scaling factor ranges from 0.5 to 1.
5. If the center points of the ground truth bounding box and the predicted bounding box are respectively and b The frame dimensions are respectively and Then the top corner of the actual auxiliary box The calculation formula is: = - , = + ; = - , = + ; in, It is the x-coordinate of the left boundary of the actual auxiliary box; It is the x-coordinate of the right boundary of the actual auxiliary box; It is the y-coordinate of the upper boundary of the actual auxiliary bounding box; It is the y-coordinate of the lower boundary of the actual auxiliary bounding box; x and y are the coordinates of the center point of the ground truth bounding box; x and y are the coordinates of the center point of the predicted bounding box. These are the width and height of the ground truth bounding box, respectively; w and h are the width and height of the predicted bounding box, respectively. It is a scaling factor used to control the size of the auxiliary box; Predict the top corner of the auxiliary box The calculation method is similar to that of the ground truth bounding box. Formula (1) calculates the degree of intersection between the ground truth bounding box and the predicted bounding box by the relative position of the top corners of the two bounding boxes. Formula (2) represents the union of the two bounding boxes. inter = (1); union = (2); in, It is the x-coordinate of the left boundary of the predicted auxiliary box. It is the x-coordinate of the right boundary of the predicted auxiliary box. It is the y-coordinate of the upper boundary of the predicted auxiliary box. It is the ordinate of the lower boundary of the predicted auxiliary box; The penalty factor P and the loss value are calculated using an improved loss function PloU adapted to the target size by a penalty factor P. : P = / 4; = +1- ; In the formula, It is the absolute value of the distance between the left edge of the predicted bounding box and the left edge of the ground truth bounding box; The absolute value of the distance between the right edge of the predicted bounding box and the right edge of the ground truth bounding box; It is the absolute value of the distance between the top edge of the predicted bounding box and the top edge of the ground truth bounding box; It is the absolute value of the distance between the bottom edge of the predicted bounding box and the bottom edge of the ground truth bounding box; Basic IoU loss; Adjustment factor An improved loss function, PloU, is introduced to adjust the strength of the penalty term, specifically the loss value. for: = +1- ; In the formula, It is an introduction The subsequent PIOU loss value; The improved loss function PloU and the inner-IoU of the auxiliary box are fused to obtain the inner-PIoU fused loss function. : = +1-r +(1-r) ; In the formula, r is the fusion weight.
5. An electronic device, comprising: processor; as well as A memory storing computer program instructions that, when executed by the processor, cause the processor to perform the method for addressing critical equipment defects in clean energy power plants based on any one of claims 1-4.
6. A computer-readable storage medium having stored thereon computer program instructions, which, when executed by a processor, cause the processor to perform the method for addressing critical equipment defects in clean energy power plants based on any one of claims 1-4.