In modern energy systems, solar photovoltaic power has become one of the most promising renewable energy sources due to its cleanliness, high efficiency, and broad availability. Solar panels, as the core components of photovoltaic power stations, directly determine the overall energy conversion efficiency. However, various defects may appear on solar panels during manufacturing, transportation, installation, and long-term outdoor operation. These defects, if not detected in time, can significantly reduce the conversion efficiency and service life of solar panels. In severe cases, they can even lead to fire or explosion risks. Therefore, developing a reliable and efficient defect detection method for solar panels is of great practical importance. In this study, I focus on the problem of multi-class defect detection in solar panel electroluminescence (EL) images using deep learning-based object detection algorithms. The main contributions are a novel improved YOLOv5 algorithm with attention mechanism, a further improved YOLOv7-based algorithm with three enhancements, a graphical user interface for defect detection, and an embedded deployment on NVIDIA Jetson Orin Nano.
1. Introduction
The rapid growth of global energy demand and the urgent need for carbon neutrality have accelerated the deployment of photovoltaic power stations. According to public statistics, China’s cumulative installed photovoltaic capacity reached 392.61 GW in 2022, and the trend is still rising. As solar panels are exposed to harsh environmental conditions, they are prone to physical and electrical defects. Common defect types include cracks, black cores, thick lines, broken fingers, and star cracks. To prevent accidents and maintain high efficiency, automated defect detection is essential.
Traditional defect detection methods for solar panels can be classified into three categories: physical parameter-based methods, traditional image processing-based methods, and deep learning-based methods. Physical parameter methods often require contact measurements and may cause secondary damage. Traditional image processing methods rely on hand-crafted features and are limited in generalization. In contrast, deep learning-based object detection methods can automatically extract hierarchical features and achieve high accuracy and speed. In this study, I adopt deep learning-based algorithms, specifically the YOLO family, to detect defects in solar panel EL images.
The rest of this article is organized as follows. Section 2 introduces the background and related work. Section 3 describes the construction of the solar panel defect dataset. Section 4 presents the improved YOLOv5 algorithm with ECA attention. Section 5 reports the experimental results of the improved YOLOv5. Section 6 proposes the improved YOLOv7-SE-DS-NWD algorithm. Section 7 gives the experiments and ablation study. Section 8 describes the software design and embedded deployment. Finally, Section 9 concludes the study.
2. Background and Related Work
2.1 Solar Panel Image Types
There are three commonly used image modalities for solar panel inspection: visible light images, infrared thermography, and electroluminescence (EL) images. Visible light images can capture surface defects, but they are less effective for internal or sub-surface defects and are sensitive to lighting conditions. Infrared thermography is mainly used for detecting hot spots caused by localized heating, but it cannot reveal detailed structural defects. EL imaging is performed by applying a forward bias voltage to the solar panel in a dark environment; the emitted near-infrared light is captured by a CCD camera. The brightness of the EL image is proportional to the minority carrier diffusion length and current density. Defective regions appear darker, making EL images particularly suitable for detecting cracks, finger interruptions, and other micro-defects. Therefore, I selected solar panel EL images as the research object.

