Solar Panel Defect Detection Using Improved YOLO Algorithms

With the global push toward carbon neutrality and the “dual carbon” strategic goals, solar power generation has rapidly become one of the most important sources of renewable energy worldwide. Solar panels are the core components of photovoltaic systems, converting sunlight directly into electricity through the photovoltaic effect. The quality of solar panels directly determines the system’s operational stability, power conversion efficiency, and service lifespan. Any surface defect, whether introduced during manufacturing or through long-term environmental exposure, can significantly degrade the performance of solar panels and potentially lead to complete system failure. Therefore, developing reliable and efficient defect detection methods for solar panels is of paramount practical importance. In the industrial quality inspection workflow, a key challenge is simultaneously achieving high defect recognition accuracy and computational efficiency. Most existing detection approaches fail to strike an optimal balance between algorithmic complexity and detection precision. Furthermore, subtle surface defects on solar panels—such as micro-scratches, hairline cracks, and localized hot spots—remain particularly difficult to identify accurately. Motivated by these challenges, I have conducted extensive research on optimizing defect detection algorithms for solar panels based on the YOLO (You Only Look Once) framework, leading to the development of two specialized detection algorithms: LPV-YOLO and PVA-YOLO.

The remainder of this article is organized as follows. In the first section, I present the background and motivation for solar panel defect detection. Next, I review the relevant literature on both traditional and deep learning-based defect detection methods. I then describe the LPV-YOLO algorithm in detail, including the lightweight architecture design, the dataset construction strategy, and comprehensive experimental validation. Following that, I introduce the PVA-YOLO algorithm, which focuses on enhancing detection accuracy for small-scale defects. Finally, I summarize the findings and outline directions for future work.

Symbol Meaning
CNN Convolutional Neural Network
YOLO You Only Look Once
FPN Feature Pyramid Network
PAN Path Aggregation Network
SPP Spatial Pyramid Pooling
SE Squeeze-and-Excitation
CA Coordinate Attention
PAM Parallel Attention Module
mAP Mean Average Precision
FPS Frames Per Second

1. Background and Motivation

The energy sector is undergoing a major transformation as nations seek to reduce greenhouse gas emissions and mitigate the effects of climate change. Renewable energy sources such as wind, tidal, and solar power are gaining increasing attention owing to their sustainability and environmental friendliness. Among these, solar energy stands out because sunlight is universally available and generally abundant throughout the year. Consequently, solar power generation offers significant advantages in terms of low cost, scalability, and ease of installation, making it a widely adopted renewable energy solution.

A typical photovoltaic power generation system is composed of four main components: solar panels, photovoltaic inverters, control cabinets, and cables. Solar panels are the heart of the system, responsible for converting solar radiation into electrical energy through the photovoltaic effect. The generated electricity can either be stored in batteries for later use or directly supplied to the grid. The performance of solar panels is therefore critical; any defect on their surface compromises both the system’s efficiency and its operational lifetime. The manufacturing process of solar panels is highly complex and involves multiple coupled factors. Any anomaly during fabrication can lead to surface defects, which not only reduce power conversion efficiency but also shorten the service life and potentially cause the entire photovoltaic system to malfunction. Hence, timely and accurate identification of defective products through effective quality control and monitoring has become essential to improving production efficiency and reducing costs in the solar panel industry.

Traditional solar panel surface defect inspection methods rely predominantly on manual visual examination. A human inspector directly observes the surface of solar panels to identify defects. While this approach is operationally simple, it suffers from severe limitations. The effectiveness of manual inspection depends heavily on the worker’s experience and sustained attention. As working hours increase, attention levels decline, resulting in reduced accuracy and efficiency. Moreover, subtle or low-contrast defects such as micro-cracks and faint scratches are often imperceptible to the human eye, leading to frequent missed detections and allowing defective products to enter the market. From an economic standpoint, manual inspection demands a large workforce, imposing significant labor costs on large-scale solar panel manufacturers. With the increasing integration of deep learning and Industry 4.0 technologies, automated defect detection systems driven by deep learning have become widely utilized in manufacturing quality control. These systems automatically learn to extract meaningful features from images through iterative training, resulting in strong generalization capabilities and robust detection performance, thereby serving as an effective alternative to labor-intensive manual inspection.

2. Literature Review

2.1 Traditional Defect Detection Methods

Before the widespread adoption of deep learning, solar panel defect detection primarily relied on traditional machine vision and image processing techniques. These methods focused on extracting and analyzing surface features such as texture, color, and shape from captured images. Texture features capture repetitive local patterns on the image surface, which are indicative of irregularities caused by manufacturing defects, contamination, or damage. For example, multi-scale texture features have been extracted using encoding modules and combined with global feature rearrangement to reconstruct normal texture backgrounds in comparison with defective regions. Color features are particularly useful for detecting discoloration caused by contamination, corrosion, or material aging. Histogram-based approximations and gray-level quantization algorithms have been used to localize defects efficiently. Shape features, on the other hand, help identify clearly defined anomalies. Hough transform combined with mathematical morphology has been employed to detect potential defect regions, achieving high accuracy in specific applications.

