Research on Defect Detection Algorithms for Solar Panels Based on Deep Learning

In my study, I focus on developing robust defect detection algorithms for solar panels using electroluminescence (EL) imaging and modern deep learning object detection techniques. The rapid expansion of photovoltaic power generation has made the operational safety and efficiency of solar panels increasingly important. Defects such as cracks, black cores, thick lines, broken fingers, and star cracks can significantly reduce the energy conversion efficiency of solar panels and may even cause severe safety hazards, including fire and explosion risks. Therefore, accurate and timely defect detection for solar panels is essential in both manufacturing and maintenance processes. In this work, I first construct a well-annotated EL image dataset for solar panels with five defect categories. Then I propose two improved detection algorithms based on YOLOv5 and YOLOv7, respectively. The first algorithm integrates an efficient channel attention (ECA) module into the backbone network of YOLOv5, achieving a high precision of 97.5%. However, it still suffers from false and missed detections. To solve these issues, I further develop a YOLOv7-based algorithm called YOLOv7-SE-DS-NWD, which incorporates a squeeze-and-excitation (SE) attention module, distribution shifting convolution (DSConv), and a normalized Gaussian Wasserstein distance (NWD) loss metric. This improved model achieves a precision of 97.9% and reduces both false detections and missed detections. Finally, I design a graphical user interface for practical defect detection and deploy the trained model on an NVIDIA Jetson Orin Nano embedded device, achieving a real-time detection speed of 19.2 frames per second with acceptable accuracy. The experimental results demonstrate that the proposed methods are effective and suitable for real-world solar panel defect inspection tasks.

1. Introduction and Background

The increasing global energy demand and the urgent need to reduce carbon emissions have accelerated the development of renewable energy sources. Among them, solar photovoltaic (PV) power generation is considered one of the most promising technologies because of its high efficiency, low operating cost, and wide geographic availability. According to statistics, the cumulative installed capacity of photovoltaic power in China has grown rapidly from 2018 to 2022, reaching 392.61 GW in 2022. The solar panels are the core components of PV systems, and their quality directly determines the overall power generation efficiency. However, solar panels are vulnerable to various types of defects during manufacturing, transportation, installation, and long-term outdoor operation. Common defects include micro-cracks, broken grid lines, black cores, thick lines, and star-shaped cracks. These defects can reduce the photoelectric conversion efficiency and, in severe cases, lead to hot spots, short circuits, or even fires. Thus, efficient and accurate defect detection for solar panels is of great significance for ensuring the reliability and safety of PV power plants.

Traditional defect detection methods for solar panels can be broadly divided into three categories: physical parameter-based methods, conventional image processing methods, and deep learning-based methods. Physical methods often require contacting the solar panels and may cause additional damage. Conventional image processing methods heavily rely on manually designed features and often fail to handle complex defect patterns. With the advancement of deep learning, particularly convolutional neural networks (CNNs), object detection algorithms have achieved remarkable progress and have become the mainstream approach for solar panel defect detection. In my research, I adopt deep learning-based object detection methods to automatically identify and localize multiple types of defects in EL images of solar panels.

2. Electroluminescence Imaging and Dataset Construction

For solar panel defect detection, several imaging modalities are available, including visible light images, infrared thermography, and electroluminescence (EL) imaging. Compared with the other two modalities, EL imaging directly reveals the electrical and structural properties of solar cells. When a forward bias voltage is applied to a solar panel in a dark environment, the injected non-equilibrium carriers recombine and emit near-infrared photons. These photons are captured by a CCD camera, and the resulting EL image shows the luminescence intensity distribution. The brightness of each region is positively correlated with the minority carrier diffusion length and current density. Therefore, defects such as cracks or broken fingers appear as dark lines or regions in the EL image. This imaging technique is highly sensitive to hidden defects and is widely used in quality inspection of solar panels.

In my work, I use a public EL image dataset containing 3,700 images of solar panels with five defect categories: cracks, black cores, thick lines, broken fingers, and star cracks. Table 1 summarizes the defect types and their characteristics.

Defect Type Appearance in EL Image Possible Causes
crack Irregular dark lines Mechanical stress, thermal shock
star_crack Star-shaped dark pattern Concentrated stress, impacts
finger Broken or missing grid lines Poor printing, soldering defects
black_core Dark region in the center of a cell Over-cutting, material inhomogeneity
thick_line Thick dark band or black spot Contamination, bubbles in encapsulation

