In recent years, solar photovoltaic technology has become a cornerstone of the global transition towards renewable energy. As a critical component of the energy system, solar panels must operate reliably under harsh environmental conditions such as ultraviolet radiation, corrosion, and humidity. These stresses inevitably lead to various defects including cracks, broken grid lines, and contamination spots, which significantly reduce the power conversion efficiency and lifespan of solar panels. Efficient and accurate defect detection is therefore essential for maintaining the performance and safety of photovoltaic installations.
Traditional inspection methods, such as manual visual inspection and infrared thermography, are often labor-intensive, slow, and prone to human error. More advanced machine learning techniques like K-means clustering and support vector machines have been applied but struggle with complex backgrounds and small defect sizes. With the rapid development of deep learning, convolutional neural network-based object detection frameworks, especially the YOLO series, have demonstrated remarkable performance in real-time industrial inspection tasks. However, the balance between detection accuracy, model complexity, and inference speed remains a challenge, particularly for small object defects on solar panels.
In this work, I propose an improved YOLOv8n algorithm specifically tailored for solar panel defect detection. The novelty lies in three key enhancements: (1) a lightweight backbone using Ghost convolution to reduce parameters while maintaining feature richness, (2) a C2f-ELA module that integrates efficient local attention to highlight subtle defect patterns, and (3) a weighted bidirectional feature pyramid network (W-BiFPN) augmented with a P2 small-object detection layer to better capture multi-scale information. Extensive experiments on a public solar panel defect dataset demonstrate that the proposed method achieves a 16.7% reduction in parameters and a 3.1 percentage point improvement in mean average precision compared to the baseline YOLOv8n.
Related Work
Defect detection in solar panels has been approached through both traditional image processing and deep learning paradigms. Classical methods often rely on handcrafted features or thermal imaging analysis. For instance, K-means clustering was employed to segment defective regions in thermographic images, and SVM classifiers were used for hotspot detection. Although these methods are computationally efficient, they lack generalization across different defect types and environmental conditions.
The advent of deep learning brought two-stage detectors like Faster R-CNN and single-stage detectors such as SSD and YOLO. Many researchers have adapted YOLOv3, YOLOv5, and YOLOv7 for solar panel inspection, achieving improved accuracy. However, these models tend to be heavy, making deployment on edge devices difficult. Moreover, small defects like micro-cracks and broken fingers are often missed due to insufficient multi-scale representation. Recent works introduced lightweight backbones (e.g., GhostNet) or attention mechanisms to address these issues, but the trade-off between speed and precision remains unresolved. My proposed method builds upon YOLOv8n, the most recent and efficient version of YOLO, and introduces targeted modifications to overcome these limitations.
Proposed Method: YOLOv8-GEB
The overall architecture of the YOLOv8-GEB model is illustrated by modifying three core components: the backbone, the feature enhancement module, and the neck for multi-scale fusion. The baseline YOLOv8n consists of a backbone with Conv, C2f, and SPPF blocks, a neck with PAN+FPN, and a decoupled head. The proposed improvements are detailed as follows.
Lightweight Backbone with Ghost Convolution
To reduce the number of parameters while preserving feature extraction capability, I replace the standard convolutions in the backbone with Ghost convolutions. A standard convolution processes all input channels to produce every output channel, leading to redundant feature maps. Ghost convolution generates a small fraction of intrinsic feature maps via ordinary convolution and then applies cheap linear transformations (e.g., depthwise convolutions) to produce ghost feature maps, as shown in the operational principle.
Assume the input has shape \(C \times H \times W\) and the desired output has \(N\) channels of size \(H’ \times W’\). Standard convolution with kernel \(k\times k\) requires parameters:
$$P_{\text{standard}} = N \times C \times k \times k.$$
Let the Ghost convolution produce \(\frac{N}{s}\) intrinsic maps (where \(s\) is the number of splits) and \(\frac{N}{s}(s-1)\) ghost maps via linear transform with kernel \(d\times d\). The total parameters become:
$$P_{\text{ghost}} = \frac{N}{s} \times C \times k \times k + \frac{N}{s} \times (s-1) \times d \times d.$$
Under typical assumptions (\(C \gg s\) and \(d \approx k\)), the ratio is approximately \(s\), meaning Ghost convolution reduces the parameter count by a factor of \(s\). In my implementation, I set \(s=2\) and \(d=5\), achieving a 50% reduction in backbone parameters without significant accuracy loss.
C2f-ELA: Efficient Local Attention Module
Standard C2f modules in YOLOv8 use a bottleneck structure with residual connections to aggregate features. However, for fine-grained defects on solar panels, these modules may overlook subtle local patterns. To address this, I propose the C2f-ELA module, which inserts an Efficient Local Attention (ELA) mechanism into the bottleneck of C2f. ELA encodes horizontal and vertical positional information using strip pooling and 1D convolutions, avoiding dimensionality reduction that could blur distinctions between foreground and background.
Given an input feature map \(\mathbf{X} \in \mathbb{R}^{C\times H\times W}\), ELA first performs average pooling along horizontal and vertical directions:
$$z_h(h) = \frac{1}{W}\sum_{0\le i< W} \mathbf{X}_c(h,i), \quad z_w(w) = \frac{1}{H}\sum_{0\le j< H} \mathbf{X}_c(j,w).$$
Then, 1D convolutions followed by group normalization and Sigmoid activation produce attention maps:
$$y_h = \sigma\left(\text{GN}\left(F_h(z_h)\right)\right), \quad y_w = \sigma\left(\text{GN}\left(F_w(z_w)\right)\right).$$
Finally, the output is:
$$\mathbf{Y} = \mathbf{X} \cdot y_h \cdot y_w.$$
This operation enhances discriminative local features while suppressing irrelevant background. The C2f-ELA module replaces the original bottleneck in the backbone, leading to better localization of cracks and broken fingers. Table 1 compares different insertion positions; placing ELA only in the backbone gives the best overall performance.
W-BiFPN with P2 Detection Layer
The neck of YOLOv8n uses a PAN+FPN structure that fuses features from top-down and bottom-up paths. However, this design treats all input features equally and often loses small object information. I replace it with a Weighted Bidirectional Feature Pyramid Network (W-BiFPN) that introduces learnable weights for each input scale. Moreover, I add an extra P2 detection layer that uses shallow, high-resolution features to improve detection of small defects.
The fast normalized fusion computes the output of a node as:
$$O = \frac{\sum_i w_i \cdot L_i}{\epsilon + \sum_j w_j},$$
where \(w_i \ge 0\) are learnable weights and \(\epsilon=0.0001\) prevents numerical instability. For a top-down path at level \(i\):
$$P_i^{\text{td}} = \text{Conv}\left( \frac{w_j P_i^{\text{in}} + w_{j+1} \text{Resize}(P_{i+1}^{\text{in}})}{w_j + w_{j+1} + \epsilon} \right).$$
Similarly, the bottom-up path yields:
$$P_i^{\text{out}} = \text{Conv}\left( \frac{w’_j P_i^{\text{in}} + w’_{j+1} P_i^{\text{td}} + w’_{j+2} \text{Resize}(P_{i-1}^{\text{out}})}{w’_j + w’_{j+1} + w’_{j+2} + \epsilon} \right).$$
The inclusion of the P2 layer (resolution 1/4 of input) significantly boosts detection of small targets such as early-stage cracks. This multi-scale fusion strategy allows the network to leverage both coarse semantic information and fine spatial details.
Experiments and Analysis
Dataset and Settings
All experiments are conducted on a publicly available solar panel defect dataset consisting of 2,400 images. The dataset contains three defect types: cracks, broken grids, and spots. I split the data into 1,920 training, 240 validation, and 240 test images. Training is performed on an NVIDIA RTX 3090 GPU with PyTorch 1.7.1, batch size 32, and SGD optimizer. The baseline model is YOLOv8n.
Evaluation Metrics
I use six metrics: Parameters (in millions), GFLOPs, Precision (P), Recall (R), \(F_2\) score, and mean Average Precision at IoU=0.5 (mAP@0.5). \(F_2\) is defined as:
$$F_2 = \frac{2 \cdot P \cdot R}{P + R}.$$
Ablation Study
To validate each component, I perform ablation experiments on the test set. The results are summarized in Table 1.
| Method | Params (M) | P (%) | R (%) | F2 | mAP@0.5 (%) |
|---|---|---|---|---|---|
| YOLOv8n (baseline) | 3.0 | 88.4 | 81.8 | 0.850 | 88.8 |
| +GhostConv | 2.8 | 82.0 | 83.0 | 0.825 | 88.1 |
| +C2f-ELA | 3.0 | 86.0 | 85.6 | 0.858 | 89.1 |
| +W-BiFPN+P2 | 2.7 | 89.5 | 84.2 | 0.868 | 89.8 |
| +GhostConv+C2f-ELA | 2.8 | 85.7 | 82.8 | 0.842 | 90.1 |
| Proposed (full) | 2.5 | 93.0 | 83.8 | 0.882 | 91.9 |
From Table 1, the baseline YOLOv8n achieves 88.8% mAP@0.5 with 3.0M parameters. Adding GhostConv alone reduces parameters to 2.8M but slightly drops mAP to 88.1%, indicating a small trade-off. The C2f-ELA module improves recall and mAP by 3.8% and 0.3% respectively without increasing parameters. Introducing W-BiFPN+P2 further boosts mAP to 89.8% with a parameter reduction. The full proposed method achieves the highest mAP@0.5 of 91.9%, precision of 93.0%, and \(F_2\) of 0.882, while reducing parameters by 16.7% compared to the baseline. These results confirm that each component contributes positively to the final performance.
Comparison with State-of-the-Art Methods
I compare the proposed YOLOv8-GEB with several popular detectors and two recent improvements. Table 2 shows the comparison on the same test set.
| Method | Params (M) | GFLOPs | P (%) | R (%) | F2 | mAP@0.5 (%) |
|---|---|---|---|---|---|---|
| Faster R-CNN | 137.1 | 370.2 | 39.3 | 88.3 | 0.544 | 65.2 |
| YOLOv3 | 61.5 | 155.3 | 85.6 | 88.6 | 0.871 | 89.7 |
| YOLOv5m | 21.1 | 25.2 | 86.4 | 87.2 | 0.868 | 89.3 |
| YOLOv7 | 37.2 | 150.1 | 87.8 | 79.1 | 0.832 | 85.7 |
| YOLOv9m | 32.6 | 130.7 | 85.1 | 89.2 | 0.871 | 90.2 |
| YOLOv10m | 16.5 | 64.0 | 84.9 | 85.0 | 0.849 | 88.6 |
| Improved YOLOv5 (Guo et al.) | 4.2 | 18.1 | 85.9 | 82.3 | 0.841 | 88.1 |
| Multi-scale FPN (Tian et al.) | 13.3 | 31.6 | 88.6 | 86.1 | 0.873 | 88.4 |
| Proposed (YOLOv8-GEB) | 2.5 | 11.7 | 93.0 | 83.8 | 0.882 | 91.9 |
The proposed model has the fewest parameters (2.5M) and the lowest computational cost (11.7 GFLOPs). Despite slightly lower recall, it achieves the highest precision, \(F_2\) score, and mAP@0.5. Compared to YOLOv9m, the mAP improves by 1.7 percentage points while using 12× fewer parameters. The improvements over the two recent methods (Guo et al. and Tian et al.) are also substantial, with 3.8% and 3.5% higher mAP respectively. These results highlight the efficiency and effectiveness of my proposed design for solar panel defect detection.
Qualitative Analysis
To further illustrate the effectiveness, I visualize heatmaps of the feature attention for different ablations. The model with all improvements (YOLOv8-GEB) shows deeper and more focused activation on defective regions, especially for small and blurred cracks. This indicates that the combination of GhostConv, C2f-ELA, and W-BiFPN+P2 successfully guides the network to attend to the most informative parts of the solar panel surface while suppressing noise.

Conclusion
In this paper, I have presented an improved YOLOv8n-based algorithm for defect detection on solar panels. By integrating Ghost convolution for lightweight feature extraction, C2f-ELA for fine-grained local attention, and W-BiFPN with an extra P2 detection layer for multi-scale fusion, the proposed method achieves a significant enhancement in detection accuracy while reducing model complexity. Experimental results demonstrate that the model outperforms several state-of-the-art detectors, achieving 91.9% mAP@0.5 with only 2.5 million parameters. This work provides a practical solution for real-time inspections of solar panels in industrial environments. In future work, I plan to deploy the model on edge devices and extend it to other photovoltaic component inspections, such as inverters and connectors, to further improve the reliability of solar energy systems.
