YOLO-RMFP: A Novel Method for Solar Panels Defect Detection

In the context of the global shift toward renewable energy, solar panels have become a crucial component of photovoltaic power generation. However, defects such as cracks, black cores, broken grids, and thick lines frequently appear on solar panels due to manufacturing imperfections, environmental stressors, and aging. Detecting these defects accurately and efficiently is vital for maintaining the performance and longevity of solar panels. Traditional methods, including manual visual inspection and non-destructive testing, suffer from subjectivity, low efficiency, and high false rates. Deep learning-based object detection algorithms, particularly one-stage models like YOLO, offer high speed and reasonable accuracy. Nevertheless, existing YOLO variants struggle with small defect sizes, large scale variations, and complex backgrounds in electroluminescence images of solar panels. To address these challenges, we propose an improved model called YOLO-RMFP, which integrates a receptive field mixed attention mechanism, a novel spatial pyramid pooling module, a multi-scale feature fusion pyramid network, and an enhanced loss function. Our approach significantly boosts detection precision and robustness for solar panel defect detection.

Introduction

Solar panels are exposed to harsh operating conditions, leading to various internal defects that reduce power conversion efficiency. Electroluminescence (EL) imaging is widely used for non-destructive inspection of solar panels. However, EL images often contain tiny defects with subtle contrast, making manual or conventional computer vision methods inadequate. Recent advances in deep learning, particularly YOLO (You Only Look Once) models, have demonstrated promise in real-time defect detection. Among these, YOLOv8n provides a lightweight backbone with good speed. However, direct application of YOLOv8n to solar panel EL images suffers from limited multi-scale feature fusion, insufficient attention to small defects, and imbalanced regression accuracy. To overcome these limitations, we propose YOLO-RMFP, which incorporates three key innovations: (1) a Receptive Field Mixed Attention (RFMA) mechanism that combines Efficient Multi-Scale Attention (EMA) and Receptive Field Attention (RFA) to focus on multi-scale features and address parameter sharing issues; (2) a Spatial Pyramid Pooling with RFMA (SPPRFMA) module that enhances multi-scale feature extraction and noise suppression; (3) a Multi-Scale Feature Fusion Pyramid Network (MSF-FPN) that improves cross-layer feature interaction; (4) a Focaler-PIoU loss function that refines bounding box regression and handles sample imbalance. Extensive experiments on a self-built solar panels defect dataset demonstrate that YOLO-RMFP achieves superior detection performance.

Methodology

RFMA: Receptive Field Mixed Attention

Traditional EMA modules dynamically adjust feature weights but suffer from parameter sharing in multi-scale processing, limiting inter-spatial feature interaction. We propose RFMA by fusing EMA with RFA. The RFMA module first applies group convolution and normalization to split input features \( \mathbf{X} = [\mathbf{X}_0, \mathbf{X}_1, \ldots, \mathbf{X}_{G-1}] \), where \( \mathbf{X}_i \in \mathbb{R}^{C/G \times K_H \times K_W} \). Then it processes through two parallel paths: a 1×1 branch and a 3×3 branch. The 1×1 branch uses one-dimensional max pooling along horizontal and vertical directions (Equation 1), concatenates the results, applies a shared 1×1 convolution followed by Sigmoid activation and another 1×1 convolution, and multiplies with the original input. The 3×3 branch applies a 3×3 convolution to capture multi-scale features. The outputs from both branches are reshaped and passed through two-dimensional max pooling (Equation 2) and Softmax to generate spatial attention weights. These weights are combined and passed through Sigmoid to produce the final output feature map. The RFMA mechanism adaptively adjusts receptive fields and emphasizes critical regions, improving detection of tiny defects on solar panels.

The 1D max pooling formula:

$$
z_{H_C}(H) = \max_{K_W}^{0} x_c(H, i) \tag{1}
$$

The 2D max pooling formula:

$$
z_c = \max_{K_H}^{j} \max_{K_W}^{i} x_c(i, j) \tag{2}
$$

Comparison of attention mechanisms
Module Multi-scale focus Parameter sharing Inter-spatial interaction
EMA Yes Yes Limited
RFA Yes No Moderate
RFMA (proposed) Yes No Enhanced

SPPRFMA: Spatial Pyramid Pooling with RFMA

The standard SPPF module in YOLOv8n performs multi-scale pooling but lacks attention to complex features. We replace SPPF with SPPRFMA, which integrates RFMA via residual connections. This module dynamically adjusts receptive fields and assigns weights to important regions, effectively filtering background noise in solar panels EL images while enhancing detection of subtle defects such as micro-cracks. The SPPRFMA structure is defined as a series of convolutions and max-pooling layers, with RFMA applied after the final pooling output. The improved feature extraction boosts the model’s ability to capture defects of varying scales.