Despite the contributions of traditional image processing methods, they exhibit notable limitations when confronted with large-scale datasets and diverse defect types. The manually designed features are inherently constrained and unable to comprehensively capture the nuances of various defects, especially when defect types are numerous and morphologically complex. Moreover, traditional approaches are highly sensitive to environmental variations such as illumination changes, weather conditions, and viewing angles, making them vulnerable to image noise and leading to reduced accuracy. Although texture and color feature computations are relatively inexpensive, processing large volumes of solar panel images still imposes considerable computational burdens in practice.

2.2 Deep Learning-Based Defect Detection

With the rapid advancement of deep learning, convolutional neural networks (CNNs) have become dominant in computer vision applications, substantially improving the accuracy and efficiency of solar panel defect detection. CNNs automatically extract and learn the most effective feature representations from massive annotated datasets, eliminating the tedious process of manual feature engineering. Through multiple convolutional and pooling layers, CNNs capture hierarchical features ranging from low-level edges and textures to high-level semantic structures. These models demonstrate remarkable robustness under varying illumination, shadows, reflections, and surface contamination. By training on large-scale datasets, deep learning-based methods enable rapid and accurate defect identification in high-volume production environments, and transfer learning techniques further alleviate the problem of insufficient annotated samples.

The evolution of CNN architectures has driven corresponding advances in defect detection. Early successes included LeNet-5 for handwritten digit recognition and AlexNet for large-scale image classification, followed by deeper networks such as VGGNet, GoogLeNet, and the residual network ResNet. In object detection, R-CNN first combined region proposal with CNN feature extraction, and subsequent improvements including Fast R-CNN and Faster R-CNN refined both accuracy and speed. The YOLO family of detectors pioneered the regression-based single-stage paradigm, achieving remarkable real-time detection performance. Subsequent versions have continuously improved accuracy, multi-scale detection, and computational efficiency, making YOLO a top choice for industrial applications.

In the specific domain of solar panel defect detection, many studies have addressed dataset scarcity and class imbalance by employing generative adversarial networks (GANs) for data augmentation. Other research has focused on enhancing feature extraction and fusion to improve the detection of small defects, such as incorporating multi-scale prediction layers, feature enhancement modules, and designed attention mechanisms. Lightweight models inspired by MobileNet and GhostNet have been developed to reduce computational cost, making real-time detection feasible on resource-constrained hardware. Studies combining segmentation and detection have also succeeded in avoiding false positives for hot-spot defects. Although these approaches represent significant progress, the dialectic between detection accuracy and model complexity remains an open and challenging problem, particularly for tiny defects on solar panels.

3. LPV-YOLO: A Lightweight Detection Method for Solar Panels

3.1 Overview of the LPV-YOLO Architecture

To address the issue of excessive parameters in existing solar panel defect detection models and the difficulty of balancing speed and accuracy, I propose LPV-YOLO, a lightweight network based on the YOLOv5s architecture. The overall structure of the LPV-YOLO network consists of four components: an input processing module, a lightweight backbone network, a neck network with enhanced attention, and the detection head. The design goal of LPV-YOLO is to significantly reduce the computational cost while maintaining comparable or better detection accuracy compared with the baseline YOLOv5s model.

The proposed architecture integrates several novel improvements over YOLOv5s. First, by replacing traditional convolution operations with the Ghost module and applying the Mish activation function, I construct two lightweight building blocks, namely GhostMConv and C3MGhost, which form the fundamental units of the lightweight backbone. Second, I enhance the spatial pyramid pooling module by incorporating the SimAM attention mechanism, resulting in the MSSPPF module that mitigates the accuracy loss caused by model compression without increasing computational burden. Third, I embed the Squeeze-and-Excitation (SE) channel attention mechanism in the neck network to strengthen the model’s ability to extract subtle defect features.

The parameter count of LPV-YOLO is remarkably reduced relative to YOLOv5s. Specifically, the total number of model parameters is 3.71M, while the baseline YOLOv5s contains 7.23M parameters, representing a reduction of approximately 49%. The model size is compressed to 7.4MB, and the computational cost is only 8.3 GFLOPs. In experimental evaluations, LPV-YOLO achieves a mean Average Precision (mAP) of 93.8% on my solar panel defect detection dataset, while operating at 70.4 FPS, comfortably meeting the real-time requirements of industrial inspection scenarios.

3.2 Lightweight Backbone Network

The backbone’s lightweight design relies on the Ghost module, which was originally proposed to reduce the redundant computation present in standard convolutions. In conventional convolution, the output feature maps contain a large degree of redundancy: many feature maps are similar and can be regarded as “ghost” representations of each other. The Ghost module capitalizes on this observation by first generating a small number of intrinsic feature maps with a standard convolution and then applying a series of cheap linear operations to these intrinsic maps to generate additional ghost feature maps, which are finally concatenated to form the complete output tensor. This process dramatically reduces the number of floating-point operations and parameters.

