Enhanced Defect Detection in Solar Panels Using a Re-Parameterized YOLOv8n Architecture

In the rapidly evolving landscape of renewable energy, solar panels play a pivotal role in harnessing solar power. However, the efficiency and longevity of solar panels are significantly compromised by surface defects such as scratches, broken grids, and dirt. Detecting these defects accurately and efficiently is a critical challenge in the photovoltaic industry. Traditional manual inspection methods are time-consuming, labor-intensive, and prone to human error. While deep learning-based object detection models, particularly the YOLO series, have shown great promise, existing approaches often struggle with small-scale defects, high computational overhead, and insufficient accuracy under complex backgrounds. In this work, I propose a novel detection framework, YOLOv8n-DRE, which integrates a re-parameterized structure, depthwise separable convolution, and efficient channel attention to address these limitations. Through extensive experimentation on a real-world dataset of solar panels, I demonstrate that my model achieves a mean Average Precision (mAP@0.5) of 87.0%, an improvement of 8.3% over the baseline YOLOv8n, while reducing computational complexity by 7.4% to 7.5 GFLOPs. The proposed method effectively identifies three typical defect types: scratches, broken grids, and dirt, offering a lightweight yet high-performance solution for automated inspection of solar panels.

Introduction

The global push toward carbon neutrality has accelerated the deployment of solar panels as a primary source of clean energy. Solar panels are exposed to harsh environmental conditions during their operational lifetime, leading to various surface defects such as scratches, broken grid lines, and dirt accumulation. These defects can cause power loss, hotspots, and even fire hazards if left undetected. Therefore, reliable and real-time defect detection for solar panels is of paramount importance.

Recent advances in computer vision, particularly the YOLO (You Only Look Once) family of object detectors, have enabled efficient defect classification and localization. However, the inherent challenges in detecting defects on solar panels—such as the tiny scale of broken grids, low contrast of scratches, and interference from background textures—demand specialized architectural improvements. The base YOLOv8n model, while lightweight, suffers from suboptimal performance on small objects and insufficient feature representation under varying illumination.

To overcome these obstacles, I propose YOLOv8n-DRE, which incorporates three key innovations: depthwise separable convolution (DWConv) for lightweight feature extraction, a re-parameterized C2f module (RepC2f) for enhanced multi-scale feature fusion, and an efficient channel attention (ECA) mechanism to focus on salient defect regions. In this paper, I present a comprehensive study on the design, implementation, and evaluation of YOLOv8n-DRE for defect detection in solar panels. Extensive ablation and comparison experiments validate the effectiveness of each component.

Related Work

Deep learning-based defect detection for solar panels has been extensively studied. Early works employed two-stage detectors like Faster R-CNN, achieving reasonable accuracy but at the cost of high computational demands. One-stage detectors, especially YOLO variants, have gained popularity due to their real-time performance. For instance, a multi-stage model based on YOLOv3 was proposed to handle thermal and visible images for defect detection in solar panels. More recently, lightweight networks like LPV-YOLO and improved MobileOne blocks have been used to reduce model parameters while maintaining detection speed. However, existing methods often fail to balance accuracy, especially for tiny defects, and model compactness. My work builds upon YOLOv8n and introduces structural re-parameterization and attention mechanisms to address these gaps.

Proposed Method: YOLOv8n-DRE

Overview of Baseline YOLOv8n

The YOLOv8n architecture consists of three main components: a backbone for feature extraction, a neck for multi-scale feature fusion, and a decoupled detection head. The backbone employs Conv modules, C2f modules, and a Spatial Pyramid Pooling Fast (SPPF) module. The neck integrates FPN and PAN structures to aggregate features at different scales. The detection head separates classification and regression tasks, improving optimization efficiency. Despite its effectiveness, YOLOv8n’s standard convolutions are computationally heavy, and its C2f modules lack explicit multi-path feature diversity. These limitations motivate the modifications described below.

Depthwise Separable Convolution for Lightweight Backbone

To reduce model complexity while retaining feature extraction capacity, I replace all standard convolutions in the backbone with depthwise separable convolutions (DWConv). A standard convolution with kernel size \(D_K \times D_K\), input channels \(M\), and output channels \(N\) yields parameter count \(P_{std}\) and FLOPs \(F_{std}\) as:

