Reparameterized Structure and Improved YOLOv8n for Solar Panel Defect Detection

In the context of the global push towards carbon neutrality and peak carbon emissions, solar energy has emerged as a pivotal clean energy source. The rapid development of photovoltaic power generation technology has led to the widespread deployment of solar panel systems. However, the efficiency and safety of these systems are critically dependent on the quality of the solar panel components. Defects in solar panels, such as scratches, broken grids, and dirt, can significantly reduce power generation efficiency and pose serious safety risks, including short circuits and fires. Therefore, the development of an accurate and efficient method for detecting defects in solar panels is of paramount importance.

Traditional manual inspection methods for solar panel defects are time-consuming, labor-intensive, and prone to human error. With the advent of computer vision and artificial intelligence, deep learning-based object detection algorithms, particularly the You Only Look Once (YOLO) series, have shown great promise in industrial inspection tasks. These algorithms offer real-time performance and high adaptability, making them suitable for online monitoring and management of solar energy systems. However, existing models often face challenges such as high computational complexity, large model size, and insufficient accuracy when dealing with small-scale defects in solar panel images.

To address these limitations, we propose a novel detection model, YOLOv8n-DRE, based on a reparameterized structure and an improved YOLOv8n framework. This model is specifically designed to enhance the detection of various defects in solar panels while maintaining a lightweight architecture. The key contributions of our work include: (1) the introduction of depthwise separable convolution (DWConv) to reconstruct the feature extraction network, reducing model parameters and computational load without sacrificing feature extraction capability; (2) the design of a reparameterized C2f module (RepC2f) by integrating the RepVGG structure to enhance multi-scale feature fusion; and (3) the incorporation of an efficient channel attention (ECA) mechanism to dynamically weight feature channels, thereby improving the detection accuracy of defects.


Bifacial Solar Panel

In this paper, we present a comprehensive study of the YOLOv8n-DRE model, detailing its architecture, training process, and performance evaluation. We conduct extensive experiments on a dataset of solar panel images containing three typical defect types: scratches, broken grids, and dirt. The results demonstrate that our proposed model significantly improves detection accuracy while reducing computational complexity, offering an efficient solution for solar panel defect detection.

YOLOv8n Model Principles

YOLOv8 is a single-stage object detection algorithm that aims to achieve the highest speed and accuracy in real-time applications. It supports various vision tasks including classification, detection, segmentation, pose estimation, and tracking. Based on network depth and width, YOLOv8 comes in five versions: YOLOv8n, YOLOv8s, YOLOv8m, YOLOv8l, and YOLOv8x. For solar panel defect detection, where small targets such as broken grids and scratches are present, a lightweight model is preferable to maintain high detection speed while minimizing parameters. Therefore, we selected YOLOv8n, which offers the smallest size and highest accuracy among the versions, as our baseline model for improvement.

The network structure of YOLOv8n consists of three main parts: the backbone, the neck, and the head. The backbone is responsible for extracting features from the input image. It is composed of basic convolution units (Conv), a Spatial Pyramid Pooling-Fast (SPPF) module, and C2f modules that enhance feature extraction capability. The neck part employs multi-scale feature fusion technology, combining ideas from the Path Aggregation Network (PAN) and Feature Pyramid Network (FPN) to fuse features from different stages of the backbone, thereby enhancing feature representation. The head adopts a task-decoupled design, independently optimizing the classification and regression branches. This decoupled structure effectively alleviates the conflict between classification and localization tasks, improving the simultaneous detection capability for multiple types of defects.

Improved YOLOv8n-DRE Model

To achieve lightweighting of the YOLOv8n model while improving detection accuracy for solar panel surface defects, we made the following improvements to the YOLOv8n network. First, we introduced a lightweight depthwise separable convolution (DWConv) module to replace the regular convolution (Conv), reducing model parameters and computational costs. Second, we combined the RepVGG network with the C2f module to propose a RepC2f module, replacing the traditional C2f module to improve detection accuracy. Finally, we integrated an efficient channel attention (ECA) mechanism into the backbone network to enhance feature attention and improve target detection accuracy.

Depthwise Separable Convolution (DWConv) Module

The application of depthwise separable convolution (DWConv) in the YOLOv8 backbone can reduce the number of parameters and improve inference speed. It consists of two parts: depthwise convolution and pointwise convolution. In depthwise convolution, each input channel is convolved with a separate filter, generating a corresponding output channel. This operation primarily captures the spatial information of the input data. Pointwise convolution is a 1×1 convolution operation that convolves all channels of the input at each position. It can be seen as a convolution operation performed along the channel dimension of the input data without involving spatial information. It linearly combines feature maps from different channels generated by depthwise convolution, further reducing the number of parameters by lowering the input channel dimension.