When the input feature map has \(c\) channels and spatial dimensions \(h \times w\), and the output feature map has \(n\) channels with dimensions \(h’ \times w’\), with a standard convolution kernel size of \(k\), the computational cost of the standard convolution is:

$$C_{standard} = n \cdot h’ \cdot w’ \cdot c \cdot k \cdot k$$

For the Ghost module, assuming each intrinsic feature map generates \(s\) ghost feature maps, the number of intrinsic feature maps is \(\frac{n}{s}\). Among the final \(n\) output maps, one is the identity map and the remaining \(s-1\) are produced via cheap linear operations with kernel size \(d\). The total computational cost of the Ghost module is therefore:

$$C_{ghost} = \frac{n}{s} \cdot h’ \cdot w’ \cdot c \cdot k \cdot k + (s-1) \cdot \frac{n}{s} \cdot h’ \cdot w’ \cdot d \cdot d$$

The compression ratio achieved by the Ghost module can be calculated as:

$$r = \frac{C_{standard}}{C_{ghost}} = \frac{n \cdot h’ \cdot w’ \cdot c \cdot k \cdot k}{\frac{n}{s} \cdot h’ \cdot w’ \cdot c \cdot k \cdot k + (s-1) \cdot \frac{n}{s} \cdot h’ \cdot w’ \cdot d \cdot d} \approx \frac{s \cdot c}{c + s – 1} \approx s$$

In practice, since the number of input channels \(c\) is generally large and the number of linear transformations \(s\) is much smaller than \(c\), the computation is reduced by approximately a factor of \(s\).

I further enhanced the Ghost module by applying the Mish activation function, which is defined as:

$$Mish(x) = x \cdot \tanh(\ln(1 + e^x))$$

The Mish function is a smooth, non-monotonic activation function that provides better gradient flow and helps to avoid vanishing gradients during training. I built the GhostMConv module by integrating the Mish activation with the Ghost module, replacing the standard convolutional layers in YOLOv5s (except for the first layer) with the new GhostMConv module. Additionally, I constructed the C3MGhost module, which combines the GhostBottleneck structure with the Mish activation and is used to replace the original C3 modules in the backbone and neck networks.

Module Components Function
GhostMConv Ghost module + BatchNorm + Mish Reduces parameters and FLOPs
C3MGhost 3 GhostMConv + Bottleneck + Concat Lightweight feature extraction
MSSPPF Conv + 3 MaxPool + Concat + SimAM Multi-scale feature fusion with attention
SE GlobalPool + FC + ReLU + FC + Sigmoid Channel-wise feature recalibration

3.3 MSSPPF: Improved Spatial Pyramid Pooling Module

The original YOLOv5s backbone incorporates a spatial pyramid pooling (SPP) layer at its end to achieve multi-scale feature fusion. The SPP layer applies three max-pooling operations with different kernel sizes in parallel, and concatenates their outputs together with the unprocessed features. While effective at aggregating multi-scale information, the SPP operation may discard some subtle details that are critical for detecting fine-grained defects on solar panels. To address this, I propose an enhanced spatial pyramid pooling module named MSSPPF (Mish-SimAM-Spatial Pyramid Pooling-Fast).

The MSSPPF module is constructed by modifying the SPP module in the following ways. First, the different-sized max-pooling kernels are replaced with kernels of the same size arranged in a serial configuration, which reduces redundant computation and improves processing speed. Second, the Mish activation function is introduced in the module to enhance the network’s expressive capability. Finally, a parameter-free attention module called SimAM is inserted before the output. SimAM assigns attention weights to neurons based on an energy function that measures the linear separability between the target neuron and its surrounding neurons. The energy function is defined as:

$$e_t = \frac{4(\sigma^2 + \lambda)}{(t – \hat{\mu})^2 + 2\hat{\sigma}^2 + 2\lambda}$$

Here, \(t\) represents the target neuron (i.e., the pixel value in the feature map), \(\hat{\mu}\) and \(\hat{\sigma}^2\) are the mean and variance of all neurons across the channel, and \(\lambda\) is the regularization coefficient. A lower energy value \(e_t\) indicates that the target neuron is more distinct from its surroundings and thus more important for the detection task. The attention weight is derived using the sigmoid function, and the final output is computed as:

$$\tilde{X} = sigmoid\left(\frac{1}{E}\right) \odot X$$

where \(E\) denotes the matrix of all energy values across channel and spatial dimensions, and \(\odot\) represents element-wise multiplication. This formulation allows the module to adaptively focus on salient features without adding any trainable parameters, thereby enhancing the representational power of the output feature maps without increasing computational overhead.

3.4 SE Attention in the Neck Network

The lightweight design inevitably reduces the model’s representational capacity to some extent, which may cause a slight degradation in detection accuracy. To compensate for this loss, I embed the SE (Squeeze-and-Excitation) channel attention module into the neck network of LPV-YOLO after each C3MGhost module. The SE module explicitly models the interdependencies between feature channels and recalibrates the channel-wise responses accordingly. It consists of two main operations: squeeze and excitation.