Table 1. Description of five defect categories on solar panels.

To prepare the dataset for supervised training, I use the LabelImg annotation tool to draw bounding boxes around each defect region and save the annotation information in XML files. The annotated dataset is then randomly split into training, testing, and validation sets with a ratio of 7:1:2. The final dataset contains 2,590 training images, 370 test images, and 740 validation images. All images are resized to 640×640 pixels before being fed into the model.

3. Convolutional Neural Networks and Object Detection

CNNs are the fundamental building blocks of modern deep learning-based object detection systems. A typical CNN consists of convolutional layers, activation functions, pooling layers, and fully connected layers. The convolutional layer uses learnable kernels to extract local features from the input image. The activation function introduces non-linearity into the network, enabling it to approximate complex functions. Common activation functions include ReLU, sigmoid, and tanh. The pooling layer performs down-sampling, reducing the spatial dimensions and increasing the receptive field while preserving important features. The fully connected layer acts as a classifier at the end of the network.

For object detection, two main paradigms exist: two-stage detectors and one-stage detectors. Two-stage detectors, such as Faster R-CNN, first generate region proposals and then classify and refine them. They generally achieve high accuracy but are slower. One-stage detectors, such as the YOLO family, directly predict object classes and bounding boxes from the input image in a single pass. They are much faster and therefore more suitable for real-time applications. In my research, I focus on one-stage detectors based on YOLOv5 and YOLOv7, as they offer an excellent trade-off between accuracy and speed for detecting defects on solar panels.

3.1 YOLOv5

YOLOv5 is a popular one-stage object detection algorithm that has evolved through multiple versions. The network architecture of YOLOv5 is composed of three main parts: backbone, neck, and head. The backbone is responsible for feature extraction and consists of convolutional modules, C3 modules, and SPPF modules. C3 modules are based on the cross-stage partial (CSP) structure, which reduces redundant gradient information and lowers the computational cost. The neck part uses a feature pyramid network (FPN) and a path aggregation network (PAN) to fuse features at different scales. The head performs the final classification and regression.

3.2 YOLOv7

YOLOv7 is a more recent advancement in the YOLO series. It introduces several architectural improvements, including extended efficient layer aggregation networks (ELAN), a modified spatial pyramid pooling cross-stage partial channel (SPPCSPC) module, and reparameterization modules (REP). These enhancements allow YOLOv7 to achieve higher detection accuracy while maintaining a reasonable inference speed. The loss function used in YOLOv7 is CIoU, which considers the overlap area, center distance, and aspect ratio between the predicted and ground-truth bounding boxes.

The CIoU loss is defined as:

$$L_{\text{CIoU}} = 1 – \text{IoU} + \frac{\rho^2(\mathbf{b}, \mathbf{b}^{gt})}{c^2} + \alpha v$$

where

$$v = \frac{4}{\pi^2} \left( \arctan \frac{w^{gt}}{h^{gt}} – \arctan \frac{w}{h} \right)^2$$

and

$$\alpha = \frac{v}{(1 – \text{IoU}) + v}$$

In the above formulas, $\mathbf{b}$ and $\mathbf{b}^{gt}$ denote the center points of the predicted and ground-truth boxes, $\rho(\cdot)$ is the Euclidean distance, $c$ is the diagonal length of the smallest enclosing box, $w$ and $h$ are the width and height of the predicted box, and $w^{gt}$ and $h^{gt}$ are the width and height of the ground-truth box.

4. Improved YOLOv5 with ECA Attention

To improve the defect detection performance on solar panels, I first modified the baseline YOLOv5 model by integrating a lightweight channel attention module named efficient channel attention (ECA). The ECA module avoids dimensionality reduction and uses a fast one-dimensional convolution to capture cross-channel interactions. Its structure is shown below: after global average pooling, the channel features are compressed into a 1×1×C vector. Then a dynamic one-dimensional convolution is applied to compute channel weights, and finally the weights are multiplied with the original feature map to recalibrate the channels.

Specifically, I added the ECA module into the C3 modules of the YOLOv5 backbone network. The original Bottleneck block in C3 was augmented with an ECA branch, forming a new C3-ECA module. This allows the network to assign different importance weights to different convolutional channels, thereby highlighting the defect features of solar panels and suppressing irrelevant background information.