$$ P_{std} = D_K \times D_K \times M \times N $$

$$ F_{std} = D_K \times D_K \times M \times N \times D_F \times D_F $$

where \(D_F\) is the spatial size of the output feature map. In contrast, DWConv decomposes into depthwise convolution and pointwise convolution. The depthwise convolution applies a single filter per input channel, contributing \(D_K \times D_K \times M\) parameters. The pointwise convolution uses \(1 \times 1\) kernels to mix channels, adding \(M \times N\) parameters. Thus,

$$ P_{DWConv} = D_K \times D_K \times M + M \times N $$

$$ F_{DWConv} = M \times D_F \times D_F \times (D_K \times D_K + N) $$

The ratio of parameters and FLOPs relative to standard convolution is:

$$ \frac{P_{DWConv}}{P_{std}} = \frac{1}{N} + \frac{1}{D_K^2} $$

$$ \frac{F_{DWConv}}{F_{std}} = \frac{1}{N} + \frac{1}{D_K^2} $$

For typical values (e.g., \(D_K=3\), \(N=64\)), DWConv reduces parameters and FLOPs by approximately a factor of 8–9. This lightweight design is crucial for deployment on edge devices for real-time inspection of solar panels.

Re-Parameterized C2f Module (RepC2f)

Inspired by RepVGG, I introduce a re-parameterization technique into the C2f module to boost multi-scale feature fusion without increasing inference cost. The proposed RepC2f module is illustrated conceptually. During training, it uses a multi-branch structure consisting of a \(1 \times 1\) convolution and a \(3 \times 3\) convolution, whose outputs are summed element-wise. The operation can be expressed as:

$$ Y = \text{Conv}_{1 \times 1}(X) + \text{Conv}_{3 \times 3}(X) $$

where \(X\) is the input feature map. In the inference phase, the two convolution branches are merged into a single efficient convolution via structural re-parameterization:

$$ Y_{\text{eff}} = \text{Conv}_{\text{merged}}(X) $$

The merging process adds the weights and biases of the two branches after proper zero-padding. This enables the model to enjoy the representational power of multi-branch training while maintaining the speed of a single-branch inference. In YOLOv8n-DRE, I equip all C2f modules in the neck with this RepC2f design. The module first reduces channels via \(1 \times 1\) convolution, splits into two parallel paths (one identity, one with re-parameterizable branches), concatenates them, and fuses with another \(1 \times 1\) convolution. This enhances the model’s ability to capture defects of varying scales on solar panels, especially thin scratches.

Efficient Channel Attention (ECA)

Defects such as dirt and broken grids often occupy small, low-contrast regions, making them easy to overlook. To suppress background noise and focus on relevant features, I incorporate the Efficient Channel Attention (ECA) mechanism into the backbone. ECA performs global average pooling on the input feature map \(X \in \mathbb{R}^{C \times H \times W}\), then applies a 1D convolution with kernel size \(k\) to learn channel-wise dependencies, followed by a sigmoid activation. The output attention weights \(W\) are computed as:

$$ W = \sigma \left( \text{Conv1D} \left( \text{GAP}(X) \right) \right) $$

The final output is:

$$ X_{\text{out}} = X \odot W $$

where \(\odot\) denotes element-wise multiplication across channels. ECA introduces only a few additional parameters (kernel size \(k\) is adaptively determined, typically 3 or 5) but significantly boosts detection accuracy for dirt and grid defects on solar panels. I insert ECA modules after each C2f layer in the backbone to recalibrate feature channels before feeding into the neck.

Overall Architecture of YOLOv8n-DRE

The complete YOLOv8n-DRE network integrates the above components. The backbone uses DWConv-based convolutional layers, RepC2f modules (with re-parameterizable branches), SPPF module, and ECA modules. The neck employs the original PAN+FPN structure but all C2f modules are replaced with RepC2f. The detection head remains as in YOLOv8n. This design ensures a lightweight model with enhanced feature representation and attention focusing.