In the squeeze step, global average pooling is applied to each channel of the input feature map, producing a channel descriptor vector that summarizes the global information of each channel. In the excitation step, two fully connected layers with a reduction ratio are employed to capture channel-wise dependencies and generate a set of per-channel scaling weights. These weights are then multiplied by the original feature map to emphasize informative channels while suppressing less important ones. The SE module enables LPV-YOLO to allocate more attention to channels that carry discriminative defect-related information, thereby enhancing detection accuracy, particularly for subtle defects on solar panels.

3.5 Dataset Construction and Preprocessing

The experimental dataset used in this study is the PV-Multi-Defect dataset, which contains 1,107 images with a pixel resolution of \(600 \times 600\). Each image contains multiple defects of varying scales, covering five annotated defect types: breakage, scratches, hot spots, black edges, and power loss. The characteristics of these defect types vary considerably: breakage appears as irregular dark regions often accompanied by scratches; scratches are typically faint thin lines with contrast close to the background; hot spots appear as white bright regions often occurring in clusters; black edges are narrow dark bars commonly found at the boundaries of photovoltaic cells; and power loss appears as relatively regular rectangular regions with large physical extent.

After inspecting the dataset, I identified issues including missing labels and imprecise annotations. I therefore re-annotated the dataset using the LabelImg tool, increasing the number of labels from 4,235 to 4,631. To further mitigate the sample imbalance problem, I employed Cycle-GAN to generate additional defect images and expand the dataset. Cycle-GAN enables unpaired image-to-image translation by preserving the content of the input image while transferring its style. The architecture comprises two generators and two discriminators, with a cycle-consistency loss ensuring that the image translated by one generator and then translated back by the other closely resembles the original input. The total loss function of Cycle-GAN is expressed as:

$$Loss = Loss_{GAN} + Loss_{cycle}$$

where \(Loss_{GAN}\) ensures that the generated images are indistinguishable from real images, and \(Loss_{cycle}\) preserves the content consistency. The GAN loss is given by:

$$L_{GAN} = \mathbb{E}_{y \sim P_{data}(y)}[\log D_Y(y)] + \mathbb{E}_{x \sim P_{data}(x)}[\log(1 – D_Y(G(x)))] + \mathbb{E}_{x \sim P_{data}(x)}[\log D_X(x)] + \mathbb{E}_{y \sim P_{data}(y)}[\log(1 – D_X(G(y)))]$$

By applying Cycle-GAN, I expanded the dataset to 4,463 images, increasing the total number of defect instances from 4,094 to 14,444. The augmented dataset was then split into training and validation sets in an 8:2 ratio, ensuring that the validation set only contains original images.

3.6 Training Configuration and Evaluation Metrics

All experiments were conducted on a Windows 10 system with an NVIDIA GeForce RTX 2080Ti GPU, Python 3.8, and CUDA 11.1. Input images were resized to \(640 \times 640\). The training configuration included the SGD optimizer, 300 epochs, a batch size of 16, momentum of 0.937, initial learning rate of 0.001, weight decay of 0.0005, and IoU threshold of 0.5.

To evaluate the performance of LPV-YOLO, I used the following metrics: mean Average Precision (mAP@0.5 and mAP@0.5:0.95), parameter count, model file size, computational complexity in GFLOPs, and frames per second (FPS). The precision, recall, and mAP are defined as follows:

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

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

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

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

Here, TP, FP, and FN denote the numbers of true positives, false positives, and false negatives, respectively.

3.7 Experimental Results for LPV-YOLO

I conducted comprehensive experiments to evaluate the performance of LPV-YOLO. The training and validation loss curves indicated that the model converged smoothly, with the box loss stabilizing at approximately 0.03, confidence loss below 0.015, and classification loss approaching zero. The P-R curve for the solar panel defect detection task revealed that LPV-YOLO achieves an impressive mAP@0.5 of 93.8%. The per-class detection results show that the model attains an AP of 93.2% for breakage, 92.5% for hot spots, 97.1% for black edges, 87.0% for scratches, and 99.1% for power loss defects.

The detection capability varies across defect categories. For relatively regular-shaped defects such as power loss and black edges, the detection accuracy reaches as high as 99.1% and 97.1%, respectively, benefiting from the efficient feature extraction of the GhostMConv module and the semantic enhancement provided by the SE attention mechanism. For irregularly shaped defects like breakage and hot spots, the detection accuracy exceeds 92%. However, for scratches—which are subtle and extremely thin—the detection accuracy is 87.0%, slightly lower than other categories, primarily because the FPN/PAN neck structure in lightweight designs relies more heavily on high-level semantic features, thereby weakening the fusion weights of shallow detail features. Despite this, LPV-YOLO demonstrates overall excellent performance on the solar panel defect detection task, successfully detecting all five types of defects with high accuracy.

3.8 Ablation Study for LPV-YOLO

I performed four groups of ablation experiments to validate the contribution of each improvement module. The baseline model (BL) is YOLOv5s. The experimental configurations include: YOLOv5s, YOLOv5s+MGhost, YOLOv5s+MGhost+MSSPPF, and the complete LPV-YOLO model. The results are presented in the following table.