The kernel size of the one-dimensional convolution in ECA is adaptively determined by the channel dimension $C$ as:

$$k = \left| \frac{\log_2(C)}{\gamma} + \frac{b}{\gamma} \right|_{odd}$$

where $|\cdot|_{odd}$ denotes the nearest odd number, and in my experiments I set $\gamma = 2$ and $b = 1$.

4.1 Training Setup and Results

All experiments were conducted on a workstation equipped with an NVIDIA GeForce RTX 3090 GPU with 24 GB of memory, an Intel Core i7-11900K CPU, and 64 GB of RAM. The operating system was Windows 10, and the deep learning framework was PyTorch 1.11.0. The input image size was set to 640×640 pixels. The total number of training epochs was 300, the batch size was 64, the initial learning rate was 0.01, the momentum was 0.937, and the weight decay was 0.0005. Stochastic gradient descent (SGD) was used as the optimizer.

To evaluate the effectiveness of the improved YOLOv5 model, I compared it with several other object detection algorithms, including Faster R-CNN, SSD, YOLOX, YOLOR, YOLOv3, and the baseline YOLOv5. The performance metrics used were precision (P), recall (R), mean average precision at IoU threshold 0.5 (mAP@0.5), and inference speed in frames per second (FPS). These metrics are defined as:

$$P = \frac{S_{TP}}{S_{TP} + S_{FP}}$$
$$R = \frac{S_{TP}}{S_{TP} + S_{FN}}$$
$$mAP = \frac{1}{n} \sum_{i=1}^{n} AP_i$$

where $S_{TP}$, $S_{FP}$, and $S_{FN}$ are the numbers of true positives, false positives, and false negatives, respectively, and $AP_i$ is the average precision for class $i$.

Table 2 shows the comparison results.

Model Precision (%) Recall (%) mAP@0.5 (%) Speed (FPS)
Faster R-CNN 65.9 57.3 61.2 51.34
SSD 79.2 84.6 82.6 10.88
YOLOX 82.6 89.5 82.5 5.68
YOLOR 78.3 94.1 94.3 4.10
YOLOv3 78.5 93.5 87.8 71.40
YOLOv5 96.1 92.1 96.6 142.80
Improved YOLOv5 (ECA) 97.5 95.7 97.7 111.10

Table 2. Performance comparison of different detection algorithms on the solar panel EL dataset.

The improved YOLOv5 achieved a precision of 97.5%, a recall of 95.7%, and an mAP@0.5 of 97.7%, which are higher than the baseline YOLOv5 and all other compared methods. This demonstrates that the ECA attention mechanism effectively enhances the feature representation for solar panel defects. However, despite the high precision, the model still produced some false detections and missed detections, especially for small defects or images containing multiple defects in close proximity. For example, the model sometimes misclassified a thick line as a crack, or failed to detect a faint crack. These issues motivated me to explore a more advanced architecture and additional improvement strategies.

5. The Proposed YOLOv7-SE-DS-NWD Algorithm

To address the remaining false and missed detection problems, I proposed a new algorithm named YOLOv7-SE-DS-NWD. This method is based on the YOLOv7 framework and incorporates three key improvements: a squeeze-and-excitation (SE) attention module in the backbone, distribution shifting convolution (DSConv) in the neck, and a normalized Gaussian Wasserstein distance (NWD) metric in the regression loss function.

5.1 Squeeze-and-Excitation (SE) Module

The SE module performs feature recalibration by explicitly modeling the interdependencies between channels. It consists of two operations: squeeze and excitation. The squeeze operation uses global average pooling to aggregate spatial information into a channel descriptor. The excitation operation uses two fully connected layers to generate per-channel weights, which are then applied to the original feature map. The SE module is defined mathematically as:

First, the squeeze operation:

$$z_c = F_{sq}(u_c) = \frac{1}{H \times W} \sum_{i=1}^{H} \sum_{j=1}^{W} u_c(i,j)$$

Then, the excitation operation:

$$s = F_{ex}(z, W) = \sigma(W_2 \, \delta(W_1 z))$$

where $\delta$ is the ReLU activation and $\sigma$ is the sigmoid activation. Finally, the reweighting operation:

$$\tilde{x}_c = F_{scale}(u_c, s_c) = s_c \cdot u_c$$

In my implementation, I inserted the SE module after the final CBS block in the ELAN modules of the YOLOv7 backbone, resulting in ELAN-SE blocks. This allows the network to focus on important channel information and suppress less relevant features, which is particularly beneficial for detecting small and subtle defects on solar panels.

5.2 Distribution Shifting Convolution (DSConv)

DSConv is an efficient convolution operator that decomposes a traditional convolution kernel into two components: a variable quantized kernel (VQK) and a distribution shifter. The VQK stores integer values, while the distribution shifter adjusts the distribution of these integer values through scaling and biasing operations. More precisely, DSConv uses a kernel distribution shifter (KDS) to adjust the distribution inside each convolution kernel slice, and a channel distribution shifter (CDS) to adjust the distribution across channels. This decomposition allows DSConv to reduce both memory usage and computational cost while maintaining similar or even better accuracy than standard convolution.

In the YOLOv7 network, the head part originally contains ELAN-W modules with multiple 3×3 standard convolutions. I replaced these standard convolutional layers with the DSConv layers to reduce the model complexity and speed up inference. The resulting modules are denoted as ELAN-W-DS.

5.3 Normalized Gaussian Wasserstein Distance (NWD)

Defects on solar panels are often very small in size, making it difficult for the standard IoU-based loss function to accurately measure the similarity between predicted and ground-truth boxes. A small positional deviation can cause a significant drop in IoU, leading to unstable training and poor localization. To overcome this issue, I adopted the normalized Gaussian Wasserstein distance (NWD) as an alternative similarity metric for bounding box regression. The NWD method models each bounding box as a two-dimensional Gaussian distribution and then computes the Wasserstein distance between two distributions. For a horizontal bounding box $R = (c_x, c_y, w, h)$, the corresponding Gaussian distribution is:

$$\mathcal{N}(\mathbf{\mu}, \mathbf{\Sigma})$$

where

$$\mathbf{\mu} = \begin{bmatrix} c_x \\ c_y \end{bmatrix}, \quad \mathbf{\Sigma} = \begin{bmatrix} \frac{w^2}{4} & 0 \\ 0 & \frac{h^2}{4} \end{bmatrix}$$

The Wasserstein distance between two Gaussian distributions $\mathcal{N}_1$ and $\mathcal{N}_2$ is:

$$W_2(\mathcal{N}_1, \mathcal{N}_2) = \sqrt{ \left\| \left( \left[ \begin{array}{c} c_{x_1} \\ c_{y_1} \end{array} \right], \left[ \begin{array}{c} \sqrt{w_1}/2 \\ \sqrt{h_1}/2 \end{array} \right] \right) – \left( \left[ \begin{array}{c} c_{x_2} \\ c_{y_2} \end{array} \right], \left[ \begin{array}{c} \sqrt{w_2}/2 \\ \sqrt{h_2}/2 \end{array} \right] \right) \right\|_2 }$$

To make it a normalized similarity metric between 0 and 1, the NWD is computed as:

$$NWD(\mathcal{N}_1, \mathcal{N}_2) = \exp\left( -\frac{W_2(\mathcal{N}_1, \mathcal{N}_2)^2}{C} \right)$$

where $C$ is a constant related to the dataset. In my experiments, I set $C$ to a value that worked well for the solar panel defect dataset. By replacing the IoU-based loss with the NWD-based loss, the model becomes more robust to small object scale variations and positional deviations, leading to better detection results for tiny defects on solar panels.

5.4 Overall Architecture of YOLOv7-SE-DS-NWD

The complete architecture of the proposed YOLOv7-SE-DS-NWD model is illustrated conceptually as follows: the input image is first fed into the backbone network, which contains standard CBS blocks, MP layers, and ELAN-SE blocks. The SE modules allow the network to recalibrate channel features and focus on defect-relevant information. The neck part uses the SPPCSPC module and the PAFPN structure with ELAN-W-DS blocks where DSConv is utilized. Finally, the head performs detection using three different scale feature maps, and the regression loss is calculated using the NWD metric.

6. Experimental Results and Ablation Study

All experiments for the YOLOv7-based models were performed under the same hardware and software environment as described earlier. The training settings were also identical: 300 epochs, batch size 64, initial learning rate 0.01, SGD optimizer, momentum 0.937, and weight decay 0.0005.