SPPRFMA vs SPPF
Module Multi-scale pooling Attention mechanism Noise suppression
SPPF Yes No Basic
SPPRFMA (proposed) Yes RFMA Enhanced

MSF-FPN: Multi-Scale Feature Fusion Pyramid Network

Conventional FPN fuses features linearly from top-down and bottom-up paths, which is insufficient for solar panels defects that exhibit large scale variations. We propose MSF-FPN, which includes shallow auxiliary fusion and deep auxiliary fusion. Shallow auxiliary fusion concatenates feature maps from adjacent levels to preserve high-resolution details while incorporating deep semantic information. The formulas are given in Equations (3) and (4). Deep auxiliary fusion uses cross-layer gradient dense connections to enhance multi-scale semantic interaction, improving distinction between different defect types coexisting on solar panels.

Shallow auxiliary fusion:

$$
\begin{aligned}
\mathbf{P}’_{n+1} &= \text{Concat}(\mathbf{P}_{n+1}, C(\mathbf{P}_n)) \\
\mathbf{P}’_n &= \text{Concat}(\mathbf{P}_n, C(\mathbf{P}_{n-1}), U(C2F(\mathbf{P}’_{n+1}))) \\
\mathbf{P}’_{n-1} &= \text{Concat}(\mathbf{P}_{n-1}, C(\mathbf{P}_{n-2}), U(C2F(\mathbf{P}’_n)))
\end{aligned} \tag{3}
$$

Deep auxiliary fusion:

$$
\begin{aligned}
\mathbf{P}”_{n-1} &= \text{Concat}(\mathbf{P}_{n-1}, C2F(\mathbf{P}’_{n-1}), U(C2F(\mathbf{P}’_n))) \\
\mathbf{P}”_n &= \text{Concat}(C(C2F(\mathbf{P}’_{n-1})), C(C2F(\mathbf{P}”_{n-1})), \mathbf{P}_n, C2F(\mathbf{P}’_n), U(C2F(\mathbf{P}’_{n+1}))) \\
\mathbf{P}”_{n+1} &= \text{Concat}(C(C2F(\mathbf{P}’_n)), C(C2F(\mathbf{P}”_n)), \mathbf{P}_{n+1}, C2F(\mathbf{P}’_{n+1}))
\end{aligned} \tag{4}
$$

Here, \(C(\cdot)\) denotes convolution downsampling, \(U(\cdot)\) denotes upsampling, and \(C2F(\cdot)\) denotes the C2F module.

Comparison of feature pyramid networks
Network Shallow detail preservation Deep semantic fusion Cross-layer interaction
FPN Moderate Moderate Linear
PANet Good Good Bidirectional
MSF-FPN (proposed) Excellent Excellent Dense gradient

Focaler-PIoU Loss Function

The CIoU loss used in YOLOv8n is suboptimal for bounding box regression on solar panels defects due to high aspect ratios and class imbalance. We replace it with Focaler-PIoU, combining the PIoU loss and Focaler-IoU reweighting. PIoU uses an adaptive penalty factor \(P\) (Equation 5) based on pixel-wise distances, leading to more accurate overlaps. The penalty function is defined in Equations (6)-(8). Focaler-IoU (Equation 9) applies linear interval mapping to focus on hard samples. The final Focaler-PIoU loss is given in Equation (10).

$$
P = \left( \frac{d_{w1}}{w_{gt}} + \frac{d_{w2}}{w_{gt}} + \frac{d_{h1}}{h_{gt}} + \frac{d_{h2}}{h_{gt}} \right) / 4 \tag{5}
$$
$$
f(x) = 1 – e^{-x^2} \tag{6}
$$
$$
\text{PIoU} = \text{IoU} – f(P), \quad -1 \leq \text{PIoU} \leq 1 \tag{7}
$$
$$
L_{\text{PIoU}} = 1 – \text{PIoU} = L_{\text{IoU}} + f(p), \quad 0 \leq L_{\text{PIoU}} \leq 2 \tag{8}
$$
$$
\text{IoU}_{\text{focaler}} = \begin{cases} 0, & \text{IoU} < d \\ \frac{\text{IoU} – d}{u – d}, & d \leq \text{IoU} \leq u \\ 1, & \text{IoU} > u \end{cases} \tag{9}
$$
$$
L_{\text{Focaler-PIoU}} = L_{\text{PIoU}} + \text{IoU} – \text{IoU}_{\text{focaler}} \tag{10}
$$