Model mAP/% Parameters/M Model Size/MB FLOPs/G FPS
Baseline (YOLOv5s) 94.4 7.23 13.70 16.5 91.7
BL + MGhost 92.1 3.70 7.42 8.2 67.1
BL + MGhost + MSSPPF 93.3 3.70 7.36 8.2 65.5
LPV-YOLO 93.8 3.71 7.40 8.3 70.4

From the ablation study, I can draw the following conclusions. First, the MGhost module significantly reduces the parameter count, model size, and computational cost of the network, confirming its effectiveness in model compression. Specifically, the parameter count drops from 7.23M to 3.70M, and the computational cost drops from 16.5 to 8.2 GFLOPs. Second, the MSSPPF and SE modules enhance the detection accuracy by 1.2% and 0.5%, respectively, without noticeably increasing the parameter count or computational overhead. This demonstrates that the proposed attention-based compensation strategies effectively restore and improve the detection capability lost through network compression. Overall, LPV-YOLO achieves a 49% reduction in parameters, a 46% reduction in model size, and a 50% reduction in computational load, while incurring only a 0.6% decrease in mAP compared with the baseline. This favorable trade-off demonstrates that LPV-YOLO is well suited for deployment on low-resource hardware in industrial contexts.

3.9 Comparison with Other Detection Models

To further validate the overall performance of LPV-YOLO, I compared it with multiple mainstream object detection networks, including YOLOv7, SSD, RetinaNet, Faster R-CNN, YOLOv8, YOLOv9c, YOLOv10s, and two other improved models. The comparison results are shown below.

Model mAP/% Parameters/M Model Size/MB FLOPs/G FPS
YOLOv5s 94.4 7.23 13.7 16.5 91.7
YOLOv7 88.0 9.33 19.0 26.7 107.5
SSD300 77.7 34.30 90.0 51.6 71.0
RetinaNet 72.2 41.90 139.0 212.0 42.9
Faster R-CNN 87.8 43.44 185.1 172.3 27.0
YOLOv8 92.7 11.20 22.4 28.6 102.0
YOLOv9c 93.7 98.0 98.0 82.6 96.0
YOLOv10s 90.6 8.20 32.8 26.8 167.2
LPV-YOLO 93.8 3.71 7.4 8.3 70.4

As shown in the table, LPV-YOLO achieves the highest mAP among all evaluated models except for the superior accuracy of the two-stage Faster R-CNN and the original YOLOv5s. Notably, LPV-YOLO delivers a mAP of 93.8%, which is higher than YOLOv7, SSD, RetinaNet, YOLOv8, YOLOv9c, and YOLOv10s. At the same time, LPV-YOLO possesses the smallest parameter count, model size, and computational cost, confirming that the proposed lightweight architecture achieves an excellent balance between detection accuracy and computational efficiency. The inference speed of 70.4 FPS exceeds the real-time requirement of industrial applications, making LPV-YOLO a practical and cost-effective solution for automated solar panel inspection.

4. PVA-YOLO: An Attention-Based Detection Method for Enhanced Precision

4.1 Overview of the PVA-YOLO Architecture

While LPV-YOLO achieves a favorable balance between speed and accuracy, the detection of subtle defects—particularly scratches and micro-cracks on solar panels—remains a bottleneck. To address this challenge, I propose the PVA-YOLO algorithm, which builds on the YOLOv9 architecture. This network integrates three novel innovations: k-means++ clustering for anchor optimization, a redesigned feature extraction module named RepNCSPELAN_TCA that combines multi-branch reparameterization with coordinate attention, and a parallel joint attention mechanism (PAM) that simultaneously enhances channel and spatial feature representations. These improvements collectively aim to boost the detection accuracy of both conventional and subtle defects on solar panels.

The YOLOv9 model provides an ideal foundation due to its innovative architecture. It introduces Programmable Gradient Information (PGI), which addresses the information bottleneck problem in deep supervision. PGI comprises a main branch, an auxiliary reversible branch, and multi-level auxiliary information that collectively generate reliable gradients and prevent the loss of important information during propagation. Additionally, YOLOv9 employs the Generalized Efficient Layer Aggregation Network (GELAN), which optimizes parameter efficiency and gradient flow. These advancements make YOLOv9 a powerful real-time object detection framework.

4.2 Anchor Optimization Using k-means++

The defects present in the solar panel dataset vary significantly in size, with some exhibiting extreme aspect ratios. The original YOLOv9 uses a set of default anchors that may not align well with the actual defect scale distribution. To address this, I applied the k-means++ clustering algorithm to generate prior anchor boxes that better match the dimensions and shapes of defects in the training dataset. This approach improves the matching degree between predicted bounding boxes and ground-truth boxes, accelerates convergence during training, and enhances detection accuracy for defects with different scales.

The k-means++ algorithm improves the initialization of cluster centers compared with standard k-means, reducing the risk of poor local optima and improving the quality of clustering results. The algorithm proceeds as follows:

Step 1: Randomly select an initial cluster center from the dataset.