6.1 Comparison with YOLOv3 and YOLOv5

First, I compared the baseline YOLOv7 with YOLOv3 and YOLOv5 on the solar panel EL dataset. Table 3 lists the results.

Model Precision (%) Recall (%) Speed (FPS)
YOLOv3 78.6 95.3 71.40
YOLOv5 96.1 92.1 140.78
YOLOv7 96.5 94.5 38.46

Table 3. Performance comparison of baseline YOLO models.

Although YOLOv7 is slower than YOLOv5 in terms of FPS, its higher recall (94.5%) compared to YOLOv5 (92.1%) indicates fewer missed detections, which is critical for solar panel defect inspection. Therefore, I selected YOLOv7 as the base network for further improvements.

6.2 Ablation Experiments

To verify the contribution of each improvement, I conducted ablation experiments on the same dataset. The results are shown in Table 4.

Model SE DSConv NWD Precision (%) Recall (%) Speed (FPS)
YOLOv7 96.5 94.5 38.46
YOLOv7-SE ✓ 97.3 94.3 37.04
YOLOv7-DS ✓ 97.1 95.1 40.00
YOLOv7-NWD ✓ 96.6 95.3 37.04
YOLOv7-SE-DS ✓ ✓ 96.8 94.3 40.00
YOLOv7-SE-NWD ✓ ✓ 97.0 95.5 37.04
YOLOv7-DS-NWD ✓ ✓ 97.4 94.3 38.46
YOLOv7-SE-DS-NWD ✓ ✓ ✓ 97.9 94.9 40.00

Table 4. Ablation study results for the proposed YOLOv7 improvements.

From Table 4, it can be seen that each individual improvement contributes positively to the detection performance. The SE module increases precision by 0.8%. The DSConv module not only improves precision by 0.6% but also reduces the number of parameters and computational cost. The NWD metric improves both precision and recall. When all three improvements are combined, the model achieves a precision of 97.9% and a recall of 94.9%, outperforming the baseline YOLOv7 by 1.4% and 0.4%, respectively. The speed also slightly increases to 40 FPS, which is beneficial for real-world applications.

6.3 Model Complexity

Table 5 presents the comparison of the number of parameters, model size, and floating-point operations (GFLOPs) for the baseline YOLOv7, YOLOv7 with DSConv, and the full YOLOv7-SE-DS-NWD model.

Model Parameters Model Size (MB) GFLOPs
YOLOv7 37,218,132 70.99 105.2
YOLOv7-DS 36,506,036 69.63 92.9
YOLOv7-SE-DS-NWD 36,671,412 69.95 93.1

Table 5. Model complexity comparison.

The use of DSConv reduces the number of parameters by about 712,096 and decreases GFLOPs by 12.3. The full improved model still has fewer parameters and lower GFLOPs compared to the baseline, demonstrating that the proposed algorithm can achieve higher accuracy with lower computational complexity.

6.4 Qualitative Detection Results

I also visually inspected the detection results of different models. The improved YOLOv7-SE-DS-NWD algorithm reduced both false detections and missed detections compared with the original YOLOv7 and the improved YOLOv5. For example, defects located near the edges of solar panels were less likely to be misclassified, and faint cracks were detected more consistently. The qualitative comparison confirms the superiority of the proposed method in handling the diversity and complexity of solar panel defects.

7. Software Design and Embedded Deployment

To make the trained models easier to use in practice, I designed a graphical user interface (GUI) for the solar panel defect detection system. The GUI was developed using PyQt5, a Python binding of the cross-platform Qt framework. The interface allows users to load an image, select the trained model, run defect detection, and save the annotated results.

7.1 GUI Description

The main interface contains buttons for model selection, image input, camera feed, start detection, end detection, and result saving. After an image is loaded, it is displayed in the interface. When the user clicks the start detection button, the model loads the pre-trained weights and performs inference on the selected image. The detection result is then displayed in the main window, and the detected defect types and confidence scores are shown. The user can save the result to a designated folder for further analysis.

The workflow of the GUI system is as follows:

  1. Select the trained model file.
  2. Choose an input image that contains solar panels.
  3. Click start detection.
  4. The system processes the image and displays the detected bounding boxes in real time.
  5. Click save to store the output image.