2.2 Defect Categories
Based on the characteristics observed in EL images, solar panel defects can be divided into five categories: crack, black core, thick line, broken finger, and star crack. A crack appears as an irregular dark line. A star crack shows a star-like branching pattern. A broken finger refers to a missing or broken grid line that reduces current collection. A black core appears as a large dark area in the center of a cell, often caused by improper cutting or contamination. A thick line appears as a dark band or region due to manufacturing defects. Table 1 summarizes these defect types and their typical appearances.
| Defect Type | Description in EL image |
|---|---|
| Crack | Irregular dark line with arbitrary direction |
| Star crack | Branching star-shaped dark pattern |
| Broken finger | Dark line or missing segment on grid lines |
| Black core | Large dark area in the cell center |
| Thick line | Dark band or spot caused by defects |
2.3 Object Detection Algorithms
Modern object detection algorithms are mainly divided into two-stage detectors and one-stage detectors. Two-stage detectors, such as R-CNN, Fast R-CNN, and Faster R-CNN, first generate region proposals and then classify and refine them. They generally provide higher accuracy but lower speed. One-stage detectors, such as SSD and YOLO series, directly predict bounding boxes and class probabilities from the input image, achieving real-time speed with competitive accuracy. In this study, I focus on the YOLO series because of its excellent balance between speed and accuracy. I first improve YOLOv5, and then propose a more advanced YOLOv7-based algorithm.
3. Dataset Construction
I used a publicly available solar panel EL image dataset containing 3700 images. All images were manually annotated using the LabelImg tool. The annotations include the bounding box coordinates and the class label for each defect instance. To ensure reliable training and evaluation, the dataset was split into training set, test set, and validation set with a ratio of 7:1:2, respectively. The input image size was resized to 640×640 pixels. Data preprocessing included normalization and color channel adjustments. The numbers of images in each split are listed in Table 2.
| Set | Number of images |
|---|---|
| Training | 2590 |
| Test | 370 |
| Validation | 740 |
During annotation, the five defect categories were labelled as crack, black_core, thick_line, finger, and star_crack. The annotated XML files store the object class and bounding box positions. The final dataset covers a wide range of defect sizes, including many small objects that are challenging for standard detectors.
4. Improved YOLOv5 for Solar Panel Defect Detection
4.1 YOLOv5 Architecture
YOLOv5 is a one-stage object detector that consists of a backbone network, a neck network, and a head network. The backbone is responsible for extracting features from input images. It uses convolutional modules, C3 modules, and SPPF (Spatial Pyramid Pooling Fast) modules. The neck network adopts a feature pyramid network (FPN) and a path aggregation network (PAN) to fuse multi-scale features. The head network performs final classification and regression on three feature maps of different scales. In this study, I used YOLOv5s-6.0 as the baseline, which has a relatively small depth and width, making it suitable for efficient defect detection.
4.2 ECA Attention Mechanism
Efficient Channel Attention (ECA) is a lightweight attention module that improves the performance of convolutional neural networks by modeling channel-wise importance without dimensionality reduction. ECA uses global average pooling to squeeze spatial information, then a fast 1D convolution to capture local cross-channel interactions. The kernel size \( k \) of the 1D convolution is adaptively determined by the channel dimension \( C \) as follows:
\[
k = \left| \frac{\log_2(C)}{\gamma} + \frac{b}{\gamma} \right|_{odd}
\]
where \( \gamma = 2 \), \( b = 1 \), and \( |\cdot|_{odd} \) denotes the nearest odd number. The ECA module can be formulated as:
\[
\mathbf{s} = \sigma(\text{Conv1D}_k(\text{GAP}(\mathbf{X})))
\]
\[
\mathbf{Y} = \mathbf{s} \odot \mathbf{X}
\]
where \( \mathbf{X} \) is the input feature map, \( \text{GAP} \) is global average pooling, \( \sigma \) is the sigmoid function, and \( \odot \) denotes channel-wise multiplication. By assigning different weights to different channels, ECA helps the model focus on defect-related features and suppress irrelevant information.
4.3 C3-ECA Module
I integrated the ECA module into the C3 module of the YOLOv5 backbone. The standard C3 module contains three convolutional layers and several bottleneck blocks. I inserted an ECA module after the bottleneck branch, forming the C3-ECA module. This modification enables the network to recalibrate channel features at the feature extraction stage, enhancing the representation of solar panel defects. The improved backbone with C3-ECA is more sensitive to small and weak defects while maintaining a low computational cost.
5. Experiments on Improved YOLOv5
5.1 Experimental Platform and Hyperparameters
The experiments were conducted on a workstation with an Intel Core i7-11900K CPU, an NVIDIA GeForce RTX 3090 GPU with 24 GB memory, and 64 GB DDR4 RAM. The operating system was Windows 10, and the detection framework was PyTorch 1.11.0. Table 3 summarizes the key hyperparameters used for training.
| Parameter | Value |
|---|---|
| Input size | 640×640 |
| Epochs | 300 |
| Batch size | 64 |
| Initial learning rate | 0.01 |
| Optimizer | SGD |
| Momentum | 0.937 |
| Weight decay | 0.0005 |
5.2 Evaluation Metrics
I used precision (P), recall (R), and mean average precision (mAP) as the main evaluation metrics. They are defined as follows:
\[
\text{Precision} = \frac{TP}{TP+FP}
\]
\[
\text{Recall} = \frac{TP}{TP+FN}
\]
\[
mAP = \frac{1}{N}\sum_{i=1}^{N} AP_i
\]
where \( TP \) is the number of true positives, \( FP \) is the number of false positives, \( FN \) is the number of false negatives, \( N \) is the number of classes, and \( AP_i \) is the average precision for class \( i \). The IoU threshold for mAP was set to 0.5.
5.3 Comparison of Detection Algorithms
I compared the improved YOLOv5 with several state-of-the-art detectors, including Faster R-CNN, SSD, YOLOX, YOLOR, YOLOv3, and the original YOLOv5. Table 4 shows the experimental results.
| Model | Precision (%) | Recall (%) | mAP@0.5 (%) | Speed (FPS) |
|---|---|---|---|---|
| Faster R-CNN | 65.9 | 57.3 | 61.2 | 51.3 |
| SSD | 79.2 | 84.6 | 82.6 | 10.9 |
| YOLOX | 82.6 | 89.5 | 82.5 | 5.7 |
| YOLOR | 78.3 | 94.1 | 94.3 | 4.1 |
| YOLOv3 | 78.5 | 93.5 | 87.8 | 71.4 |
| YOLOv5 | 96.1 | 92.1 | 96.6 | 142.8 |
| Improved YOLOv5 | 97.5 | 95.7 | 97.7 | 111.1 |
From Table 4, the improved YOLOv5 achieved a precision of 97.5%, a recall of 95.7%, and an mAP of 97.7%, outperforming all other compared algorithms. Compared to the original YOLOv5, the improved version increased precision by 1.4 percentage points, recall by 3.6 percentage points, and mAP by 1.1 percentage points. The speed of the improved model was 111.1 FPS, which is still sufficiently fast for real-time applications.
5.4 Remaining Issues: False and Missed Detections
Although the improved YOLOv5 achieved high accuracy, I observed some false detections and missed detections when testing on challenging images. For example, a thick line defect at the edge of a solar panel was sometimes misclassified as a crack. Some faint cracks were also missed. These issues mainly arise because solar panel defects are small objects with large intra-class variations and inter-class similarities. This motivated me to develop a more advanced algorithm based on YOLOv7.
6. YOLOv7-SE-DS-NWD Algorithm
6.1 YOLOv7 Baseline
YOLOv7 is a recent one-stage object detector that achieves state-of-the-art performance in terms of both accuracy and speed. Its architecture consists of an input end, a backbone, a neck, and a head. The backbone uses convolutional blocks, pooling layers, and extended efficient layer aggregation networks (ELAN). The neck uses a path aggregation feature pyramid network (PAFPN) with a spatial pyramid pooling cross stage partial channel (SPPCSPC) module. The head uses parameterized reparameterization blocks to accelerate inference. YOLOv7 employs the CIoU loss function for bounding box regression. The CIoU loss is defined as:
\[
L_{CIoU} = 1 – \text{IoU} + \frac{\rho^2(\mathbf{b}, \mathbf{b}^{gt})}{c^2} + \alpha v
\]
\[
\alpha = \frac{v}{(1-\text{IoU}) + v}
\]
\[
v = \frac{4}{\pi^2}\left(\arctan\frac{w^{gt}}{h^{gt}} – \arctan\frac{w}{h}\right)^2
\]
where \( \rho \) is the Euclidean distance between the center points of the predicted and ground-truth boxes, \( c \) is the diagonal length of the smallest enclosing box, \( \alpha \) is a trade-off parameter, and \( v \) measures the consistency of the aspect ratio.
6.2 SE Attention Module
Squeeze-and-Excitation (SE) attention is a channel attention mechanism that adaptively recalibrates channel-wise feature responses. The SE module performs three operations: squeeze, excitation, and rescale. The squeeze operation uses global average pooling:
\[
z_c = \frac{1}{H \times W}\sum_{i=1}^{H}\sum_{j=1}^{W} u_c(i,j)
\]
The excitation operation uses two fully connected layers to model channel dependencies:
\[
\mathbf{s} = \sigma(\mathbf{W}_2 \delta(\mathbf{W}_1 \mathbf{z}))
\]
where \( \mathbf{W}_1 \) and \( \mathbf{W}_2 \) are the weights of the two fully connected layers, \( \delta \) is the ReLU function, and \( \sigma \) is the sigmoid function. Finally, the rescale operation multiplies the original feature map \( \mathbf{U} \) by the channel weights \( \mathbf{s} \):
\[
\tilde{\mathbf{x}}_c = s_c \cdot \mathbf{u}_c
\]
I inserted the SE module after the ELAN module in the YOLOv7 backbone, forming the ELAN-SE module. This enhances the model’s ability to focus on important channel information and improves the extraction of solar panel defect features.
6.3 Distribution Shifting Convolution (DSConv)
DSConv is an efficient convolution operator that mimics the behavior of a standard convolution by decomposing the kernel into 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 using two shifters: the kernel distribution shifter (KDS) and the channel distribution shifter (CDS). This decomposition reduces the model size and computational cost while maintaining comparable accuracy. In my improved model, I replaced the standard 3×3 convolutional layers in the ELAN-W modules of the neck network with DSConv modules, forming the ELAN-W-DS module. This modification reduces the number of parameters and floating-point operations, resulting in faster inference.
6.4 Normalized Gaussian Wasserstein Distance (NWD)
For small object detection, the IoU-based loss is very sensitive to small positional deviations. To alleviate this issue, I introduced the Normalized Gaussian Wasserstein Distance (NWD) to replace the IoU metric in the regression loss. A bounding box \( R = (c_x, c_y, w, h) \) is modeled as a two-dimensional Gaussian distribution \( \mathcal{N}(\mu, \Sigma) \), where:
\[
\mu = \begin{bmatrix} c_x \\ c_y \end{bmatrix}, \quad
\Sigma = \begin{bmatrix} \frac{w^2}{4} & 0 \\ 0 & \frac{h^2}{4} \end{bmatrix}
\]
The Wasserstein distance between two Gaussian distributions \( \mathcal{N}_a \) and \( \mathcal{N}_b \) is:
\[
W_2^2(\mathcal{N}_a, \mathcal{N}_b) = \left\| \begin{bmatrix} c_{xa}, c_{ya}, \frac{w_a}{2}, \frac{h_a}{2} \end{bmatrix}^T – \begin{bmatrix} c_{xb}, c_{yb}, \frac{w_b}{2}, \frac{h_b}{2} \end{bmatrix}^T \right\|_2^2
\]
The normalized distance is computed as:
\[
\text{NWD}(\mathcal{N}_a, \mathcal{N}_b) = \exp\left(-\frac{\sqrt{W_2^2(\mathcal{N}_a, \mathcal{N}_b)}}{C}\right)
\]
where \( C \) is a constant related to the dataset. By embedding NWD into the regression loss, the model becomes more robust to small object localization errors and improves the detection of tiny defects in solar panels.
6.5 Overall Architecture
The proposed YOLOv7-SE-DS-NWD model integrates three improvements. First, the SE attention is added to the ELAN modules in the backbone. Second, the standard convolutions in the ELAN-W modules of the neck are replaced with DSConv. Third, the IoU loss is replaced with a loss based on NWD. This combined model is designed to reduce false and missed detections while maintaining a high processing speed.
The final detection process can be summarized as: Input solar panel EL image → Backbone with ELAN-SE extracts features → Neck with ELAN-W-DS fuses multi-scale features → Head predicts bounding boxes and class probabilities using the NWD-based regression loss.
7. Experiments on YOLOv7-SE-DS-NWD
7.1 Comparison with YOLO Variants
I first compared YOLOv3, YOLOv5, and YOLOv7 on the same solar panel defect dataset. Table 5 shows the results.
| Model | Precision (%) | Recall (%) | Speed (FPS) |
|---|---|---|---|
| YOLOv3 | 78.6 | 95.3 | 71.4 |
| YOLOv5 | 96.1 | 92.1 | 140.8 |
| YOLOv7 | 96.5 | 94.5 | 38.5 |
Although YOLOv7 has a lower speed than YOLOv5, it achieved higher precision and recall. Given the importance of reducing missed detections, I selected YOLOv7 as the baseline for further improvement.
7.2 Ablation Study
To validate the effectiveness of each improvement, I conducted ablation experiments. The results are presented in Table 6, where “√” indicates that the corresponding component is used.
| Model | SE | DSConv | NWD | P (%) | R (%) | Speed (FPS) |
|---|---|---|---|---|---|---|
| YOLOv7 | 96.5 | 94.5 | 38.5 | |||
| YOLOv7-SE | √ | 97.3 | 94.3 | 37.0 | ||
| YOLOv7-DS | √ | 97.1 | 95.1 | 40.0 | ||
| YOLOv7-NWD | √ | 96.6 | 95.3 | 37.0 | ||
| YOLOv7-SE-DS | √ | √ | 96.8 | 94.3 | 40.0 | |
| YOLOv7-SE-NWD | √ | √ | 97.0 | 95.5 | 37.0 | |
| YOLOv7-DS-NWD | √ | √ | 97.4 | 94.3 | 38.5 | |
| YOLOv7-SE-DS-NWD | √ | √ | √ | 97.9 | 94.9 | 40.0 |
Table 6 shows that the full model achieves the highest precision of 97.9%, which is 1.4 percentage points higher than the original YOLOv7. The recall is 94.9%, slightly higher than 94.5%. The speed remains at 40 FPS, demonstrating that the improvements do not degrade real-time performance. The DSConv component significantly reduces the model size and computational cost, while the SE and NWD components improve detection accuracy.
7.3 Parameter and Computation Analysis
I also analyzed the effect of DSConv on the model complexity. Table 7 shows the number of parameters, model size, and floating-point operations (GFLOPs) for different models.
| Model | Parameters | 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 |
Compared with the original YOLOv7, the proposed model reduces the number of parameters by 546,720 and the GFLOPs by 12.1, while improving the detection accuracy. This makes the model more suitable for deployment on embedded devices.
7.4 Qualitative Results
In practical tests, the improved YOLOv7-SE-DS-NWD model exhibited fewer false and missed detections than the improved YOLOv5 model. For instance, a thick line defect that was previously misclassified as a crack by YOLOv5 is now correctly identified. Faint crack defects that were missed by YOLOv5 are also detected by the improved YOLOv7. These qualitative observations confirm that the proposed algorithm is more robust for solar panel defect detection, especially for small and ambiguous defects.
8. Software Design and Embedded Deployment
8.1 Graphical User Interface
To facilitate practical use, I developed a graphical user interface (GUI) for solar panel defect detection using PyQt5. The GUI allows users to load a trained model, select an image, and perform defect detection with a simple click. The main interface includes buttons for model selection, input image selection, camera capture, start detection, stop detection, and result saving. After detection, the annotated image is displayed on the interface, and the user can save the result to a specified folder. The workflow is as follows:
- Load the trained YOLOv7-SE-DS-NWD model.
- Select an input image from the local file system.
- Click the “Start Detection” button to run the inference.
- View the detection result with bounding boxes and class labels.
- Save the output image if needed.
This GUI improves the accessibility of the solar panel defect detection system and enables non-expert users to operate the system easily.
8.2 Deployment on NVIDIA Jetson Orin Nano
I deployed the trained model on an NVIDIA Jetson Orin Nano embedded module, which is a low-power AI computing platform with 1024 CUDA cores, 32 tensor cores, and a 6-core ARM Cortex-A78AE CPU. The JetPack 5.1.1 SDK was installed, which includes CUDA 11.4, cuDNN 8.6, and TensorRT 8.5. The original PyTorch model was converted and optimized for the embedded platform. After deployment, the model achieved a detection speed of 19.2 frames per second (FPS), with an average inference time of 52 ms per image. Table 8 compares the detection accuracy before and after deployment.
| Class | Before deployment | After deployment | ||
|---|---|---|---|---|
| Precision | Recall | Precision | Recall | |
| 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 |
| Broken finger | 0.974 | 0.941 | 0.961 | 0.926 |
| Star crack | 0.968 | 0.934 | 0.956 | 0.931 |
The precision and recall values after deployment are slightly lower than those of the original model due to quantization and optimization, but the degradation is acceptable for real-world engineering applications. The embedded deployment enables portable and real-time solar panel defect detection, which is valuable for field inspection using drones or mobile devices.
9. Conclusion
In this study, I investigated deep learning-based defect detection algorithms for solar panels using electroluminescence images. I first constructed a dataset with five common defect types and then proposed two improved detection algorithms. The improved YOLOv5 with ECA attention achieved 97.5% precision, but still suffered from some false and missed detections. To overcome these limitations, I developed the YOLOv7-SE-DS-NWD algorithm by adding an SE attention module, replacing standard convolutions with DSConv, and introducing the NWD metric for regression. The proposed model achieved a precision of 97.9%, which is 1.4 percentage points higher than the original YOLOv7, while reducing the number of parameters and computational cost. Finally, I designed a user-friendly graphical interface and successfully deployed the model on an NVIDIA Jetson Orin Nano, achieving a real-time speed of 19.2 FPS. The results demonstrate that the proposed system can effectively detect solar panel defects and has strong potential for practical applications in photovoltaic power station inspection.
Future work may focus on expanding the dataset to cover more defect types, such as aging and snail trails, and on further improving the model compression and deployment efficiency. Moreover, integrating the detection algorithm with unmanned aerial vehicles and path planning could enable fully automated inspection of large-scale solar panel arrays, thereby enhancing the intelligence and reliability of photovoltaic system maintenance.