Comparison of loss functions
Loss Adaptive penalty Hard sample focus Performance on solar panels defects
CIoU No No Baseline
PIoU Yes No Better
Focaler-PIoU (proposed) Yes Yes Best

Experimental Setup

We built a dataset of 3,150 electroluminescence images of solar panels with four defect types: cracks, black cores, broken grids, and thick lines. The dataset was split into training (2,520), validation (315), and test (315) sets. All experiments were performed on a system with NVIDIA GeForce RTX 3070 Ti GPU, 12th Gen Intel i9-12900H CPU, 32 GB RAM, PyTorch 2.1.0, and CUDA 12.5. Training parameters: 150 epochs, batch size 2, image size 640×640, initial learning rate 0.01, final learning rate 0.01. Evaluation metrics included mAP@0.5, mAP@0.5:0.95, precision, recall, frame rate (FPS), and computational complexity (GFLOPS).

Results and Discussion

Comparison with State-of-the-Art Methods

We compared YOLO-RMFP with several detectors: Faster R-CNN, Mask R-CNN, YOLOv5s, YOLOv7-tiny, YOLOv8n, and YOLOv10n. The results are summarized in the table below. YOLO-RMFP achieved the highest mAP@0.5 of 94.2%, outperforming YOLOv8n by 3.1% and other models by 3.1-9.5%. Although its FPS (201.4) is slightly lower than YOLOv8n (211.1), it still satisfies real-time requirements (≥30 fps). The computational cost (9.9 GFLOPS) is acceptable for deployment.

Performance comparison of different models on solar panels defect detection
Model mAP@0.5 (%) FPS GFLOPS
Faster R-CNN 86.0 52.3 134
Mask R-CNN 86.6 48.1 187
YOLOv5s 88.8 208.1 8.7
YOLOv7-tiny 84.7 103.8 13.2
YOLOv8n 91.1 211.1 8.1
YOLOv10n 85.7 205.7 8.4
YOLO-RMFP (ours) 94.2 201.4 9.9

Ablation Study

We conducted ablation experiments to evaluate the contribution of each component: SPPRFMA, MSF-FPN, and Focaler-PIoU. The baseline YOLOv8n had mAP@0.5 of 91.1%. Adding SPPRFMA improved to 91.9%; adding MSF-FPN to 92.3%; adding Focaler-PIoU to 91.4%. Combining all three modules yielded 94.2%, demonstrating synergy. Precision and recall also improved significantly. The detailed results are shown below.

Ablation study results
SPPRFMA MSF-FPN Focaler-PIoU mAP@0.5 (%) mAP@0.5:0.95 (%) Recall (%) Precision (%) FPS GFLOPS
91.1 62.8 87.3 88.4 211.1 8.1
91.9 64.9 88.4 88.9 203.4 8.7
92.3 63.4 88.5 89.0 198.3 9.1
91.4 63.1 91.6 83.9 223.3 8.1
93.5 65.1 90.7 89.1 194.6 9.9
92.2 64.6 87.5 89.0 205.7 8.7
92.7 65.3 88.5 87.9 203.5 8.9
94.2 69.3 90.8 92.6 201.4 9.9

Robustness Testing

We tested YOLO-RMFP and YOLOv8n under various disturbances: contrast change, noise addition, rotation, and flipping. For crack defects, YOLO-RMFP improved precision over YOLOv8n by 14% under contrast, 30% under noise, 17% under flip, and 2% under 90° rotation. For broken grid defects, improvements ranged from 10% to 30%, with YOLOv8n missing some detections. These results confirm that YOLO-RMFP maintains high accuracy even under severe image quality degradation, making it robust for real-world inspection of solar panels.

Conclusion

In this work, we presented YOLO-RMFP, a novel deep learning model tailored for detecting defects in solar panels. By integrating RFMA attention into the SPPF module, we enhanced multi-scale feature extraction and noise rejection. The MSF-FPN improved cross-layer feature fusion, and the Focaler-PIoU loss refined bounding box regression while addressing sample imbalance. On a challenging dataset of solar panels electroluminescence images, YOLO-RMFP achieved mAP@0.5 of 94.2% and mAP@0.5:0.95 of 69.3%, with precision 92.6% and recall 90.8%, outperforming existing models. The method shows strong robustness to environmental variations, making it suitable for automated quality inspection of solar panels in production and maintenance. Future work will focus on further reducing computational cost while maintaining high accuracy for edge deployment.

Scroll to Top