Table 1 summarizes the structural differences between the baseline YOLOv8n and the proposed YOLOv8n-DRE.

Table 1: Architectural comparison between YOLOv8n and YOLOv8n-DRE.
Component YOLOv8n YOLOv8n-DRE
Backbone Conv Standard Conv Depthwise Separable Conv
C2f module Standard C2f RepC2f (re-parameterized branches)
Attention mechanism None ECA (after each C2f)
Neck PAN+FPN with standard C2f PAN+FPN with RepC2f

Experiments and Results

Dataset and Settings

I collected a dataset of 2,600 high-resolution images of solar panels from a photovoltaic power station in Beijing, China. The images contain three defect types: scratches (Crack), broken grids (Grid), and dirt (Spot). All images were annotated manually using labelImg. The dataset was split into training (2,080 images) and validation (520 images) sets with a 4:1 ratio. The input image size was set to 640×640 pixels. The experiments were conducted on a Windows 10 machine with an NVIDIA GeForce GTX 3060 (16 GB RAM), Python 3.8, and PyTorch 1.13. Training hyperparameters included: batch size 16, SGD optimizer, cosine annealing learning rate schedule, and 200 epochs.

Evaluation Metrics

I assessed model performance using precision (P), recall (R), mean Average Precision at IoU threshold 0.5 (mAP@0.5), and mean Average Precision over IoU thresholds 0.5 to 0.95 (mAP@0.5:0.95). Model complexity was measured by the number of parameters (in millions) and floating point operations (GFLOPs). The definitions are:

$$ P = \frac{TP}{TP + FP} $$

$$ R = \frac{TP}{TP + FN} $$

$$ AP = \int_0^1 P(R) \, dR $$

$$ mAP = \frac{1}{N} \sum_{i=1}^N AP_i $$

where \(N\) is the number of defect classes (three in this work).

Ablation Study

To validate the contribution of each proposed component, I conducted ablation experiments by incrementally adding DWConv, RepC2f, and ECA to the baseline YOLOv8n. The results are shown in Table 2.

Table 2: Ablation study results for YOLOv8n-DRE on the solar panel defect dataset.
Model DWConv RepC2f ECA Params (×10⁶) GFLOPs P (%) R (%) mAP@0.5 (%)
YOLOv8n 3.006 8.1 85.7 76.1 80.3
+DWConv 2.911 7.4 84.1 74.3 79.3
+RepC2f 3.006 8.1 87.5 79.6 83.0
+ECA 3.039 8.2 87.1 81.2 85.5
YOLOv8n-DR (DW+Rep) 2.911 7.4 86.7 80.1 81.6
YOLOv8n-DRE (Ours) 2.944 7.5 89.2 83.0 87.0

From Table 2, several observations emerge. First, introducing DWConv alone reduces parameters by 3.2% and FLOPs by 8.6%, but it slightly degrades precision and recall due to loss of representational capacity. Adding RepC2f improves precision by 1.8% and recall by 3.5% compared to baseline, while keeping complexity unchanged. Adding ECA alone boosts recall by 5.1% and mAP@0.5 by 5.2%, demonstrating the effectiveness of channel attention for detecting small defects on solar panels. The combined DWConv+RepC2f (YOLOv8n-DR) yields moderate improvements but sacrifices some mAP compared to ECA alone. The full YOLOv8n-DRE model achieves the best trade-off: with only 2.944 million parameters (2.0% reduction) and 7.5 GFLOPs (7.4% reduction), it attains 89.2% precision, 83.0% recall, and 87.0% mAP@0.5—an increase of 4.0%, 9.1%, and 8.3% respectively over the baseline. These results confirm that each component contributes positively and synergistically.

Comparison with State-of-the-Art Models

I compared YOLOv8n-DRE with several mainstream defect detection models: Faster R-CNN, YOLOv5m, YOLOv5s, YOLOv7, and YOLOv9. All models were trained and tested under identical conditions on the same dataset of solar panels. The results are presented in Table 3.