Step 2: For each sample \(x\), compute its distance to the nearest cluster center using the formula:

$$D(x) = \min_{c \in C} \| x – c \|^2$$

where \(C\) is the set of already selected cluster centers.

Step 3: Select the next cluster center using a probability proportional to the squared distance \(D(x)^2\), calculated as:

$$P(x) = \frac{D(x)^2}{\sum_{x’ \in X} D(x’)^2}$$

Step 4: Repeat steps 2–3 until \(k\) cluster centers have been selected.

Step 5: Assign each sample to the nearest cluster center.

Step 6: Recompute the cluster centers as the mean of all samples assigned to each cluster.

Step 7: Repeat steps 5–6 until the cluster centers no longer change.

In this work, I set the number of anchor boxes to 9, corresponding to the three-scale detection heads of YOLOv9 with three anchors per scale. The final anchor sizes generated by k-means++ on my solar panel defect dataset are listed below.

Anchor Index Width Height
1 20 34
2 21 62
3 21 119
4 22 202
5 50 44
6 64 109
7 122 50
8 123 171
9 146 588

These anchors provide a tailored set of prior boxes that significantly improve the matching between predicted boxes and actual defect regions on solar panels, especially for elongated defects such as black edges and power loss regions.

4.3 RepNCSPELAN_TCA: Enhanced Feature Extraction Module

The standard RepNCSPELAN module in YOLOv9 is designed for efficient feature learning but may lack the necessary capability to extract fine-grained detail features critical for small-scale defect detection on solar panels. I therefore redesigned this module by introducing a three-branch reparameterized feature extraction structure and incorporating the coordinate attention mechanism.

The building block, called RepConvN_T, is constructed by concatenating one \(1 \times 1\) convolution with two \(3 \times 3\) convolutions in parallel, following the reparameterization paradigm. In the training phase, multiple parallel branches are active, allowing the model to learn rich feature representations. In the inference phase, the parameters of the multiple branches are fused into a single \(3 \times 3\) convolution through structural reparameterization, thereby reducing computational cost while preserving model capacity. Based on RepConvN_T, I developed the RepNBottleneck_T and RepNCSP_T modules. The final module, RepNCSPELAN_TCA, stacks two RepNCSP_T modules and incorporates a coordinate attention layer at the output. The coordinate attention mechanism encodes positional information into channel attention by decomposing the global pooling into two 1D feature encoding operations, allowing the network to focus on important spatial locations while retaining channel-specific information. This enhancement enables the network to extract more precise and context-aware features from the images of solar panels, leading to improved detection of small and subtle defects.

Component Layers/Operations Role
RepConvN_T 1×1 Conv; 3×3 Conv (×2); Concat Multi-branch reparameterized feature extraction
RepNBottleneck_T RepConvN_T; BN; activation Residual feature learning
RepNCSP_T RepNBottleneck_T; 1×1 Conv; Concat Cross-stage feature fusion
Coordinate Attention 1D pooling; Conv; activation Spatial position-aware channel weighting

4.4 Parallel Joint Attention Module (PAM)

To further improve the detection of fine-grained defects on solar panels, I designed a parallel joint attention mechanism that combines channel attention and spatial attention. The channel attention branch, named ChannelAtt, first applies global average pooling and global max pooling to each channel of the input feature map, capturing both the mean and the peak responses. These pooled features are then passed through shared multi-layer perceptrons (or convolution layers) to generate channel attention weights, which are normalized using the sigmoid function. The spatial attention branch, named SAM, applies average pooling and max pooling along the channel dimension, concatenates the resulting 2D maps, and processes them through a \(7 \times 7\) convolution followed by sigmoid activation to generate a spatial attention map.

Instead of the conventional sequential arrangement of channel attention followed by spatial attention, I adopted a parallel design where the input feature map is simultaneously processed by both attention branches. The outputs of the two branches are then fused with the original feature map via element-wise multiplication and addition. This parallel arrangement allows the model to capture both channel-wise and spatial-wise important features simultaneously, thereby improving the interaction between these two types of information. The formulation of the PAM module is:

$$F_{out} = F_{in} + F_{in} \otimes \sigma(W_c(F_{in})) \otimes \sigma(W_s(F_{in}))$$

where \(F_{in}\) and \(F_{out}\) are the input and output feature maps, \(W_c\) and \(W_s\) represent the channel attention and spatial attention operations, \(\sigma\) is the sigmoid activation, and \(\otimes\) denotes element-wise multiplication. The parallel joint attention module enhances the model’s capacity to focus on the most discriminative features of solar panel defects, leading to improved detection results, particularly for small and low-contrast defects.

4.5 Experimental Settings for PVA-YOLO

The experimental environment for PVA-YOLO consisted of a Windows 10 operating system, an NVIDIA GeForce RTX 4090 GPU, Python 3.8, and CUDA 11.8. Images were resized to \(640 \times 640\). The training hyperparameters were consistent with those used for LPV-YOLO: SGD optimizer, 300 epochs, batch size of 16, momentum of 0.937, initial learning rate of 0.001, and weight decay of 0.0005. The same expanded dataset from the previous chapter was used for training and validation.

