
1. Introduction and Background
The global push toward achieving carbon neutrality has significantly accelerated the adoption of renewable energy sources, with solar energy emerging as a frontrunner in this transition. As a core component of photovoltaic systems, the quality of solar panels directly determines the overall efficiency and stable operation of the entire power generation system. However, the manufacturing process of solar panels is highly complex and involves multiple coupled factors. Any anomaly during production can lead to surface defects on solar panels, which not only reduce the power generation efficiency and shorten the service life of the solar panels but may also cause the entire solar power system to malfunction. Therefore, timely identification of defective products and effective quality control have become crucial for improving production efficiency and reducing costs in the solar panel industry.
In the field of industrial quality inspection, how to ensure high defect recognition accuracy while effectively optimizing the computational complexity of the algorithm remains a key issue that constrains the real-time performance of the detection system. Existing detection methods often struggle to achieve a satisfactory balance between algorithmic complexity and detection precision. Furthermore, accurate identification of subtle surface defects on solar panels, such as fine scratches, cracks, and hot spots, still requires significant improvement. In response to these challenges, I have conducted in-depth research based on the YOLO (You Only Look Once) family of models and proposed two optimized algorithms for solar panel surface defect detection: LPV-YOLO (Light Photovoltaic-YOLO) and PVA-YOLO (Photovoltaic Attention-YOLO).
2. Related Work and Theoretical Foundations
Before the widespread adoption of deep learning, traditional solar panel defect detection methods mainly relied on machine vision and image processing techniques. These methods extracted features such as texture, color, and shape from solar panel surface images to identify defects. Texture analysis focuses on identifying irregular patterns, while color features help detect discoloration caused by pollution or material degradation. Shape-based methods are effective for clearly defined defects.
However, traditional methods have significant limitations. They depend heavily on manually designed features, which are difficult to fully capture the details of various defect types. Moreover, they are sensitive to noise caused by environmental variations such as lighting, weather, and viewing angles. When processing large-scale solar panel images, these methods often lead to high computational burdens.
The rapid development of deep learning, particularly Convolutional Neural Networks (CNNs), has revolutionized the field of computer vision and defect detection. CNNs can automatically extract and learn the most effective feature representations from large amounts of labeled data, avoiding the tedious process of manual feature design. Unlike traditional methods, CNNs maintain high detection performance under varying environmental conditions through multiple convolutional and pooling layers that automatically identify hidden high-level features in images.
The evolution of target detection algorithms has led to two main categories: two-stage and one-stage detectors. Two-stage algorithms, such as R-CNN, Fast R-CNN, and Faster R-CNN, first generate candidate regions and then classify and regress them in a second stage. These methods typically achieve higher accuracy but suffer from slower inference speeds. In contrast, one-stage detectors, including the YOLO series, SSD, and RetinaNet, directly predict object classes and bounding boxes from feature maps without a separate region proposal stage. They are favored for their impressive inference speed and are highly suitable for real-time applications.
Given that the core requirements for solar panel defect detection in industrial settings are high speed and balanced accuracy, I chose one-stage detectors as the basis for my research. Among them, the YOLO algorithm stands out due to its continuous evolution and optimization towards both speed and accuracy.
3. Lightweight Solar Panel Defect Detection Based on YOLOv5
3.1 Motivation and Approach
Existing solar panel defect detection models often suffer from excessive parameters, making it difficult to balance recognition speed and accuracy. To address this, I proposed a lightweight network called LPV-YOLO based on the YOLOv5s architecture. The primary goal was to significantly reduce model complexity while maintaining a high level of detection accuracy, thereby providing an efficient solution for industrial deployment.