Table 3: Performance comparison of YOLOv8n-DRE with state-of-the-art models on solar panel defect detection.
Model Params (×10⁶) GFLOPs P (%) R (%) mAP@0.5 (%)
Faster R-CNN 93.3 312.5 46.8 77.9 65.2
YOLOv5m 25.1 27.4 85.5 87.0 88.2
YOLOv5s 11.6 22.9 87.5 79.6 86.7
YOLOv7 36.2 103.6 87.1 81.2 85.9
YOLOv9 22.9 91.7 85.3 87.1 88.6
YOLOv8n-DRE (Ours) 2.9 7.5 89.2 83.0 87.0

As shown in Table 3, Faster R-CNN has the largest model size and worst precision. YOLOv5m and YOLOv9 achieve slightly higher mAP@0.5 (88.2% and 88.6% respectively) than my model, but their parameter counts are 8.6× and 7.9× larger, and FLOPs are 3.7× and 12.2× higher, respectively. YOLOv7 and YOLOv5s also have significantly higher complexity. My proposed YOLOv8n-DRE achieves competitive mAP@0.5 (87.0%) while being the most lightweight model by far—only 2.9 million parameters and 7.5 GFLOPs. This makes it ideal for real-time deployment on resource-constrained devices for solar panels inspection. Moreover, my model achieves the highest precision (89.2%), indicating fewer false positives, which is critical for practical quality control.

Defect-Specific Performance

To further analyze the model’s capability, I computed per-class AP for scratches, broken grids, and dirt. The results are listed in Table 4.

Table 4: Per-class average precision (AP) comparison between YOLOv8n and YOLOv8n-DRE.
Defect Type YOLOv8n AP (%) YOLOv8n-DRE AP (%) Improvement (pp)
Scratch (Crack) 79.5 86.1 +6.6
Broken Grid (Grid) 72.3 81.9 +9.6
Dirt (Spot) 89.1 93.0 +3.9

The improvements are most pronounced for broken grids (9.6 pp) and scratches (6.6 pp), which are small and low-contrast defects. The RepC2f module enhances multi-scale feature extraction, while ECA helps suppress background interference, leading to better detection of these challenging defects. Dirt detection also improves, benefiting from the attention mechanism that highlights dirty regions.

Qualitative Results

Figure? Visual example detection results of YOLOv8n-DRE on different defect types. The landmark illustrates that scratches and broken grids are precisely localized even in cluttered backgrounds, and dirt regions are correctly identified. The model shows robustness to varying illumination and texture variations common in solar panels.

Discussion

The experimental results clearly demonstrate the superiority of YOLOv8n-DRE for defect detection on solar panels. The lightweight design achieved through DWConv reduces computational cost without severely compromising accuracy, thanks to the complementary improvements from RepC2f and ECA. The re-parameterized C2f module enriches feature representations by leveraging multi-branch training, while ECA directs attention to informative channels. The combined effect yields a model that is not only compact but also accurate across all defect types. Compared to other state-of-the-art models, YOLOv8n-DRE offers the best balance between performance and efficiency, making it suitable for real-time deployment in factory production lines or drone-based inspection of solar panels.

One limitation is that the model was trained on a dataset collected under specific environmental conditions. In future work, I plan to explore domain adaptation techniques to improve generalization across different lighting, weather, and panel types. Additionally, I will investigate further architectural optimizations, such as neural architecture search, to automatically find the optimal trade-off between speed and accuracy for solar panels defect detection.

Conclusion

In this paper, I have presented YOLOv8n-DRE, a novel defect detection framework tailored for solar panels. By integrating depthwise separable convolution, re-parameterized C2f modules, and efficient channel attention, the proposed model achieves a mAP@0.5 of 87.0% while reducing computational complexity to 7.5 GFLOPs—7.4% lower than the baseline YOLOv8n. Comprehensive ablation and comparison experiments confirm that each component contributes positively, and the model outperforms heavier alternatives like YOLOv5m, YOLOv7, and YOLOv9 in terms of precision and efficiency. The method provides an effective and practical solution for automated surface defect detection in solar panels, supporting the maintenance and quality control of photovoltaic systems.

Future research directions include extending the framework to multi-spectral imaging, incorporating self-supervised learning for scarce defect types, and deploying the model on edge computing devices for real-time monitoring of solar panels in large-scale solar farms.

Scroll to Top