The evaluation metrics included precision (P), recall (R), F1 score, mAP@0.5, and mAP@0.5:0.95. The F1 score is defined as:

$$F1 = 2 \times \frac{P \times R}{P + R}$$

These metrics provide a comprehensive evaluation of the model’s classification and localization performance across varying IoU thresholds.

4.6 Experimental Results for PVA-YOLO

The loss curves for PVA-YOLO during training show a rapid decrease in the early epochs, followed by gradual stabilization. After approximately 300 epochs, the box loss, classification loss, and distribution focal loss all converge to below 1.3, indicating that the model has achieved stable and reliable detection performance. The evaluation results demonstrate that PVA-YOLO achieves a mAP@0.5 of 96.3% and a mAP@0.5:0.95 of 76.5%, representing improvements of 2.6% and 7.6% over the baseline YOLOv9 model, respectively.

I further analyzed the per-class detection results and observed that all five defect types benefit from the proposed improvements. Compared with YOLOv9, the detection accuracy for breakage improved by 3.5%, for hot spots by 1.7%, for black edges by 1.7%, for scratches by 5.1%, and for power loss by 0.8%. These results confirm that PVA-YOLO effectively addresses the challenge of detecting subtle defects on solar panels.

4.7 Ablation Study for PVA-YOLO

I performed a series of ablation experiments to validate the contributions of each proposed improvement. The baseline is YOLOv9, and the three improvements are: (a) anchors generated by k-means++, (b) the RepNCSPELAN_TCA feature extraction module, and (c) the parallel joint attention PAM. The results are presented below.

YOLOv9 ① ② ③ Breakage/% Hot Spot/% Black Edge/% Scratch/% Power Loss/% mAP@0.5/% mAP@0.5:0.95/%
✔ 95.0 91.0 97.5 87.1 97.8 93.7 68.9
✔ ✔ 96.7 90.0 97.6 89.9 97.5 94.3 72.7
✔ ✔ 97.8 91.4 99.0 91.4 98.8 95.7 70.0
✔ ✔ 97.7 91.6 99.3 90.2 98.8 95.5 74.4
✔ ✔ ✔ 98.2 91.7 99.4 91.7 98.9 96.0 76.1
✔ ✔ ✔ 97.7 91.3 99.4 92.0 98.8 95.9 75.5
✔ ✔ ✔ 98.1 92.7 99.2 92.2 98.9 96.2 76.2
✔ ✔ ✔ ✔ 98.5 92.7 99.2 92.2 98.6 96.3 76.5

In the table, ① denotes the k-means++ generated anchors, ② denotes the RepNCSPELAN_TCA feature extraction module, and ③ denotes the parallel joint attention PAM. The results clearly demonstrate the effectiveness of each individual component. The k-means++ anchors improve mAP@0.5 by 0.6% and mAP@0.5:0.95 by 3.8%. The RepNCSPELAN_TCA module improves mAP@0.5 by 2.0% and mAP@0.5:0.95 by 1.1%. The PAM attention improves mAP@0.5 by 1.8% and mAP@0.5:0.95 by 5.5%. When all three improvements are applied simultaneously, the final PVA-YOLO model achieves a mAP@0.5 improvement of 2.6% and a mAP@0.5:0.95 improvement of 7.6% over the baseline, confirming that the proposed modifications complement each other and collectively yield substantial performance gains.

4.8 Comparison with State-of-the-Art Models

To benchmark the performance of PVA-YOLO, I compared it with various state-of-the-art object detection models on the solar panel defect dataset. The comparison includes YOLOv5, YOLOX, SSD, Faster R-CNN, YOLOv7, YOLOv8, YOLOv10, YOLOv11, and three other improved models: GHB-YOLO, PB-YOLO, and YOLOv5-scSE.

Model Precision/% Recall/% F1 Score/% mAP@0.5/% mAP@0.5:0.95/%
YOLOv5 88.6 91.2 90.0 93.8 65.1
YOLOX 81.6 86.5 83.9 80.8 49.8
SSD 75.6 81.8 78.6 77.7 45.4
Faster R-CNN 84.5 82.8 65.2 87.8 60.8
YOLOv7 88.4 90.7 89.5 94.2 66.8
YOLOv8 87.5 84.7 86.1 92.7 65.6
YOLOv9 88.9 89.2 89.0 93.7 68.9
YOLOv10 85.3 83.7 84.5 90.6 53.9
YOLOv11 85.0 84.3 84.6 89.7 52.8
GHB-YOLO 90.2 89.8 90.0 93.2 66.3
PB-YOLO 91.0 93.5 92.2 96.5 73.1
YOLOv5-scSE 92.7 91.3 92.0 96.1 75.4
PVA-YOLO 91.6 93.4 92.5 96.3 76.5

