With the increasing severity of global ecological challenges and the growing demand for renewable energy, solar energy has become a critical component in the transition toward sustainable power systems. Solar panels, as the core components of photovoltaic systems, directly determine the stability and efficiency of power generation. However, defects on the surface of solar panels, such as scratches, cracks, hotspots, and electrical disconnection, can significantly degrade their performance and shorten their lifespan. Therefore, accurate and real-time detection of these defects is of great importance for quality control in the manufacturing process and for the long-term operation of photovoltaic systems.

Traditional defect detection methods for solar panels mainly rely on manual inspection, which is time-consuming, labor-intensive, and strongly dependent on the workers’ experience. Moreover, subtle defects such as micro-cracks and faint scratches are often difficult to identify through the naked eye, leading to a high rate of missed detections. In recent years, deep learning methods, especially convolutional neural networks (CNNs), have been widely applied to defect detection tasks and have achieved remarkable performance. Among these, the YOLO (You Only Look Once) series algorithms have become the mainstream approach for real-time object detection due to their excellent trade-off between speed and accuracy.
In this article, I present my research on optimizing defect detection algorithms for solar panels based on the YOLO framework. I propose two improved detection algorithms, namely LPV-YOLO (Light Photovoltaic-YOLO) and PVA-YOLO (Photovoltaic Attention-YOLO), to address the challenges of balancing detection accuracy with model complexity and improving the detection of subtle defects on the surface of solar panels. In this article, I will provide a comprehensive overview of my research, including the theoretical background, the design of the proposed methods, and the experimental results.
1. Introduction
Solar panels are the most important components in photovoltaic systems, as they directly convert solar energy into electricity. Their quality plays a decisive role in the efficiency and reliability of the entire photovoltaic system. During the manufacturing process, various factors can cause surface defects such as structural damage, scratches, hot spots, black edges, and electrical disconnection. These defects not only reduce the power generation efficiency but also increase the risk of system failure. Therefore, it is necessary to develop accurate and efficient defect detection methods to ensure the quality of solar panels.
Existing defect detection methods can be roughly divided into traditional image processing techniques and deep learning-based methods. Traditional methods, which include texture analysis, color-based detection, and shape-based feature extraction, often fail to achieve high accuracy in complex and diverse scenarios due to their reliance on manually designed features. In contrast, deep learning methods automatically learn feature representations from large datasets, demonstrating superior accuracy and robustness. However, many existing deep learning models for detecting defects in solar panels are computationally heavy, which hinders their deployment in real-time industrial applications.
To solve the aforementioned problems, my research focuses on two aspects: reducing model complexity while preserving detection accuracy, and improving the detection performance for small and subtle defects. To address the first issue, I design a lightweight network based on YOLOv5s, known as LPV-YOLO. To tackle the second issue, I improve YOLOv9 by introducing a parallel attention mechanism, resulting in PVA-YOLO. In the following sections, I will detail the theoretical foundations, the architecture designs, and the experimental validations of these two methods.
2. Theoretical Foundations
This section briefly describes the basic concepts and structures involved in deep learning-based object detection, including convolutional neural networks, activation functions, and the YOLO family of algorithms.
2.1 Convolutional Neural Networks
Convolutional neural networks (CNNs) are the fundamental building blocks of modern deep learning models for computer vision. A typical CNN consists of four main types of layers: the input layer, convolutional layers, pooling layers, fully connected layers, and activation function layers.
The input layer receives raw pixel values and usually performs normalization to scale pixel values to a suitable range. The convolutional layer applies a set of learnable filters (kernels) to the input feature map to extract spatial features. Each filter slides across the image and computes the dot product between the kernel weights and the local regions of the input, producing feature maps that highlight specific patterns. Pooling layers usually follow convolutional layers to reduce the spatial dimensions of the feature maps. This down-sampling operation helps decrease computational complexity and control overfitting. Fully connected layers are typically placed at the end of the network to perform high-level reasoning and output the final predictions. Activation functions introduce non-linearity into the network, enabling it to learn complex patterns in the data.
Several activation functions are commonly used:
1. The Sigmoid function maps input values to the range (0, 1) and is widely used in binary classification tasks. Its mathematical definition is:
$$\sigma(x) = \frac{1}{1 + e^{-x}}$$
However, it suffers from the gradient vanishing problem for very large or very small input values.
2. The Tanh function maps inputs to the range (-1, 1), defined as:
$$\tanh(x) = \frac{e^{x} – e^{-x}}{e^{x} + e^{-x}}$$
While it partially alleviates the saturation issue, it still experiences gradient disappearance in deeper networks.
3. The ReLU function, defined as
$$\text{ReLU}(x) = \max(0, x)$$
is the most popular activation function in deep learning. It is computationally efficient and effectively resolves the gradient vanishing problem. However, it may cause dead neurons.
4. Leaky ReLU, with a small negative slope a, mitigates the dead-neuron problem:
$$\text{LeakyReLU}(x) = \max(ax, x)$$
5. The Mish activation function used in my research is a smooth and non-monotonic activation function that has been shown to improve model convergence and generalization. It is defined as:
$$\text{Mish}(x) = x \cdot \tanh(\ln(1 + e^{x}))$$
This function helps to avoid overfitting and stabilize the training process, which is essential for building accurate and reliable detection models.
2.2 Object Detection Frameworks
Object detection methods based on deep learning can be categorized into two-stage and one-stage approaches. Two-stage methods, such as R-CNN, Fast R-CNN, and Faster R-CNN, first generate a set of candidate regions and then classify and refine them. These methods achieve high accuracy but are computationally expensive. One-stage methods, such as the YOLO series and SSD, predict object classes and locations directly from the entire image in a single forward pass, leading to faster inference speeds. Among them, the YOLO family has evolved significantly, with each iteration introducing architectural improvements that increase both accuracy and speed.
The YOLOv5 model, which I use as the baseline for building LPV-YOLO, consists of four main parts: the input end, the backbone network, the neck network, and the prediction head. The backbone network, typically CSPDarknet53, is responsible for extracting feature maps at different scales. The neck, which usually adopts the FPN-PAN structure, fuses features from different layers to enhance multi-scale detection. The prediction head uses multiple detection layers to predict the classes and bounding boxes of objects.
YOLOv9, on the other hand, utilizes Programmable Gradient Information (PGI) and Generalized Efficient Layer Aggregation Networks (GELAN), which can effectively solve the information bottleneck problem and further improve the detection accuracy. These advancements make YOLOv9 an ideal base model for high-precision defect detection tasks. In the following sections, I will discuss how I optimize these baseline models to achieve better detection results for solar panels.
3. LPV-YOLO: A Lightweight Defect Detection Model for Solar Panels
In this section, I describe my first proposed algorithm, LPV-YOLO, which aims to reduce the model complexity of the defect detection algorithm while maintaining high detection accuracy. The architecture is built upon YOLOv5s and incorporates three key improvements: the GhostMConv and C3MGhost modules for lightweight feature extraction, the MSSPPF module to enhance feature representation, and the SE attention mechanism embedded in the neck network to improve the detection of subtle defects.
3.1 Lightweight Backbone Network
To reduce the number of parameters and computational cost, I design the lightweight modules GhostMConv and C3MGhost based on the Ghost module. The Ghost module decomposes a traditional convolution into two stages: the first stage uses a small number of standard convolutions to generate intrinsic feature maps, and the second stage applies a series of cheap linear operations to generate additional ghost feature maps. This significantly reduces the computational redundancy. The structure of the Ghost module can be summarized as follows:
For an input feature map with channel size c, height h and width w, and a standard convolution kernel of size k, the computation cost of a standard convolution is:
$$\text{Cost}_{std} = n \cdot h’ \cdot w’ \cdot c \cdot k \cdot k$$
where n is the output channel number and h’, w’ are the output height and width. In contrast, the computational cost of the Ghost module, which produces n feature maps with s times acceleration, can be expressed as:
$$\text{Cost}_{ghost} = \frac{n}{s} \cdot h’ \cdot w’ \cdot c \cdot k \cdot k + \frac{n}{s}(s-1) \cdot h’ \cdot w’ \cdot d \cdot d$$
where d is the kernel size of the linear operation. The compression ratio r is given by:
$$r = \frac{\text{Cost}_{std}}{\text{Cost}_{ghost}} \approx \frac{s \cdot c}{s + c – 1} \approx s$$
This indicates that the Ghost module can reduce the computational cost by a factor approximately equal to s.
In my implementation, I replace the activation function of the original Conv module with the Mish activation function to construct the CBM element. Then, I integrate the Ghost module with the CBM structure to form the GhostMConv and C3MGhost modules. The GhostMConv replaces the original Convolution module in YOLOv5s, while the C3MGhost replaces the C3 module. These replacements greatly reduce the parameter volume and simplify the model architecture.
3.2 Improved Spatial Pyramid Pooling with SimAM
To compensate for the accuracy loss introduced by the lightweight network, I improve the Spatial Pyramid Pooling – Fast (SPPF) module. The traditional SPPF module uses multiple max-pooling layers in series to enlarge the receptive field. However, max-pooling may lead to the loss of fine-grained details. In my design, I introduce Mish activation and a parameter-free attention module, SimAM, to the SPPF structure, forming the MSSPPF (Mish-SimAM-Spatial Pyramid Pooling-Fast) module.
SimAM attention evaluates the importance of each neuron by an energy function, which is defined as:
$$e_{t} = \frac{4 \cdot (\hat{\sigma}^{2} + \lambda)}{(t – \hat{\mu})^{2} + 2 \cdot \hat{\sigma}^{2} + 2 \cdot \lambda}$$
where t is the target neuron, μ̂ and σ̂² are the mean and variance of all neurons in the channel. A lower energy value e_t indicates that the neuron t is more distinct and therefore more important. The output feature is then weighted using a sigmoid function:
$$\tilde{X} = X \cdot \text{sigmoid}\left( \frac{1}{E} \right)$$
where E represents the energy matrix across channels and spatial dimensions. The MSSPPF module achieves better multi-scale feature interaction without increasing the number of parameters or computational burden.
3.3 SE Attention Mechanism in the Neck Network
I further embed the Squeeze-and-Excitation (SE) attention mechanism into the neck network of the model, specifically after every C3MGhost module. The SE block adaptively recalibrates channel-wise feature responses by modeling the interdependencies between channels. It consists of a squeeze operation (global average pooling) that aggregates information from each channel, and an excitation operation (two fully connected layers) that generates the attention weights. The formula is described below:
$$s = \sigma (W_2 \cdot \delta (W_1 \cdot z))$$
where z is the result of the global average pooling, W1 and W2 are the weights of the two fully connected layers, δ is the ReLU activation function, and σ is the sigmoid function. The final output is obtained by scaling the original feature map with the attention weights:
$$\tilde{X} = s \cdot X$$
This mechanism enhances the network’s ability to focus on the most informative channels, thereby improving the accuracy of detecting subtle defects on solar panels.
3.4 Experiments and Results
The experiments are conducted on the PV-Multi-Defect dataset, which originally contains 1,107 images. After inspecting the dataset, I find that some labels are inaccurate or missed, so I relabel the dataset using LabelImg. To address the issue of sample imbalance and insufficient data, I employ Cycle-GAN to generate an augmented dataset. After augmentation, the dataset expands to 4,463 images, including 14,444 labeled defects. The distribution of five defect types is presented below.
| Defect Type | Amplified Sample Image (described) | Description |
|---|---|---|
| Breakage | Irregular black patterns | Often accompanied by scratches |
| Scratch | Thin lines similar to background | Weak edges and subtle appearance |
| Hot Spot | Bright white block areas | Often appears in clusters |
| Black Edge | Narrow black lines | Usually at the edge of cells |
| Disconnection | Large rectangular dark regions | Regionally distributed |
The training parameters are configured as follows:
| Training Parameter | Value |
|---|---|
| Optimizer | SGD |
| Epoch | 300 |
| Batch Size | 16 |
| Momentum | 0.937 |
| Initial Learning Rate | 0.001 |
| Weight Decay | 0.0005 |
| IoU Threshold | 0.5 |
To evaluate the performance, I use metrics including the mean Average Precision (mAP), the number of parameters, the model size, the floating-point operations (GFLOPs), and the frame rate (FPS) for real-time measurement. The mAP is calculated as the area under the Precision-Recall curve, averaged over all defect classes:
$$mAP = \frac{1}{n} \sum_{i=1}^{n} AP_i$$
The experimental results for the detection of each defect type are listed below.
| Defect Type | Precision/% | Recall/% | mAP@0.5/% | mAP@0.5:0.95/% |
|---|---|---|---|---|
| Breakage | 88.7 | 89.7 | 93.2 | 65.7 |
| Hot Spot | 87.6 | 87.8 | 92.5 | 60.3 |
| Black Edge | 91.1 | 85.5 | 97.1 | 62.7 |
| Scratch | 80.1 | 85.7 | 87.0 | 46.4 |
| Disconnection | 96.0 | 96.9 | 99.1 | 90.5 |
| All Defects | 88.7 | 91.1 | 93.8 | 65.1 |
To demonstrate the effectiveness of each module, I conduct ablation experiments. The results are shown in the following table, where BL represents the baseline YOLOv5s model and MGhost denotes the combination of GhostMConv and C3MGhost modules.
| Model | mAP/% | Params/M | Model Size/MB | GFLOPs | FPS |
|---|---|---|---|---|---|
| BL | 94.4 | 7.23 | 13.70 | 16.5 | 91.7 |
| BL + MGhost | 92.1 | 3.70 | 7.42 | 8.2 | 67.1 |
| BL + MGhost + MSSPPF | 93.3 | 3.70 | 7.36 | 8.2 | 65.5 |
| LPV-YOLO | 93.8 | 3.71 | 7.40 | 8.3 | 70.4 |
As can be observed, the proposed LPV-YOLO network significantly reduces the number of parameters, model size, and computational load by approximately half, while decreasing the detection accuracy by only 0.6% compared to the baseline. The final model achieves 93.8% mAP with 3.71M parameters, 8.3 GFLOPs, and 70.4 FPS. This proves that LPV-YOLO successfully balances detection speed and accuracy for the surface inspection of solar panels, making it well-suited for real-time industrial deployment under limited hardware conditions.
4. PVA-YOLO: A Joint Attention Mechanism-based Defect Detection Method
Although LPV-YOLO effectively reduces model complexity, its detection accuracy for small and subtle defects remains limited. To further boost the overall detection accuracy of solar panel defect detection, especially for small defects, I propose my second algorithm, PVA-YOLO, based on the YOLOv9 architecture.
4.1 Anchor Generation with K-means++
The solar panel defect dataset contains various defect sizes, including very narrow and elongated shapes. To achieve better alignment between the prior boxes and the actual defects, I employ the K-means++ clustering algorithm to generate appropriate anchor boxes. The K-means++ algorithm chooses the initial cluster centers wisely to improve the clustering results. The algorithm first selects a random sample as the first center, and then chooses subsequent centers with a probability proportional to the squared distance from the nearest existing center. Its probability formula is:
$$P(x) = \frac{D(x)^2}{\sum_{x’ \in X} D(x’)^2}$$
where D(x) is the distance between sample x and its nearest center.
In this way, I obtain a set of nine anchor boxes that match the defect scale distribution of the dataset. These anchors improve the initial matching between predicted boxes and ground truths, thereby accelerating the training process and improving the detection accuracy. The generated anchor box sizes are listed below.
| Width | 20 | 21 | 21 | 22 | 50 | 64 | 122 | 123 | 146 |
|---|---|---|---|---|---|---|---|---|---|
| Height | 34 | 62 | 119 | 202 | 44 | 109 | 50 | 171 | 588 |
4.2 Improved Feature Extraction Module
To better extract feature information, especially for small defects, I redesign the feature processing structure of YOLOv9. I construct a three-branch reparameterization module, called RepConvN_T, by combining a 1×1 convolution with two 3×3 convolutions in parallel. In the training phase, the model learns from multiple branches to enhance its learning capability, while during inference, these branches are fused into a single convolution to reduce computational cost and memory usage.
Based on this module, I further construct two additional modules: RepNBottleneck_T and RepNCSP_T. Finally, I integrate these structures with a coordinate attention mechanism to create the novel feature processing module RepNCSPELAN_TCA. By leveraging the coordinate attention, the module can capture both long-range dependencies and location information, which improves the model’s capacity to detect fine defects on solar panels. This design enriches the feature representation and enhances detection accuracy.
4.3 Parallel Joint Attention Module
In this section, I introduce a parallel joint attention mechanism, named PAM, which integrates channel attention and spatial attention in parallel to enhance the model’s ability to capture fine-grained features. The channel attention block extracts channel statistics through global average pooling and global max pooling, followed by fully connected layers and activation functions, generating weights for each channel. Its output can be expressed as:
$$M_c = \sigma \left( W_1 \cdot \delta(W_0 \cdot z_{avg}) + W_1 \cdot \delta(W_0 \cdot z_{max}) \right)$$
The spatial attention block aggregates channel information through two pooling operations and applies a convolution layer to generate the spatial attention map, defined as:
$$M_s = \sigma \left( f^{3\times3}([AvgPool(F); MaxPool(F)]) \right)$$
Instead of using a conventional sequential connection, I connect these two attention modules in parallel. The final output is computed by adding the input feature map to the weighted sum of the two attention outputs:
$$F’ = F + \lambda_1 \cdot M_c \otimes F + \lambda_2 \cdot M_s \otimes F$$
where λ1 and λ2 are learnable scale parameters. By considering both channel and spatial information simultaneously, the PAM mechanism enables the model to identify key features more effectively, further improving the detection of small and subtle defects.
4.4 Experimental Setup and Results
The experiments are carried out on the same augmented dataset. I use P, R, F1 score, mAP@0.5, and mAP@0.5:0.95 as evaluation metrics. The training configuration remains consistent with the experimental settings described earlier, with an input size of 640 × 640, SGD optimizer, 300 epochs, and a batch size of 16.
The loss functions of the training process are monitored. The total loss is composed of the bounding box regression loss, classification loss, and distribution focal loss. The results show that the loss values decrease rapidly during the initial epochs and then stabilize around epoch 300, indicating that the model converges properly.
To validate the effectiveness of each improvement, I conduct a series of ablation experiments. In the table below, ① denotes the K-means++ generated anchors, ② represents the RepNCSPELAN_TCA module, and ③ stands for the PAM attention module.
| YOLOv9 | ① | ② | ③ | Breakage | Hot Spot | Black Edge | Scratch | Disconnection | 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 |
As shown in the table, all three improvements contribute positively to the detection performance. The final PVA-YOLO model achieves a mAP@0.5 of 96.3%, an improvement of 2.6% over the baseline YOLOv9, and a mAP@0.5:0.95 of 76.5%, which is an increase of 7.6%. In particular, the scratch defects, which are the most difficult to detect, achieve an improvement of 5.1% in average precision.
I also compare PVA-YOLO with other state-of-the-art detection models, including SSD, Faster-RCNN, YOLOv5, YOLOv7, YOLOv8, YOLOX, YOLOv10, YOLOv11, and two custom models GHB-YOLO and PB-YOLO. The comparison results are as follows:
| Model | Precision/% | Recall/% | F1 Score/% | 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.0 | 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 |
From the results, it is evident that PVA-YOLO achieves the best overall performance among all compared methods in terms of precision, recall, F1 score, and the two mAP metrics. This demonstrates that the improvements introduced in PVA-YOLO significantly boost the detection capability of solar panel defects across all categories. In particular, the integration of the joint attention mechanism is able to provide more accurate and robust feature extraction for the small and subtle defects commonly found on solar panels.
5. Conclusion and Future Work
In this article, I presented my research on improving the defect detection methods for solar panels based on the YOLO algorithm. I addressed two major challenges in the current detection systems for solar panels, namely the balance between detection accuracy and computational efficiency, and the accurate detection of small and subtle surface defects.
To tackle the first challenge, I proposed LPV-YOLO, a lightweight defect detection model based on YOLOv5s. By introducing the GhostMConv and C3MGhost modules, I effectively reduced the number of parameters and computational complexity of the network. The MSSPPF module and the SE attention mechanism further improved the feature representation and detection ability, compensating for the minor accuracy loss introduced by the lightweight network. The experimental results demonstrate that LPV-YOLO reduces the parameter count by about 49%, the model size by 46%, and the computational load by nearly 50%, while still achieving a high mAP of 93.8% and a real-time detection speed of 70.4 FPS. This makes it a suitable candidate for real-time detection systems deployed in industrial scenarios.
To tackle the second challenge, I proposed PVA-YOLO, an attention-based improvement of YOLOv9. By introducing K-means++ anchor clustering, an enhanced RepNCSPELAN_TCA feature extraction module, and a parallel joint attention mechanism, PVA-YOLO effectively improves the detection of small defects on solar panels. The experimental results show that PVA-YOLO improves the mAP@0.5 from 93.7% to 96.3% and mAP@0.5:0.95 from 68.9% to 76.5%, demonstrating its excellent capability in accurately detecting various defect types on solar panels.
In the future, my work can be extended in several directions. First, I plan to investigate the deployment of these methods on edge devices with constrained resources, as well as their integration into existing industrial inspection pipelines. Second, exploring the combination of internet-of-things technologies with the solar panel defect detection system may enable the development of a comprehensive monitoring platform for photovoltaic plants, allowing for early detection of potential defects and better maintenance planning. Furthermore, the ongoing development of the YOLO algorithm family will continue to offer new possibilities for improving the accuracy and efficiency of solar panel defect detection.
