Photovoltaic panel surface defect detection method based on improved YOLOv5s
By improving the YOLOv5s model, combining drone image acquisition and feature fusion technology, the efficiency and accuracy problems of photovoltaic panel surface defect detection are solved, and efficient and real-time defect detection is achieved, which is suitable for drone inspection.
Patent Information
- Application Number
- CN202510486155.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-17
- Publication Date
- 2025-07-22
AI Technical Summary
The prior art is difficult to efficiently detect surface defects of photovoltaic panels, resulting in a decrease in energy conversion efficiency and a shortened service life.
Using the improved YOLOv5s model, images are collected through drones, defect areas are segmented using GrabCut algorithm, feature extraction is performed by combining Ghost Net and SPPFCSPC modules, SIoU loss function optimization is used to decouple classification and regression tasks, and multi-scale feature fusion is generated to achieve high-precision defect detection.
It realizes high-precision and real-time detection of photovoltaic panel surface defects, improves detection accuracy and model generalization capabilities, reduces model complexity, and is suitable for real-time inspection of drones.
Smart Images

Figure CN120355691A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of artificial intelligence and photovoltaic operation and maintenance technology, and specifically relates to a photovoltaic panel surface defect detection method based on improved YOLOv5s, which is particularly suitable for multi-scale defect recognition and positioning in real-time drone inspection scenarios. Background Art
[0002] Photovoltaic power generation mainly uses photovoltaic panels to achieve the conversion of light energy into electrical energy. With the continuous development of photovoltaic power generation technology, the requirements for the performance and quality of photovoltaic panels are getting higher and higher. In the entire life cycle of photovoltaic panels from production and manufacturing, assembly and configuration to actual use, various defects will occur, which will lead to problems such as reduced energy conversion efficiency, system failures, and reduced service life of photovoltaic panels, thereby affecting the efficiency of the entire photovoltaic power generation system. Therefore, how to achieve accurate and efficient detection of various defects in photovoltaic panels has become one of the key core issues that need to be urgently solved in the field of photovoltaic power generation. Summary of the invention
[0003] In order to overcome the above-mentioned defects of the prior art, an embodiment of the present invention provides a photovoltaic panel surface defect detection method to solve the problems raised in the above-mentioned background technology.
[0004] To achieve the above object, the present invention provides the following technical solutions: A photovoltaic panel surface defect detection method based on improved YOLOv5s includes the following steps: Step S1: Data collection and preprocessing The surface images of photovoltaic panels were collected by using a visible light camera mounted on a drone, and the GrabCut algorithm was used to segment the defect areas to construct a data set containing four types of defects: hidden cracks, hot spots, stains, and damage. Adaptive anchor box calculation is performed on the input image, and Mosaic data enhancement technology is applied to integrate random scaling, rotation and color jittering operations to generate diverse training samples.
[0005] Step S2: Model construction and training Build a lightweight backbone network: Use Ghost Net to replace the original YOLOv5s's CSPDarknet53, and achieve feature map redundancy compression by stacking GhostBottleneck modules; Design a multi-scale feature fusion module: embed the SPPFCSPC pyramid pooling structure in the neck network, extract cross-scale features by connecting 5×5, 9×9, and 13×13 maximum pooling layers in series, and connect and fuse them with the cross-stage partial channel (CSPC); Optimize loss function: Use SIoU loss function instead of CIoU, and use angle loss term to constrain the direction matching between the predicted box and the real box; Decouple classification and regression tasks: In the detection head, independent branches are used to process classification confidence and bounding box coordinates, and 1×1 convolution is used to output category probability and positioning information respectively.
[0006] Step S3: Model training and optimization Initialize network parameters, use Adam optimizer, set the initial learning rate to 0.001, and dynamically adjust the learning rate with the cosine annealing strategy; Optimize network weights through back propagation of SIoU loss function and train until the loss function converges; Non-maximum suppression (NMS) is used to filter the prediction box, and the intersection over union (IoU) threshold is set to 0.5 and the confidence threshold is set to 0.25.
[0007] Step S4: Defect detection and output Input the photovoltaic panel image to be inspected into the trained model, and output the defect category, location coordinates and confidence level; Combined with drone positioning data, a heat map of photovoltaic panel defect distribution is generated, and priority areas requiring maintenance are marked.
[0008] In the step S1, the data enhancement also includes CutMix hybrid enhancement, which randomly cuts the defect areas of the two images and splices them to improve the robustness of the model to local defects.
[0009] In step S2, the channel expansion ratio of the Ghost Bottleneck module is 2:1, and the step size of the depthwise separable convolution (DWConv) is dynamically selected to be 1 or 2 according to the size of the feature map.
[0010] In step S4, the defect detection results are transmitted to the cloud platform in a lightweight format (JSON), and compared and analyzed with historical detection data to predict the defect evolution trend.
[0011] The beneficial effects of the present invention are as follows: The backbone network introduces Ghost Conv and GhostC3 modules of Ghost Net to reduce the complexity of the model and better handle cross-scale information.
[0012] The SPPFCSPC module is used as the pyramid pooling module to improve the diversity and fusion ability of feature extraction.
[0013] The original CIoU loss function is replaced by the SIoU loss function to achieve the relative displacement direction matching between the predicted box and the real box, accelerate the model convergence speed and improve the detection and positioning accuracy. The Decoupled Head is introduced to replace the original detection head, separate the classification task and the regression task, and improve the model accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] Figure 1 is the framework of the present invention.
[0015] Figure 2 is the detection effect diagram of traditional YOLO v5s.
[0016] Figure 3 is the detection effect diagram after the improvement of the present invention. Specific implementation manners
[0017] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0018] A photovoltaic panel surface defect detection method based on improved YOLOv5s includes the following steps: Step S1: Data collection and preprocessing Collect the surface images of the photovoltaic panel by using a visible light camera carried by a drone, segment the defect area by using the GrabCut algorithm, and construct a data set including four types of defects: hidden cracks, hot spots, stains, and breakages; Perform adaptive anchor box calculation on the input image, and apply the Mosaic data augmentation technology to fuse random scaling, rotation, and color jitter operations to generate diverse training samples.
[0019] Step S2: Model construction and training Construct a lightweight backbone network: Replace the CSPDarknet53 of the original YOLOv5s with Ghost Net, and realize redundant compression of feature maps through stacking of GhostBottleneck modules; Design a multi-scale feature fusion module: Embed the SPPFCSPC pyramid pooling structure in the neck network, extract cross-scale features by concatenating 5×5, 9×9, and 13×13 maximum pooling layers, and connect and fuse with cross-stage partial channels (CSPC); Optimize the loss function: Replace CIoU with the SIoU loss function, and constrain the direction matching between the predicted box and the ground truth box through the angular loss term; Decouple the classification and regression tasks: Use independent branches in the detection head to process the classification confidence and bounding box coordinates, and output the class probability and localization information through 1×1 convolution respectively.
[0020] Step S3: Model training and optimization Initialize the network parameters, use the Adam optimizer, set the initial learning rate to 0.001, and dynamically adjust the learning rate in conjunction with the cosine annealing strategy; Backpropagate and optimize the network weights through the SIoU loss function, and train until the loss function converges; Use non-maximum suppression (NMS) to filter the prediction boxes, set the intersection over union (IoU) threshold to 0.5, and the confidence threshold to 0.25.
[0021] Step S4: Defect detection and output Input the photovoltaic panel image to be detected into the trained model, and output the defect category, position coordinates, and confidence; Combine the UAV positioning data to generate a heat map of the photovoltaic panel defect distribution, and mark the priority areas that need to be maintained.
[0022] In the above step S1, data augmentation also includes CutMix hybrid augmentation, randomly cropping the defect areas of two images and stitching them together to improve the model's robustness to local defects.
[0023] In the above step S2, the channel expansion ratio of the Ghost Bottleneck module is 2:1, and the stride of the depthwise separable convolution (DWConv) is dynamically selected as 1 or 2 according to the feature map size.
[0024] In the above step S4, the defect detection results are transmitted to the cloud platform in a lightweight format (JSON), and compared and analyzed with the historical detection data to predict the defect evolution trend.
[0025] Example 1: Model training Use the F450 UAV to collect 12,911 photovoltaic panel images, and divide them into a training set, a validation set, and a test set according to 8:1:1; Scale the input images to 640×640, use Mosaic augmentation to generate 4-image stitching samples, and set the CutMix probability to 0.15; Training parameters: batch_size = 16, epochs = 300, and the cosine annealing period of the learning rate is 50 epochs; Test results: mAP = 72.85%, the number of parameters is 1.17×10 7 , and the model size is 14.3 MB.
[0026] Example 2: Edge deployment Convert the trained model to the TensorRT format and deploy it on the NVIDIA Jetson AGX Xavier platform; Process the 1080P video stream of the UAV in real time, with a detection delay ≤ 35 ms and a power consumption < 15 W; The output results are transmitted wirelessly to the operation and maintenance center via LoRa, and the defect alarm response time is less than 1 second.
[0027] The present invention uses a lightweight Ghost Net backbone network, introduces the SPPFCSPC spatial pyramid pooling module, and realizes efficient multi-scale feature extraction by enhancing the spatial pyramid pooling capability and introducing cross-stage partial channel connections. The detection head of the original model is replaced by a decoupled head to separate the classification and regression tasks, avoid error propagation, and enhance the generalization ability of the model. Finally, the CIoU loss function of the original model is replaced by the SIoU loss function to improve the running speed and efficiency of the model and avoid overfitting. The detection effect of the improved model is verified based on a new data set. Experimental results show that compared with the traditional YOLOv5s model, although the model complexity of the new model is slightly improved, the detection accuracy is improved, and the performance is better than the YOLO v7, YOLO v7X, and YOLO v7-w6 models.
[0028] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0029] Finally: The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for detecting surface defects of photovoltaic panels based on improved YOLOv5s, characterized in that, It includes the following steps: Step S1: Data collection and preprocessing Collect the surface images of the photovoltaic panels by using a visible light camera carried by a drone, segment the defective areas by using the GrabCut algorithm, and construct a dataset containing four types of defects: hidden cracks, hot spots, stains, and breakages; Perform adaptive anchor box calculation on the input images, and apply the Mosaic data augmentation technique, which integrates operations such as random scaling, rotation, and color jittering, to generate diverse training samples; Step S2: Model construction and training Construct a lightweight backbone network: Replace the CSPDarknet53 of the original YOLOv5s with Ghost Net, and achieve redundant compression of the feature maps through stacking of the GhostBottleneck modules; Design a multi-scale feature fusion module: Embed the SPPFCSPC pyramid pooling structure in the neck network, extract cross-scale features by concatenating the 5×5, 9×9, and 13×13 max pooling layers, and fuse them with the cross-stage partial channel connections; Optimize the loss function: Replace the CIoU with the SIoU loss function, and constrain the direction matching between the predicted box and the ground truth box through the angular loss term; Decouple the classification and regression tasks: In the detection head, use independent branches to process the classification confidence and the bounding box coordinates, and output the class probability and the localization information respectively through 1×1 convolutions; Step S3: Model training and optimization Initialize the network parameters, use the Adam optimizer, set the initial learning rate to 0.001, and dynamically adjust the learning rate in cooperation with the cosine annealing strategy; Optimize the network weights through backpropagation of the SIoU loss function until the loss function converges; Use non-maximum suppression (NMS) to filter the predicted boxes, set the intersection over union (IoU) threshold to 0.5, and the confidence threshold to 0.25; Step S4: Defect detection and output Input the photovoltaic panel images to be detected into the trained model, and output the defect category, location coordinates, and confidence; Combine the drone positioning data to generate a heat map of the photovoltaic panel defect distribution, and mark the priority areas that need maintenance.
2. The method according to claim 1, wherein: In the step S1, the data augmentation further includes CutMix hybrid augmentation, randomly cropping the defective areas of two images and splicing them to improve the robustness of the model to local defects.
3. The method according to claim 1, wherein: In the step S2, the channel expansion ratio of the Ghost Bottleneck module is 2:1, and the stride of the depthwise separable convolution (DWConv) is dynamically selected as 1 or 2 according to the feature map size.
4. The method according to claim 1, wherein: In the step S4, the defect detection results are transmitted to the cloud platform in a lightweight format (JSON), and compared and analyzed with the historical detection data to predict the defect evolution trend.