The comparison results demonstrate that PVA-YOLO achieves the highest mAP@0.5:0.95 among all evaluated models, reaching 76.5%, and the second-highest mAP@0.5 at 96.3%, closely following PB-YOLO. In terms of precision, recall, and F1 score, PVA-YOLO shows competitive and superior overall performance, with the highest F1 score of 92.5% among all compared models. These findings confirm that PVA-YOLO is a highly effective detector for solar panel surface defects, delivering excellent accuracy and robustness across all five defect categories.

5. Discussion and Comparative Analysis

The two proposed algorithms, LPV-YOLO and PVA-YOLO, address different aspects of the solar panel defect detection problem. LPV-YOLO emphasizes lightweight design and computational efficiency, making it particularly suitable for deployment on resource-constrained edge devices. Its architecture, built on the Ghost module and enhanced with SimAM and SE attention mechanisms, achieves a compact model of only 3.71M parameters and 8.3 GFLOPs while maintaining a mAP@0.5 of 93.8%. This makes LPV-YOLO an excellent choice for real-time applications on embedded systems in the solar panel manufacturing floor. The model’s reduced computational footprint also translates to lower energy consumption and faster inference speeds, which are crucial factors in large-scale industrial settings.

On the other hand, PVA-YOLO focuses on maximizing detection accuracy, particularly for subtle and small-scale defects that are often missed by conventional detectors. By leveraging the powerful YOLOv9 backbone, optimizing anchors with k-means++, enhancing feature extraction with RepNCSPELAN_TCA, and integrating the parallel joint attention module PAM, PVA-YOLO achieves a superior mAP@0.5 of 96.3% and mAP@0.5:0.95 of 76.5% on the same dataset. The significant improvement in mAP@0.5:0.95, which considers multiple IoU thresholds, indicates that PVA-YOLO not only localizes defects accurately but also produces bounding boxes with higher overall quality.

Both models demonstrate superior performance compared to several baseline and state-of-the-art approaches on the solar panel defect detection task. The success of these algorithms can be attributed to the careful combination of domain-specific architecture design, effective feature representation learning, and advanced attention mechanisms. Furthermore, the dataset augmentation approach using Cycle-GAN demonstrates a viable strategy for mitigating the data scarcity problem commonly encountered in industrial defect detection applications, where acquiring large numbers of labeled defective samples is often expensive and time-consuming.

6. Conclusion and Future Directions

In this article, I have presented a comprehensive study on defect detection methods for solar panels based on the YOLO algorithm. I proposed two improvement algorithms, LPV-YOLO and PVA-YOLO, to address the key challenges of balancing detection accuracy and computational efficiency, and improving the detection of subtle defects on solar panels.

The LPV-YOLO algorithm was developed to address the limitation of high model complexity in existing detection models. By designing the GhostMConv and C3MGhost lightweight modules based on the Ghost module and Mish activation function, the model’s parameter count was reduced by 49%, model size by 46%, and computational cost by 50% compared with YOLOv5s. The MSSPPF module, which integrates the SimAM attention mechanism with multi-scale pooling, and the SE attention modules embedded in the neck network, effectively compensated for any accuracy loss from compression, allowing LPV-YOLO to achieve a mAP@0.5 of 93.8% with only 3.71M parameters and 8.3 GFLOPs, running at 70.4 FPS.

The PVA-YOLO algorithm was developed to enhance the detection of small and subtle defects on solar panels. By applying k-means++ clustering to generate anchors better aligned with the defect scale distribution, redesigning the feature extraction module with multi-branch reparameterization and coordinate attention, and introducing a parallel joint attention mechanism, PVA-YOLO achieved a mAP@0.5 of 96.3% and a mAP@0.5:0.95 of 76.5%, representing improvements of 2.6% and 7.6% over YOLOv9, respectively. The ablation study confirmed that each proposed component contributes to the overall performance gain, validating the effectiveness of the presented approach.

The results of this research hold significant implications for the solar energy industry. The ability to quickly and accurately detect surface defects on solar panels helps manufacturers maintain high product quality, reduce waste, and lower production costs. Additionally, the proposed deep learning-based detection methods can be extended to other defect detection applications in industrial settings, bringing the benefits of automation and artificial intelligence to a broader range of manufacturing processes.

However, there are several important directions for future research. First, the current algorithms have been validated primarily in controlled experimental settings. To achieve real-world impact, these models must be integrated with actual industrial inspection systems, which involves addressing challenges related to hardware compatibility, real-time data transmission, and robustness under diverse and unpredictable conditions such as uneven illumination, dust, and reflections. Second, the growing scale of solar panel production calls for the development of distributed detection systems that connect multiple inspection devices and platforms into a unified monitoring framework. Such an IoT-enabled approach would facilitate earlier detection of potential defects, timely maintenance interventions, and extension of solar panel service life.

In conclusion, the research presented in this article demonstrates that thoughtfully designed deep learning architectures based on the YOLO framework can effectively address the challenges of solar panel defect detection. As emerging technologies continue to evolve and integrate with artificial intelligence, the accuracy, efficiency, and intelligence of defect detection systems for solar panels are expected to improve further, contributing to the sustainable development of the solar energy industry and the global transition to renewable energy sources.

Scroll to Top