7.2 Deployment on Jetson Orin Nano

For practical edge deployment, I transferred the optimized YOLOv7-SE-DS-NWD model to an NVIDIA Jetson Orin Nano embedded platform. The Jetson Orin Nano is a compact, low-power AI computer equipped with a 6-core Arm Cortex-A78AE CPU, 1024 CUDA cores, 32 tensor cores, and 8 GB of LPDDR5 memory. It supports JetPack SDK, CUDA, cuDNN, TensorRT, and various programming frameworks, making it suitable for real-time inference in resource-constrained environments.

The deployment procedure involved the following steps:

  1. Install Ubuntu 20.04 and JetPack 5.1.1 on the Jetson Orin Nano using NVIDIA SDK Manager.
  2. Set up the necessary deep learning libraries, including CUDA 11.4.315, cuDNN 8.6.0.166, and TensorRT 8.5.2.2.
  3. Train and optimize the YOLOv7-SE-DS-NWD model on the workstation.
  4. Transfer the trained model to the Jetson device.
  5. Integrate the model with the inference engine and test the detection performance.

The detection results after deployment on the Jetson Orin Nano are shown in Table 6, which compares the precision and recall of five defect categories before and after deployment.

Defect Type Precision (original) Recall (original) Precision (deployed) Recall (deployed)
crack 0.971 0.939 0.935 0.907
black_core 0.999 0.986 0.996 0.980
thick_line 0.980 0.945 0.976 0.935
finger 0.974 0.941 0.961 0.926
star_crack 0.968 0.934 0.956 0.931

Table 6. Detection accuracy before and after deployment on Jetson Orin Nano.

The average inference time per image on the Jetson Orin Nano was 52 ms, corresponding to a detection speed of 19.2 frames per second. Although the precision and recall slightly dropped after deployment due to model compression and quantization, the values remained sufficiently high for practical solar panel defect detection tasks. This demonstrates the feasibility of using the proposed algorithm on edge devices for real-time monitoring of solar panels.

The image above illustrates a typical high-quality solar panel used in photovoltaic installations. In real-world scenarios, automatically detecting defects on such panels is essential for maintaining their performance and longevity. The algorithm developed in my research aims to accurately locate and classify defects in EL images of solar panels, even when the panels appear visually normal under natural light.

8. Conclusion and Future Work

In this thesis, I have systematically studied the problem of defect detection for solar panels using deep learning-based object detection methods. I constructed an EL image dataset with five types of common defects and proposed two improved algorithms. The first algorithm, based on YOLOv5 with an ECA attention module, achieved a precision of 97.5% but still suffered from false and missed detections. To solve these issues, I developed a more advanced model, YOLOv7-SE-DS-NWD, which integrates an SE attention module, DSConv, and an NWD-based loss function. This model achieved a precision of 97.9%, a recall of 94.9%, and a mean average precision of 97.7%, while also reducing the model complexity and improving the inference speed. The proposed algorithm significantly mitigates the problems of false detections and missed detections for solar panel defects.

In addition, I designed a user-friendly graphical interface for defect detection, making the system accessible to operators without specialized knowledge. The model was also successfully deployed on an NVIDIA Jetson Orin Nano embedded device, achieving real-time detection at 19.2 frames per second with only a slight reduction in accuracy. This demonstrates the applicability of the proposed technique to portable and drone-based inspection systems for solar panels.

Future work can be directed in several areas. First, the dataset can be expanded to include more defect types such as aging, snail trails, and delamination. Second, more advanced attention mechanisms and transformer-based detectors could be explored to further improve accuracy. Third, lightweight model compression techniques such as pruning and quantization can be applied to enable even faster inference on embedded platforms. Finally, the integration of the defect detection algorithm with unmanned aerial vehicle (UAV) path planning and autonomous inspection systems could significantly enhance the automation level of solar panel maintenance in large-scale photovoltaic plants.

In conclusion, the deep learning-based methods developed in this study provide an efficient and accurate solution for defect detection on solar panels. The combination of attention mechanisms, efficient convolution operators, and advanced loss functions proves to be highly effective in addressing the challenges of small-target detection and complex defect patterns. The successful deployment on edge hardware further highlights the practical value of the proposed algorithm for real-world solar panel inspection tasks.

Scroll to Top