3.2 Dataset Preparation and Augmentation
For my experiments, I used the PV-Multi-Defect dataset. This dataset originally contained a total of 1107 images with a pixel resolution of 600*600. Each image contains multiple defects of various scales, labeled into five categories: crack, scratch, hot spot, black edge, and interruption. The presence of diverse defect scales and types makes this dataset particularly challenging and suitable for evaluating my proposed methods.
I observed that the dataset had issues such as missed labels and imprecise annotations. To improve the quality of the dataset, I used the labelimg tool to re-annotate all images. This process increased the number of labels from 4,235 to 4,631, providing a more accurate and complete set of ground truth boxes for training.
To mitigate the problem of imbalanced samples and enhance the model’s generalization ability, I employed Cycle-GAN for data augmentation. Cycle-GAN can perform domain transfer without requiring paired images, using two generators and two discriminators with cycle consistency loss. The final dataset was expanded to 4,463 images with a total of 14,444 defect instances. The expanded dataset was split into training and validation sets in an 8:2 ratio, with the validation set entirely derived from the original data.
3.3 Architecture of LPV-YOLO
My proposed LPV-YOLO network enhances the YOLOv5s model through several strategic modifications. The architecture is composed of four main parts: input, backbone, neck, and detection head. The specific improvements are as follows:
1. Lightweight Backbone with Ghost Modules: To substantially reduce the model’s parameter count and computational cost, I redesigned the backbone network. First, I constructed a new CBM (Conv-Batch Normalization-Mish) module by integrating the Mish activation function. Mish is a smooth, non-monotonic activation function that offers better generalization performance and faster convergence compared to traditional activation functions like ReLU or Leaky ReLU. Its mathematical formulation is:
$$Mish(x) = x \times tanh(ln(1 + e^x))$$
Next, I combined the improved CBM module with the concept of Ghost modules to create two new components: GhostMConv and C3MGhost. The standard Ghost module splits convolution into two parts: a primary convolution to generate intrinsic feature maps, followed by a series of inexpensive linear operations to produce redundant feature maps, which are then concatenated. By replacing the standard convolutions in the backbone (except the first layer) with GhostMConv and the C3 modules with C3MGhost, I significantly decreased the model’s size and complexity. The computational cost of a standard convolution is:
$$C_{standard} = n \cdot h’ \cdot w’ \cdot c \cdot k \cdot k$$
The computational cost of the Ghost module is:
$$C_{ghost} = \frac{n}{s} \cdot h’ \cdot w’ \cdot c \cdot k \cdot k + (s-1) \cdot \frac{n}{s} \cdot h’ \cdot w’ \cdot d \cdot d$$
where $c$ is the number of input channels, $k$ is the kernel size of the standard convolution, $n$ is the number of output channels, $s$ is the number of linear operations per channel, and $d$ is the kernel size of the linear operation. The compression ratio is approximately equal to $s$. The overall module structure is shown in Figure 7.
2. Optimized Spatial Pyramid Pooling Module: To enhance multi-scale feature fusion and improve the representation capability of the output feature maps, I proposed a new module called Mish-SimAM-Spatial Pyramid Pooling-Fast (MSSPPF). This module integrates the Mish activation function and the parameter-free SimAM attention mechanism into the SPPF structure. The core idea of SimAM is to evaluate the importance of each neuron by optimizing an energy function, thereby enhancing the network’s attention to important features. The energy function is defined as:
$$e_t = \frac{4(\hat{\sigma}^2 + \lambda)}{(t – \hat{\mu})^2 + 2\hat{\sigma}^2 + 2\lambda}$$
where $t$ is the target neuron, $\hat{\mu}$ and $\hat{\sigma}^2$ are the mean and variance of all neurons in the channel, and $\lambda$ is the regularization coefficient. The final output feature is:
$$\tilde{X} = sigmoid\left(\frac{1}{E}\right) \odot X$$
MSSPPF effectively compensates for the accuracy loss caused by the lightweight design without increasing computational burden.
3. Attention Mechanism in Neck: To further enhance the model’s ability to extract subtle defects, I embedded the Squeeze-and-Excitation (SE) channel attention mechanism into the neck network. SE attention computes channel-wise weights to emphasize informative channels and suppress weaker ones. By applying SE after each C3MGhost module in the neck, the network can adaptively focus on the most critical channel features during the feature fusion process, significantly boosting detection accuracy.