The main advantage of using depthwise separable convolution is the reduction in computational cost and parameter count, while maintaining relatively high performance and improving detection efficiency and speed. Compared with standard convolution, DWConv shows significant differences in structure, parameter count, and computational cost.

Let the convolution kernel size be $D_K \times D_K$, input channels be $M$, output channels be $N$, and output feature map size be $D_F \times D_F$. For standard convolution, the parameter count and computational cost are given by:

$$ 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 $$

For depthwise separable convolution, which includes depthwise and pointwise convolutions, the depthwise convolution kernel size is $D_K \times D_K \times 1$, and the number of kernels is $M$, resulting in a parameter count of $D_K \times D_K \times M$. The pointwise convolution kernel size is $1 \times 1 \times M$, and the number of kernels is $N$, giving a parameter count of $M \times N$. Thus, the total parameter count for DWConv is:

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

For computational cost, each depthwise convolution kernel performs $D_F \times D_F$ multiply-accumulate operations, resulting in $D_K \times D_K \times M \times D_F \times D_F$. Each pointwise convolution kernel also requires $D_F \times D_F$ operations, giving $M \times N \times D_F \times D_F$. Therefore, the total computational cost for DWConv is:

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

The ratios of parameter count and computational cost between DWConv and standard convolution are:

$$ \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} $$

These equations clearly show that DWConv has significantly fewer parameters and lower computational cost compared to standard convolution.

RepC2f Module

RepVGG is an innovative convolutional neural network architecture that uses structural reparameterization to allow the model to use complex structures during training while simplifying through optimization during inference. In the training phase, RepVGG uses multiple convolution operations, including 1×1 and 3×3 convolutions, and sums their outputs. The convolution operation can be represented as:

$$ Y = Conv_{1\times1}(X) + Conv_{3\times3}(X) $$

where $X$ is the input feature map and $Conv(X)$ is the output of the convolution operation. In the inference phase, RepVGG merges the multiple convolution operations from the training phase into a single, more efficient convolution. The structural reparameterization process can be represented as:

$$ Y_{efficient} = Conv_{merged}(X) $$

where $Conv_{merged}$ is the efficient convolution kernel obtained by merging the multiple convolution operations from the training phase. RepVGG enables the possibility of complex training and simple inference, greatly improving computational efficiency during inference while maintaining the complexity and high performance of the training phase.

In our improved YOLOv8n, we combined the RepVGG network with the C2f module to introduce the reparameterized C2f module, called RepC2f, which enhances feature extraction capability. The RepC2f module first reduces the channel dimension of the input $X$ through Conv1×1 to generate $X_1$. Then, it enters two parallel convolution branches, and the outputs of the two branches are summed and passed through BN2d to generate feature $X_2$. Next, $X_1$ and $X_2$ are concatenated along the channel dimension to form a rich feature representation. The concatenated features are then fused again through Conv1×1 to generate the final output. This design allows the RepC2f module to leverage the powerful feature extraction capability of the complex multi-branch structure during training, while achieving computational efficiency during inference through structural reparameterization.

ECA Module

Some defects on the surface of solar panels, such as broken grids and dirt, appear as local, low-contrast regions in the image, with small differences from normal areas. Additionally, solar panel images contain interference factors such as reflections and shadows, which can easily lead to false detections. To enhance the weight of key feature channels and suppress irrelevant background or noise interference, we introduced an efficient channel attention (ECA) mechanism into YOLOv8n. ECA uses lightweight channel-level feature recalibration to make the solar panel defect detection model focus more on key regions, enhancing the model’s sensitivity to defect features at a very low cost, thereby improving detection capability for small or complex defects.

The ECA module first performs global average pooling (GAP) on the input feature map. Then, it learns features through a 1D convolution. The output is passed through a Sigmoid activation function to ensure the output is between 0 and 1, obtaining the weight for each channel of the feature layer. The normalized output is then dimensionally transformed to restore its shape. Finally, the channel attention weights obtained in the previous step are multiplied by the original input feature map to obtain the final result. By incorporating ECA into the YOLOv8n backbone, we reduce false detection rates for small target defects such as broken grids and dirt, improving detection accuracy and robustness while maintaining computational efficiency.

Experimental Results and Analysis

Experimental Environment and Parameter Settings

All training and testing tasks were conducted in the same environment to ensure the effectiveness of the YOLOv8n-DRE algorithm. The experimental environment configuration is summarized in the following table.

Experimental Environment Configuration
Environment Name Configuration
Operating System Windows 10
GPU NVIDIA GeForce GTX 3060
Memory (GB) 16
Python 3.8
Deep Learning Framework PyTorch 1.13

The experimental parameters were set as follows: image size of 640×640 pixels, cosine annealing learning rate strategy (cos_lr=True), batch size of 16, SGD optimizer, and epochs of 200. Other parameters were set to their default values.

Dataset

