The rapid integration of solar panels into the global energy grid is a cornerstone of the transition towards sustainable power systems. However, the operational efficiency and long-term economic viability of photovoltaic (PV) installations are critically dependent on the health of individual solar panels. Throughout their lifecycle, solar panels are susceptible to various defects such as cracks, broken fingers, black cores, thick lines, and star cracks. These imperfections can significantly degrade power output and, if undetected, lead to premature system failure. Traditional inspection methods, including manual visual checks or electroluminescence imaging, are often labor-intensive, slow, and unsuitable for large-scale deployments. Consequently, automated, accurate, and rapid defect detection in solar panels has become a paramount research focus to ensure the reliability and profitability of solar energy assets.
Deep learning, particularly convolutional neural networks (CNNs), has revolutionized visual inspection tasks. For defect detection in solar panels, both two-stage detectors (e.g., Faster R-CNN, Mask R-CNN) and one-stage detectors (e.g., SSD, YOLO series) have been explored. While two-stage methods often achieve high accuracy, their computational complexity hinders real-time application. One-stage detectors, especially the YOLO (You Only Look Once) family, offer an excellent balance between speed and accuracy, making them highly suitable for industrial inspection scenarios. The latest iteration, YOLOv8, further refines this balance with an anchor-free detection head and an efficient backbone-neck architecture. Nevertheless, directly applying the standard YOLOv8 model to the specific challenge of solar panel defect detection reveals limitations. Defects in solar panels can be minute, irregular in shape, and often resemble texture or background noise, leading to potential misdetections or false alarms. This necessitates architectural enhancements tailored to the unique characteristics of solar panel imagery.