3.4 Experiments and Results
The experiments were conducted on a Windows10 system with an NVIDIA GeForce RTX 2080Ti GPU, Python 3.8, and CUDA 11.1. The input image size was set to 640*640. The specific training parameters are shown in Table 2.
Evaluation Metrics: I evaluated the model’s performance using mean Average Precision (mAP), a crucial metric for object detection. I also considered the number of parameters, model size, computational cost (GFLOPs), and Frames Per Second (FPS) to assess the model’s efficiency and real-time capability.
To calculate Precision (P) and Recall (R), I use the following formulas:
$$P = \frac{TP}{TP + FP}, \quad R = \frac{TP}{TP + FN}$$
The mAP is the mean of the Average Precision (AP) for all classes:
$$AP = \int_0^1 P(R) dR, \quad mAP = \frac{1}{n} \sum_{i=1}^{n} AP_i$$
Results: The loss curves in Figure 13 show that the model converged well during training. The P-R curve in Figure 14 demonstrated that the LPV-YOLO model could achieve a mAP of 93.8%. The detection performance for individual defects is presented in Table 3. The model achieved high precision for relatively regular shapes like interruption (99.1%) and black edge (97.1%). The detection rate for irregular defects like crack and hot spot was also above 92%. The scratch defect, being very subtle, achieved a detection accuracy of 87%.
Ablation Study: I conducted ablation experiments to verify the effectiveness of each proposed module, with results shown in Table 4.
| Model | mAP/% | Params/M | Model Size/MB | GFLOPs | FPS |
|---|---|---|---|---|---|
| YOLOv5s | 94.4 | 7.23 | 13.70 | 16.5 | 91.74 |
| YOLOv5s+MGhost | 92.1 | 3.70 | 7.42 | 8.2 | 67.11 |
| YOLOv5s+MGhost+MSSPPF | 93.3 | 3.70 | 7.36 | 8.2 | 65.52 |
| LPV-YOLO | 93.8 | 3.71 | 7.40 | 8.3 | 70.42 |
The ablation study confirms the effectiveness of my improvements. The MGhost module dramatically reduced the model’s parameters, size, and computation. The MSSPPF and SE modules each contributed to increasing the mAP without significant computational overhead. Compared with the original YOLOv5s, LPV-YOLO reduced parameters by 49%, model size by 46%, and computation by 50%, while experiencing only a 0.6% decrease in mAP.
Comparison with State-of-the-Art: I compared LPV-YOLO against several other established models, including YOLOv7, SSD, RetinaNet, Faster-RCNN, and various YOLO versions. The results in Table 5 show that LPV-YOLO achieves a superior trade-off between accuracy and efficiency. It has the smallest parameter count, model size, and computational cost while maintaining a high mAP of 93.8% and a real-time FPS of 70.4.
| Model | mAP/% | Params/M | Model Size/MB | GFLOPs | FPS |
|---|---|---|---|---|---|
| YOLOv5s | 94.4 | 7.23 | 13.7 | 16.5 | 91.7 |
| GBH-YOLOv5 | 93.2 | 7.24 | 12.4 | 23.8 | 68.6 |
| Wang | 92.6 | 3.22 | – | 8.3 | 236 |
| YOLOv7 | 88.0 | 9.33 | 19.0 | 26.7 | 107.5 |
| SSD300 | 77.7 | 34.30 | 90.0 | 51.6 | 71.0 |
| RetinaNet | 72.2 | 41.90 | 139.0 | 212.0 | 42.9 |
| Faster-RCNN | 87.8 | 43.44 | 185.1 | 172.3 | 27.0 |
| YOLOv8 | 92.7 | 11.2 | 22.4 | 28.6 | 102.0 |
| YOLOv9c | 93.7 | 98.0 | 98 | 82.6 | 96.0 |
| YOLOv10s | 90.6 | 8.2 | 32.8 | 26.8 | 167.2 |
| LPV-YOLO | 93.8 | 3.71 | 7.4 | 8.3 | 70.4 |
The LPV-YOLO model successfully addresses the challenge of balancing detection accuracy and model complexity, making it highly suitable for solar panel defect detection in industrial scenarios where computational resources may be limited.
4. Solar Panel Defect Detection with Joint Attention Mechanism
4.1 Motivation and Approach
While LPV-YOLO achieved a good balance between speed and accuracy, the detection of subtle defects on solar panels remained a bottleneck. The presence of fine scratches, small cracks, and other minor imperfections significantly impacted the overall detection performance. To address this challenge and further improve the detection accuracy, I shifted my research focus to the more recent YOLOv9 architecture and proposed the PVA-YOLO model. The main contributions here are the adaptive anchor generation, a novel feature processing module, and a parallel joint attention mechanism.
4.2 Architecture of PVA-YOLO
1. K-means++ Clustering for Anchors: The YOLOv9 architecture originally employs an anchor-free detection strategy. However, solar panel defects often have extreme aspect ratios and vary greatly in size. To better adapt to these characteristics, I introduced the k-means++ clustering algorithm to generate anchor boxes that are more tailored to the distribution of solar panel defects in the dataset. This algorithm initializes cluster centers in a smart way, leading to more stable and accurate clustering results. The distance and probability calculations are as follows:
$$D(x) = \min_{c \in C} \|x – c\|^2$$
$$P(x) = \frac{D^2(x)}{\sum_{x’ \in X} D^2(x’)}$$
By generating 9 anchor boxes matched to the ground truth sizes, the model can converge faster and produce more accurate detection boxes, especially for irregular defects like black edges and interruptions. The resulting anchor sizes are presented in Table 6.
| Width | 20 | 21 | 21 | 22 | 50 | 64 | 122 | 123 | 146 |
|---|---|---|---|---|---|---|---|---|---|
| Height | 34 | 62 | 119 | 202 | 44 | 109 | 50 | 171 | 588 |
2. Improved Feature Extraction Module (RepNCSPELAN_TCA): To enhance the model’s ability to extract crucial features, especially for small-scale defects, I designed a novel feature processing module. First, I constructed a Three Convolution Branch Reparameter Module (RepConvN_T) by parallelly connecting a 1*1 convolution and two 3*3 convolutions, incorporating the concept of reparameterization. In the training phase, this module uses multiple branches for better learning; in the inference phase, these branches can be reparameterized into a single convolution, reducing computation without sacrificing performance.
Based on RepConvN_T, I built Three Convolution Branch Reparameter Bottleneck (RepNBottleneck_T) and Three Convolution Branch Reparameter CSP (RepNCSP_T). Finally, I proposed the RepNCSPELAN_TCA module, which consists of two RepNCSP_T modules and standard convolutions arranged in parallel and sequential connections. To better capture fine details, a Coordinate Attention (CA) mechanism is incorporated before the feature output. CA captures positional information, allowing the network to extract more fine-grained and rich features which is particularly beneficial for detecting small solar panel defects.
3. Parallel Joint Attention Module (PAM): To simultaneously enhance the representation of channel and spatial features, I proposed a Parallel Attention Module (PAM). This module combines a Channel Attention mechanism (ChannelAtt) and a Spatial Attention Mechanism (SAM) in parallel. The ChannelAtt module uses both global average pooling and max pooling to derive channel-wise statistics, followed by convolutional and activation layers to generate attention weights. The SAM module focuses on significant spatial regions in the image. By combining them, PAM can effectively capture both “what” (channel) and “where” (spatial) are important, leading to more comprehensive feature refinement.