The dataset used in this study was collected at a photovoltaic power station of a Beijing electric power company. The original dataset consisted of 2,831 images, which were filtered to 2,600 images. The images contain three typical defect types: scratches (Crack), dirt (Spot), and broken grids (Grid). The dataset was split into training and validation sets at a ratio of 4:1, resulting in 2,080 training images and 520 validation images. All images were fully annotated using the labelImg tool.

Evaluation Metrics

To evaluate the performance of the YOLOv8n-DRE network structure, we used metrics such as parameter count, computational cost (GFLOPs), precision (P), recall (R), and mean average precision (mAP). The parameter count and computational cost measure the model complexity and computational efficiency. Precision is the proportion of correctly detected objects among all detected objects, while recall is the probability that real objects are detected. mAP is calculated at an IoU threshold of 0.5. The formulas for these metrics are:

$$ P = \frac{TP}{TP + FP} $$
$$ R = \frac{TP}{TP + FN} $$
$$ AP = \int_{0}^{1} PR \, dR $$
$$ mAP = \frac{1}{N} \sum_{i=1}^{N} AP_i $$

where TP and FP are the numbers of true and false positives, respectively; FN is the number of false negatives; N is the number of target classes; and $AP_i$ is the average precision for the i-th class.

Ablation Experiments

We conducted ablation experiments to verify the effectiveness of each improvement module. The experiments involved introducing the DWConv module, RepC2f module, and ECA module into the original YOLOv8n model. The results are summarized in the following table.

Ablation Experiment Results
Model DWConv RepC2f ECA Parameters (×10^6) GFLOPs P (%) R (%) mAP@0.5 (%)
YOLOv8n 3.006 8.1 85.7 76.1 80.3
YOLOv8n-D 2.911 7.4 84.1 74.3 79.3
YOLOv8n-R 3.006 8.1 87.5 79.6 83.0
YOLOv8n-E 3.039 8.2 87.1 81.2 85.5
YOLOv8n-DR 2.911 7.4 86.7 80.1 81.6
YOLOv8n-DRE 2.944 7.5 89.2 83.0 87.0

From the ablation experiment results, we can observe that introducing the DWConv module into the YOLOv8n backbone significantly reduced the parameter count and computational cost, with GFLOPs decreasing by 8%. However, precision and mAP@0.5 also decreased slightly. When the RepC2f and ECA modules were introduced separately, although the parameter count and computational cost increased slightly, precision and mAP@0.5 both improved. Our proposed YOLOv8n-DRE model achieved a good balance: while the parameter count and computational cost were reduced, precision, recall, and mAP@0.5 improved by 4.0%, 9.1%, and 8.3%, respectively, compared to the original YOLOv8n model. These results demonstrate that our improved model is more lightweight and achieves significantly higher detection accuracy for solar panel defects.

Comparative Experiments

To further verify the effectiveness of our algorithm, we conducted comparative experiments using the same dataset and experimental environment, comparing our YOLOv8n-DRE model with other mainstream solar panel defect detection algorithms, including Faster R-CNN, YOLOv5m, YOLOv5s, YOLOv7, and YOLOv9. The results are summarized in the following table.

Comparative Experiment Results
Model Parameters (×10^6) 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.944 7.5 89.2 83.0 87.0

From the comparative experiment results, Faster R-CNN showed disadvantages in model complexity and detection accuracy. YOLOv5s had lower parameter count and computational cost compared to YOLOv5m, YOLOv7, and YOLOv9, but still higher than our model. YOLOv5m and YOLOv9 achieved slightly higher recall and mAP@0.5 than our model, but their precision was lower, and their parameter count and computational cost were significantly higher. Considering both model lightweighting and accuracy, our YOLOv8n-DRE model demonstrates superior performance. It effectively detects small target defects such as broken grids without missing detections, meeting the requirements for detecting different defect types in practical applications.

Conclusion

In this study, we proposed a lightweight model, YOLOv8n-DRE, based on a reparameterized structure and an improved YOLOv8n framework for solar panel defect detection. By introducing depthwise separable convolution (DWConv), we effectively reduced the model’s parameter count and computational cost, validating the effectiveness of the lightweight design. The integration of the reparameterized structure with the C2f module (RepC2f) significantly improved the sensitivity to defects such as broken grids and dirt through multi-scale feature fusion, thereby enhancing detection accuracy. The incorporation of the efficient channel attention (ECA) mechanism strengthened the saliency of defect regions and reduced interference from complex backgrounds.

Experimental results demonstrated that the final YOLOv8n-DRE model achieved significant progress in both reducing model complexity and improving detection accuracy. The model provides an effective solution for lightweight and high-precision solar panel surface defect detection. Future work will focus on optimizing the model’s generalization ability under varying illumination conditions, enhancing its environmental adaptability, and further improving detection capability for a wider variety of defects.

Scroll to Top