To address these challenges, we propose a significantly enhanced model based on YOLOv8, which we refer to as YOLOv8-EDD (Enhanced Defect Detector). Our improvements are multi-faceted, targeting feature enhancement, geometric adaptability, computational efficiency, and robust optimization. The core architecture of the original YOLOv8 consists of three parts: a Backbone for feature extraction (built with Conv, C2f, and SPPF modules), a Neck for multi-scale feature fusion (using a FPN-PAN structure with upsample and concat operations), and a Head for final prediction. Our modifications systematically upgrade each of these components.
First, we incorporate a multi-scale attention mechanism, the Efficient Multi-scale Attention (EMA) module, into the backbone. Defects like broken fingers in solar panels require the model to focus on precise local features amidst cluttered backgrounds. The EMA module partitions feature maps into groups and processes them through parallel sub-networks to capture cross-spatial dependencies without a significant computational penalty. It applies 1D global average pooling along height and width dimensions in separate branches and uses a 3×3 convolution branch to capture detailed spatial structure. The outputs are then integrated using a re-weighting mechanism. This allows our model to dynamically highlight salient defect features in solar panels while suppressing irrelevant background information, directly improving the discriminative power of the extracted features. The process within the EMA module for a grouped feature $X_i$ can be summarized as focusing on channel and spatial information aggregation to produce a refined output $Y_i$:
$$Y_i = \text{Re-weight}\left(\sigma\left(\text{Aggregate}\left(\text{GAP}_{1D}(X_i), \text{Conv}_{3\times3}(X_i)\right)\right)\right)$$
where $\sigma$ denotes the sigmoid function and GAP represents global average pooling.
Second, to empower the model with a flexible receptive field capable of adapting to the irregular shapes of defects like star cracks or uneven black cores, we integrate Deformable Convolution v2 (DCNv2) into the core feature extraction blocks. We replace the standard C2f modules at key stages in the backbone with newly designed C2f_DCNv2 modules. Unlike standard convolution with a fixed grid, DCNv2 adds learnable offsets $\Delta p_k$ and a modulation scalar $\Delta m_k$ to each sampling location, allowing the kernel to dynamically adjust its sampling points based on the feature map content. This is particularly effective for the non-rigid geometries often found in damaged solar panels. The operation for an output feature $y(p)$ at location $p$ is defined as:
$$y(p) = \sum_{k=1}^{K} w_k \cdot x(p + p_k + \Delta p_k) \cdot \Delta m_k$$
Here, $K$ is the total number of sampling points, $w_k$ is the weight for the $k$-th point, $x$ is the input feature map, $p_k$ is the pre-defined offset for the regular convolution, $\Delta p_k$ is the learned additional offset, and $\Delta m_k \in [0,1]$ is the learned weight modulating the importance of each sampled feature. This enhancement significantly improves the model’s ability to precisely delineate defect boundaries in solar panels.
Third, the introduction of DCNv2 increases model parameters and complexity, which could impact inference speed—a critical factor for inspecting vast solar farms. To compensate and achieve a net gain in efficiency, we replace the original nearest-neighbor upsampling operator in the neck with a lightweight, dynamic alternative called DySample. Conventional upsampling methods like bilinear or nearest interpolation use fixed rules, which can blur or lose fine details crucial for small defects in solar panels. DySample approaches upsampling from a point-sampling perspective. It generates a dynamic sampling coordinate set $\delta$ through a lightweight sub-network (a linear layer followed by a static range factor of 0.25) and then uses a grid sampler to resample the input features. This process is more parameter-efficient and preserves spatial fidelity better than content-aware upsamplers like CARAFE, leading to faster and more accurate feature map resolution recovery. The upsampling operation can be expressed as:
$$\alpha’ = \text{grid\_sampler}(\alpha, \delta), \quad \text{where} \quad \delta = 0.25 \cdot \text{linear}(\alpha)$$
Finally, the training dynamics and localization precision are improved by replacing the default CIoU loss function with Wise-IoU v3 (WIoUv3). The quality of annotated bounding boxes in real-world solar panel datasets can be inconsistent, with some “low-quality” examples featuring ambiguous boundaries. Traditional IoU-based losses like CIoU can be adversely influenced by these outliers during training. WIoUv3 introduces a non-monotonic focusing mechanism. It constructs a running mean of IoU losses $\hat{L}_{IoU}$ as a benchmark, and assigns a gradient gain $r$ that is smaller for anchors with outlier-high loss (likely low-quality samples), preventing them from dominating the gradient. This fosters a more stable training process and improves generalization to diverse defect appearances in solar panels. The WIoUv3 loss $L_{WIoUv3}$ is calculated as:
$$L_{WIoU} = 1 – IoU$$
$$R_{WIoU} = \exp\left(\frac{(x – x_{gt})^2 + (y – y_{gt})^2}{(W_g^2 + H_g^2)^*}\right)$$
$$L_{WIoUv1} = R_{WIoU} \cdot L_{WIoU}$$
$$\beta = \frac{\hat{L}_{IoU}}{L_{IoU}}, \quad r = \frac{\beta}{\delta \alpha^{\beta-\delta}}$$
$$L_{WIoUv3} = r \cdot L_{WIoUv1}$$
Here, $\alpha$ and $\delta$ are hyperparameters, $(x, y)$ and $(x_{gt}, y_{gt})$ are the predicted and ground-truth bounding box centers, and $W_g, H_g$ are the dimensions of the smallest enclosing box.
We constructed our experimental dataset from a publicly available source, focusing on five common defect types in solar panels: Crack, Broken Finger, Black Core, Thick Line, and Star Crack. A total of 4,000 annotated images were split into training, validation, and test sets in a 7:2:1 ratio. All models were trained and evaluated on a consistent hardware setup with an NVIDIA Tesla P4 GPU. The training hyperparameters are summarized in the table below.
| Hyperparameter | Value |
|---|---|
| Image Size | 640 × 640 |
| Batch Size | 16 |
| Epochs | 200 |
| Optimizer | Auto (SGD) |
| Initial Learning Rate (lr0) | 0.01 |
| Momentum | 0.937 |
| Weight Decay | 0.0005 |
We used standard evaluation metrics for object detection: Precision (P), Recall (R), mean Average Precision at IoU=0.5 (mAP@50), number of parameters (Params), Giga Floating Point Operations (GFLOPs), and inference speed in Frames Per Second (FPS). Precision and Recall are defined as:
$$P = \frac{TP}{TP + FP}, \quad R = \frac{TP}{TP + FN}$$
where TP, FP, and FN are True Positives, False Positives, and False Negatives, respectively. The mAP is the mean of the Average Precision (area under the P-R curve) across all classes.
Ablation studies were conducted to validate the contribution of each proposed component. Starting from the baseline YOLOv8, we incrementally added the EMA module, the C2f_DCNv2 module, the DySample upsampler, and finally the WIoUv3 loss. The results clearly demonstrate the cumulative benefit of each improvement.
| Model Configuration | P (%) | R (%) | mAP@50 (%) | FPS |
|---|---|---|---|---|
| YOLOv8 (Baseline) | 82.4 | 84.9 | 88.4 | 178.1 |
| + EMA | 92.3 (+9.9) | 86.8 (+1.9) | 93.5 (+5.1) | 179.9 |
| + EMA + DCNv2 | 93.3 | 89.0 | 95.0 | 177.1 |
| + EMA + DCNv2 + DySample | 93.1 | 92.7 | 96.3 | 187.3 |
| YOLOv8-EDD (All) | 97.7 (+15.3) | 96.2 (+11.3) | 98.9 (+10.5) | 184.6 (+6.5) |
The EMA module provided a substantial boost in precision. The DCNv2 module further increased recall and mAP. Critically, the DySample operator successfully recovered and even increased the FPS that was slightly reduced by DCNv2, leading to a faster model than the baseline. The final integration of WIoUv3 yielded the best overall performance across all accuracy metrics while maintaining a high inference speed, proving the effectiveness of our holistic design for inspecting solar panels.
We also performed comparative analyses against individual alternatives. When testing different attention mechanisms for integration into the solar panel defect detector, EMA outperformed others like CBAM, ECA, and SimAM, offering the best accuracy-efficiency trade-off.
| Attention Mechanism | mAP@50 (%) | Params | GFLOPs |
|---|---|---|---|
| None (Baseline) | 88.4 | 3.01M | 8.1 |
| CBAM | 92.3 | 3.07M | 8.1 |
| ECA | 92.2 | 3.01M | 8.1 |
| SimAM | 89.6 | 3.01M | 8.1 |
| EMA (Ours) | 93.5 | 3.01M | 8.1 |
Similarly, DySample was compared against other upsampling methods. It achieved superior accuracy with lower parameter counts than content-aware methods like CARAFE, making it ideal for a fast solar panel inspection system.
| Upsampling Method | mAP@50 (%) | Params |
|---|---|---|
| Nearest (Baseline) | 88.4 | 3.01M |
| CARAFE | 92.6 | 3.17M |
| DySample (Ours) | 93.1 | 3.02M |
The WIoUv3 loss function demonstrated clear advantages over a range of other IoU-based losses, providing the highest mAP and robust convergence during training for our solar panel defect task.
| Loss Function | P (%) | R (%) | mAP@50 (%) |
|---|---|---|---|
| CIoU | 82.4 | 84.9 | 88.4 |
| DIoU | 87.4 | 87.2 | 91.5 |
| GIoU | 89.4 | 89.5 | 92.8 |
| SIoU | 85.3 | 90.0 | 91.1 |
| WIoUv3 (Ours) | 91.2 | 91.5 | 94.4 |
A benchmark against other state-of-the-art YOLO models underscores the superior performance of YOLOv8-EDD for the specific application of solar panel defect detection.
| Model | P (%) | R (%) | mAP@50 (%) | Params | FPS |
|---|---|---|---|---|---|
| YOLOv5 | 80.0 | 78.5 | 83.0 | 2.50M | 127.1 |
| YOLOv7 | 88.3 | 81.7 | 87.5 | 37.21M | 105.2 |
| YOLOv8 | 82.4 | 84.9 | 88.4 | 3.01M | 178.1 |
| YOLOv8-EDD (Ours) | 97.7 | 96.2 | 98.9 | 3.18M | 184.6 |
Our model achieves the highest precision, recall, and mAP, with a parameter count far lower than YOLOv7 and a significant FPS advantage over all compared models except the baseline YOLOv8, which it surpasses in speed as well. This demonstrates that YOLOv8-EDD successfully breaks the trade-off, offering both higher accuracy and faster inference for detecting flaws in solar panels.
To test the generalization capability of our model, we expanded the dataset to include a sixth, more challenging defect class: “Thick Line,” which is subtle and easily confused with the solar panel’s background texture. The results confirmed that YOLOv8-EDD maintains robust performance even with an increased number of defect types, significantly outperforming both YOLOv7 and vanilla YOLOv8 in mAP and FPS on this more complex task, proving its adaptability and practical utility for comprehensive solar panel inspection systems.
| Model (6-class task) | mAP@50 (%) | FPS |
|---|---|---|
| YOLOv7 | 78.1 | 91.2 |
| YOLOv8 | 86.1 | 173.2 |
| YOLOv8-EDD (Ours) | 94.2 | 181.6 |
Visual comparisons of detection results on sample solar panel images provide qualitative evidence of the improvement. The baseline YOLOv8 model tends to miss small cracks or produces bounding boxes with low confidence for subtle defects. In contrast, YOLOv8-EDD consistently identifies these challenging defects with high confidence and precise localization, effectively reducing both false negatives and false positives in the inspection of solar panels.
In conclusion, the proposed YOLOv8-EDD model presents a powerful solution for automated defect detection in solar panels. By integrating the EMA attention mechanism for focused feature learning, DCNv2 for adaptable spatial reasoning, DySample for efficient feature map recovery, and WIoUv3 for robust optimization, the model achieves a remarkable synergy. It significantly surpasses the original YOLOv8 and other contemporary detectors in terms of detection accuracy (precision, recall, mAP) while simultaneously achieving a higher inference speed. This combination of high precision and real-time capability makes YOLOv8-EDD particularly suitable for large-scale, automated inspection of solar farms, contributing directly to improved maintenance, higher energy yield, and greater economic returns from photovoltaic installations. Future work may explore knowledge distillation to create even lighter versions for edge deployment on drones or robotic inspectors, further automating the lifecycle management of solar energy assets.