4.3 Experiments and Results
The experiments for PVA-YOLO were conducted on a Windows10 system with an NVIDIA GeForce RTX 4090 GPU, Python 3.8, and CUDA 11.8. The input image size was set to 640*640, and the training parameters remained consistent with the previous experiment, as shown in Table 7.
The improvements resulted in a significant performance leap. The loss function curves in Figure 20 demonstrate stable convergence during training, with box_loss, cls_loss, and dfl_loss stabilizing below 1.3. The P-R curves in Figure 22 and the detection results in Figure 21 confirm that the PVA-YOLO model accurately detects all five types of defects on solar panels.
Ablation Study: I performed a comprehensive ablation study, the results of which are detailed in Table 8.
| YOLOv9 | K-means++ | RepNCSPELAN_TCA | PAM | crack | hot spot | black edge | scratch | interruption | mAP@0.5/% | mAP@0.5:0.95/% |
|---|---|---|---|---|---|---|---|---|---|---|
| ✓ | 95.0 | 91.0 | 97.5 | 87.1 | 97.8 | 93.7 | 68.9 | |||
| ✓ | ✓ | 96.7 | 90.0 | 97.6 | 89.9 | 97.5 | 94.3 | 72.7 | ||
| ✓ | ✓ | 97.8 | 91.4 | 99.0 | 91.4 | 98.8 | 95.7 | 70.0 | ||
| ✓ | ✓ | 97.7 | 91.6 | 99.3 | 90.2 | 98.8 | 95.5 | 74.4 | ||
| ✓ | ✓ | ✓ | 98.2 | 91.7 | 99.4 | 91.7 | 98.9 | 96.0 | 76.1 | |
| ✓ | ✓ | ✓ | 97.7 | 91.3 | 99.4 | 92.0 | 98.8 | 95.9 | 75.5 | |
| ✓ | ✓ | ✓ | 98.1 | 92.7 | 99.2 | 92.2 | 98.9 | 96.2 | 76.2 | |
| ✓ | ✓ | ✓ | ✓ | 98.5 | 92.7 | 99.2 | 92.2 | 98.6 | 96.3 | 76.5 |
The ablation study confirms that each improvement contributes positively to the overall performance. The k-means++ anchor generation improved mAP@0.5 by 0.6% and mAP@0.5:0.95 by 3.8%. The RepNCSPELAN_TCA module increased mAP@0.5 by 2.0% and mAP@0.5:0.95 by 1.1%. The PAM improved mAP@0.5 by 1.8% and mAP@0.5:0.95 by 5.5%. The combination of all improvements in PVA-YOLO resulted in a substantial increase, with mAP@0.5 improving by 2.6% (from 93.7% to 96.3%) and mAP@0.5:0.95 improving by 7.6% (from 68.9% to 76.5%), demonstrating a significant advancement in solar panel defect detection capability.
Comparison with State-of-the-Art: I benchmarked PVA-YOLO against several other mainstream detection models and the results are presented in Table 9.
| Model | Precision/% | Recall/% | F1/% | mAP@0.5/% | mAP@0.5:0.95/% |
|---|---|---|---|---|---|
| YOLOv5 | 88.6 | 91.2 | 90.0 | 93.8 | 65.1 |
| YOLOX | 81.6 | 86.5 | 83.9 | 80.8 | 49.8 |
| SSD | 75.6 | 81.8 | 78.6 | 77.7 | 45.4 |
| Faster-RCNN | 84.5 | 82.8 | 65.2 | 87.8 | 60.8 |
| YOLOv9 | 88.9 | 89.2 | 89.0 | 93.7 | 68.9 |
| YOLOv7 | 88.4 | 90.7 | 89.5 | 94.2 | 66.8 |
| YOLOv8 | 87.5 | 84.7 | 86.1 | 92.7 | 65.6 |
| YOLOv10 | 85.3 | 83.7 | 84.5 | 90.6 | 53.9 |
| YOLOv11 | 85.0 | 84.3 | 84.6 | 89.7 | 52.8 |
| GHB-YOLO | 90.2 | 89.8 | 90.0 | 93.2 | 66.3 |
| PB-YOLO | 91 | 93.5 | 92.2 | 96.5 | 73.1 |
| YOLOv5-scSE | 92.7 | 91.3 | 92.0 | 96.1 | 75.4 |
| PVA-YOLO | 91.6 | 93.4 | 92.5 | 96.3 | 76.5 |
PVA-YOLO outperforms all other models in terms of mAP@0.5:0.95, indicating its superior capability in precise localization and detection, which is particularly crucial for evaluating model performance for small and subtle defects on solar panels. It also achieves the highest F1 score, demonstrating a strong overall balance between precision and recall. This validates that PVA-YOLO provides a more effective and reliable solution for high-precision solar panel inspection.
5. Conclusion and Future Perspectives
In this research, I have dedicated my efforts to advancing the field of solar panel surface defect detection by leveraging the YOLO algorithm family. The primary challenge has been to devise methods that not only accurately identify defects but also offer practical and efficient solutions for industrial applications.
Summary of Work: I developed two powerful detection models. The first, LPV-YOLO, is a lightweight detector built on YOLOv5s. By innovatively combining Ghost modules with the Mish activation function to create GhostMConv and C3MGhost modules, I successfully compressed the model by roughly half in parameters and computation, while maintaining a high detection accuracy of 93.8% mAP. The introduction of the MSSPPF module and SE attention effectively mitigated the precision loss typically associated with model lightweighting. LPV-YOLO demonstrates that significant efficiency gains are achievable without a substantial sacrifice in accuracy, making it well-suited for deployment in resource-constrained industrial environments.
The second model, PVA-YOLO, focused on elevating the detection accuracy of solar panel defects, especially subtle ones. Built upon the YOLOv9 architecture, PVA-YOLO integrates three key enhancements: adaptive anchor generation through k-means++ clustering, a novel feature extraction module RepNCSPELAN_TCA that combines reparameterization with coordinate attention, and a parallel joint attention mechanism PAM. These components synergistically improved the model’s ability to focus on key features across channel and spatial dimensions. The experimental results showed a remarkable improvement, with mAP@0.5 rising to 96.3% and mAP@0.5:0.95 surging to 76.5%. This signifies a considerable leap forward in the accurate detection of complex and fine defects on solar panels.
Future Directions: While these findings mark significant progress, there are still numerous avenues for future exploration. First, bridging the gap between algorithmic development and real-world industrial deployment is crucial. Future work should focus on optimizing the algorithms for integration with various hardware platforms, ensuring compatibility and efficient data handling. Additionally, robustness in challenging environments, such as uneven illumination, contamination, and reflections, needs to be addressed to guarantee stable performance in actual factory settings. Second, integrating these detection systems with Internet of Things (IoT) technology could enable a comprehensive, multi-layered monitoring network for solar panels. This would facilitate earlier detection and timely maintenance, ultimately extending the lifespan of the panels. As new technologies continue to merge and evolve, the field of solar panel surface defect detection is poised for significant advancements, contributing to the global push for sustainable and efficient solar energy utilization.
