Solar panels play a crucial role in the transition toward renewable energy systems, as they directly convert solar radiation into electrical energy. The rapid expansion of photovoltaic installations worldwide has led to an increasing demand for efficient and reliable quality control throughout the lifecycle of solar panels. Defects occurring during manufacturing, transportation, installation, or operation can significantly reduce the energy conversion efficiency and shorten the lifespan of solar panels. Consequently, accurate detection of such defects is essential to ensure the reliability and economic viability of solar energy systems. Traditional inspection methods, which rely heavily on manual visual inspection or simple image processing techniques, often suffer from low efficiency, high misdetection rates, and an inability to cope with large-scale deployments. In recent years, deep learning has emerged as a powerful tool for automated visual inspection, providing high accuracy and robustness in various industrial applications.
This paper addresses the problem of solar panel defect detection using deep learning techniques. We present a comprehensive study that includes dataset construction, image enhancement, network architecture improvement, and software system development. Our goal is to develop efficient and accurate detection models for two distinct scenarios: factory-level product inspection and aerial inspection of photovoltaic plants. For the first scenario, we propose a lightweight single-shot multi-box detector (SSD) based on MobileNetV2, named MobileNetV2-C-SSD, which significantly reduces model size while improving detection accuracy. For the second scenario, we enhance the model with a feature fusion path and attention mechanisms to tackle the challenge of small-object defect detection in aerial images. Additionally, we implement a detection system using PySide6 to provide a user-friendly interface for practical applications.

In the remainder of this paper, we first review related work on solar panel defect detection and object detection algorithms. Then, we describe our proposed methods in detail, including dataset preprocessing, the MobileNetV2-C-SSD architecture, and the improvements for small target detection. Extensive experiments are conducted on a public PVEL-AD dataset and an aerial photovoltaic small-target dataset. The results demonstrate that our proposed models outperform traditional SSD approaches in terms of accuracy, model size, and inference speed. Finally, we present the design and implementation of a complete solar panel defect detection system based on PySide6, which allows users to select different models for various applications.
Related Work
The detection of defects in solar panels has been studied extensively using various techniques. Infrared thermography is widely adopted in large photovoltaic plants to identify thermal anomalies, which often indicate malfunctioning cells. Visual inspection, combined with image processing, is another common approach for surface defect identification. With the advancement of machine learning, several studies have exploited deep neural networks to improve the accuracy and efficiency of defect detection. For example, improved YOLO variants have been applied to electroluminescence (EL) images of solar cells, achieving high precision in locating cracks and finger interruptions. Attention mechanisms such as SENet and CBAM have also been integrated into convolutional networks to enhance the focus on relevant regions. Furthermore, feature pyramid networks (FPN) and multi-scale feature fusion have been utilized to better detect small defects.
The Single Shot MultiBox Detector (SSD) is one of the most popular one-stage object detection models. It predicts bounding boxes and class probabilities directly from multiple feature layers of different scales, achieving a favorable balance between speed and accuracy. However, the original SSD uses VGG16 as the backbone network, which is computationally heavy and yields a large model size. Moreover, SSD lacks sufficient interaction between feature layers, leading to suboptimal performance for small objects. To address these limitations, researchers have proposed various improvements, including replacing the backbone with lightweight networks such as MobileNet, introducing attention modules, and applying FPN to enhance feature representation. In this work, we follow this line of research and introduce a lightweight SSD network tailored for solar panel defect detection.
Dataset Construction and Preprocessing
To train and evaluate our defect detection models, we used the PVEL-AD dataset, which contains a large collection of solar panel images with various types of defects. The dataset includes images of black cores, short circuits, star cracks, linear cracks, thick lines, finger interruptions, dislocations, and other anomalies. In addition, for the aerial small-target scenario, we adopted a dataset composed of drone-captured images of photovoltaic arrays with defects such as glass breakage, hot spots, and partial shading. To prepare the data for supervised learning, we annotated the images using the LabelImg tool, which generates XML files containing the coordinates and class labels of each defect region.
We selected 4500 images from the PVEL-AD dataset and manually annotated all defect instances. The distribution of defect classes is summarized in the following table:
| Defect Class | Number of Instances |
|---|---|
| Black Core | 1028 |
| Linear Crack | 1260 |
| Finger Interruption | 2958 |
| Star Crack | 135 |
| Thick Line | 981 |
| Horizontal Dislocation | 798 |
| Vertical Dislocation | 137 |
| Short Circuit | 492 |
As can be observed, certain classes such as star cracks and vertical dislocations have relatively few samples, which may lead to class imbalance during training. We addressed this issue later by introducing a Focal Loss function. The dataset was split into training, validation, and testing sets with a ratio of approximately 8:1:1. The training set contained 3645 images, the validation set 402 images, and the test set 450 images.
We also noticed that many images exhibited uneven gray-level distributions, resulting in low contrast and poor visibility of defect regions. To enhance the image quality, we compared four histogram-based enhancement methods: histogram equalization (HE), adaptive histogram equalization (AHE), adaptive local region stretching (LRS), and contrast-limited adaptive histogram equalization (CLAHE). Among these, CLAHE produced the best results, as it enhances local contrast while preventing over-amplification of noise. The transformation function of CLAHE can be expressed mathematically. Given a local histogram $h_{block}(l)$ for a block of the image, the cumulative distribution function (CDF) is computed as:
$$ C_{block}(l) = \sum_{i=0}^{l} h_{block}(i) $$
After clipping the histogram to a predefined threshold and renormalizing, the equalized pixel intensity is obtained by mapping through the modified CDF. The application of CLAHE significantly improved the visibility of defects, leading to higher detection accuracy in subsequent experiments.
Proposed MobileNetV2-C-SSD Network
The original SSD network uses VGG16 as the backbone, which is computationally expensive and results in a large model (approximately 105 MB). To make the detector more suitable for industrial deployment, we replaced the VGG16 backbone with MobileNetV2. MobileNetV2 employs depthwise separable convolutions, which drastically reduce the number of parameters and computations while maintaining high accuracy. The architecture of MobileNetV2 includes two key components: inverted residual blocks and linear bottlenecks. The depthwise separable convolution factorizes a standard convolution into a depthwise convolution and a pointwise convolution. The computational cost reduction can be quantified as follows:
$$ \frac{DF \cdot DF \cdot M}{DF \cdot DF \cdot N} = \frac{1}{N} $$
where $D_F$ is the spatial dimension of the feature map, $M$ is the number of input channels, and $N$ is the number of output channels. The inverted residual block first expands the number of channels using a pointwise convolution, then applies depthwise convolution, and finally projects back to a lower-dimensional output with a linear activation. This structure allows the network to learn richer features without excessive computational overhead.
We integrated MobileNetV2 with SSD by selecting six effective feature layers for detection: Conv11, Conv13 from the MobileNetV2 network, and the additional Conv14_2, Conv15_2, Conv16_2, and Conv18_2 layers. The detection heads are attached to these layers at different scales, enabling the model to recognize objects of varying sizes. The overall architecture is illustrated in our design, and for clarity, the main concept is that the shallow layers provide fine-grained spatial details for small defects, while deeper layers offer global semantic information.
To further enhance detection accuracy, we applied CLAHE as a preprocessing step before feeding images into the network. This combination was named MobileNetV2-C-SSD. The training configuration included 200 epochs, a batch size of 8, an initial learning rate of 2e-5, and the SGD optimizer. The IOU threshold for matching positive and negative samples was set to 0.45. We evaluated our model using mean average precision (mAP) at an IOU threshold of 0.5, as well as model size and inference time.
Improvements for Small Target Detection
Detecting small defects in aerial images of solar panels is particularly challenging because these defects occupy only a few pixels and often lack sufficient discriminative features. The original SSD network extracts features in a single forward pass without cross-layer communication, which leads to a loss of semantic information for small objects in deeper layers. To overcome these challenges, we proposed three main improvements.
First, we introduced a Focal Loss function to address the class imbalance problem. The standard cross-entropy loss is given by:
$$ L_{CE} = – \sum_{i=1}^{N} \sum_{c=1}^{C} y_{i,c} \log(p_{i,c}) $$
where $N$ is the number of samples, $C$ is the number of classes, $y_{i,c}$ is the ground-truth indicator, and $p_{i,c}$ is the predicted probability. Focal Loss modifies this by adding a modulating factor:
$$ L_{FL} = – \sum_{i=1}^{N} \sum_{c=1}^{C} \alpha_c (1 – p_{i,c})^\gamma y_{i,c} \log(p_{i,c}) $$
Here, $\alpha_c$ balances the importance of positive and negative samples, and $\gamma$ controls the rate at which easy examples are down-weighted. In our experiments, we set $\alpha$ to a constant and $\gamma=2$. The use of Focal Loss encouraged the model to focus on hard-to-classify samples, such as rare defect types and small objects.
Second, we incorporated the Convolutional Block Attention Module (CBAM) after each effective feature layer. CBAM sequentially applies channel attention and spatial attention, allowing the network to emphasize informative features and suppress irrelevant background. The channel attention module first aggregates spatial information using both average-pooling and max-pooling, then passes the results through a multi-layer perceptron (MLP) to generate channel weights. The spatial attention module concatenates average-pooled and max-pooled features along the channel axis, then applies a $7 \times 7$ convolution to produce a spatial attention map. By multiplying the input feature map with these attention maps, the network becomes more selective. We also experimented with the SE attention mechanism, but CBAM consistently yielded better performance for solar panel defect detection.
Third, we constructed a Feature Pyramid Network (FPN) to enhance the semantic information of shallow feature layers. The FPN consists of a bottom-up pathway, a top-down pathway, and lateral connections. In our design, we selected three feature layers (Conv11, Conv13, and Conv14_2) to form a small FPN. The top-down pathway up-samples the higher-level features and fuses them with the corresponding bottom-up features via element-wise addition. This procedure enriches the spatial details with semantic context, resulting in stronger representations for small targets. The FPN structure can be summarized as:
$$ P_{out} = f_{conv}( U(f_{conv}(P_{in})) \oplus F_{lateral} ) $$
where $U$ denotes up-sampling, $\oplus$ is element-wise addition, and $f_{conv}$ represents a convolution operation. We integrated the FPN, CBAM, and Focal Loss into the MobileNetV2-C-SSD framework, producing our final small-target detection model.
Experiments and Results
Experimental Setup
All experiments were conducted on a machine equipped with an Intel Core i7-8750H CPU, 24 GB RAM, and an RTX 4090D GPU. The software environment consisted of Python 3.8, PyTorch 2.0.0, and CUDA 11.8. The input image resolution was set to 300×300 for all models. We trained each model for 200 epochs using the SGD optimizer with an initial learning rate of 2e-5 and a batch size of 8. The IOU threshold for positive sample assignment was set to 0.45. We report the mean Average Precision at IOU 0.5 (mAP@0.5) as the primary metric, along with model size and inference time.
Results on the PVEL-AD Dataset
We first evaluated the proposed MobileNetV2-C-SSD network on the PVEL-AD dataset. The performance comparison between the original SSD (VGG16 backbone), MobileNetV2-SSD (without CLAHE), and MobileNetV2-C-SSD (with CLAHE) is presented in the following table:
| Model | Backbone | Model Size (MB) | mAP@0.5 (%) | Inference Time (ms) |
|---|---|---|---|---|
| SSD-VGG16 | VGG16 | 105.2 | 72.33 | 23.6 |
| MobileNetV2-SSD | MobileNetV2 | 18.1 | 74.10 | 15.2 |
| MobileNetV2-C-SSD | MobileNetV2 | 18.1 | 78.57 | 14.9 |
As shown in the table, MobileNetV2-C-SSD achieves the highest mAP of 78.57%, which is 6.24 percentage points higher than the original SSD-VGG16, while the model size is reduced to about one-sixth of the original size. The inference time is also reduced to 14.9 ms, making it suitable for real-time applications. The improvement can be attributed to both the use of CLAHE image enhancement and the efficient feature extraction of MobileNetV2.
We further analyzed the performance on each defect category. The per-class AP values are listed below:
| Defect Class | SSD AP(%) | MobileNet-SSD AP(%) | MobileNet-C-SSD AP(%) |
|---|---|---|---|
| Black Core | 98.63 | 98.92 | 98.97 |
| Linear Crack | 41.32 | 39.32 | 40.54 |
| Finger Interruption | 73.76 | 72.10 | 72.14 |
| Horizontal Dislocation | 99.25 | 97.86 | 100.0 |
| Short Circuit | 100.0 | 100.0 | 100.0 |
| Star Crack | 44.62 | 41.01 | 47.23 |
| Thick Line | 75.24 | 74.90 | 74.74 |
| Vertical Dislocation | 45.83 | 68.75 | 91.67 |
The results indicate that MobileNetV2-C-SSD not only improves the overall mAP but also significantly boosts the AP for difficult defect classes such as vertical dislocation and star cracks. These defects are rare in the dataset, and the CLAHE preprocessing coupled with the lightweight architecture helps the model extract more distinctive features.
Evaluation of Small Target Detection Improvements
To validate the effectiveness of the proposed small-target detection algorithm, we conducted a series of experiments on the PVEL-AD dataset as well as on an aerial photovoltaic dataset. The aerial dataset consists of 1468 images with 3516 defect instances across three types: glass breakage (GB), hot spots (HSP), and partial shading (CRP). We applied the same training setup and compared the following variants: the baseline MobileNetV2-C-SSD, the model with Focal Loss only (focal_loss), the model with Focal Loss and CBAM (focal_loss+cbam), and the full model with FPN, CBAM, and Focal Loss (fpn+cbam+focal_loss).
The mAP results on the PVEL-AD dataset are summarized in the table below:
| Model | Backbone | mAP@0.5 (%) |
|---|---|---|
| SSD | VGG16 | 72.33 |
| MobileNetV2-SSD | MobileNetV2 | 74.10 |
| MobileNetV2-C-SSD | MobileNetV2 | 78.57 |
| focal_loss | MobileNetV2 | 77.46 |
| focal_loss+cbam | MobileNetV2+CBAM | 80.26 |
| fpn+cbam+focal_loss | MobileNetV2+CBAM+FPN | 81.14 |
From the table, we observe that the full model (fpn+cbam+focal_loss) achieves the highest mAP of 81.14%, which is 2.57 percentage points higher than the MobileNetV2-C-SSD baseline. Interestingly, adding Focal Loss alone slightly reduces the mAP compared to the baseline, suggesting that the class imbalance issue is not severe in this dataset, but when combined with CBAM and FPN, the performance improves significantly. This indicates that the attention and feature fusion modules are more crucial for capturing fine-grained defect information.
We also evaluated the models on the aerial photovoltaic dataset. The mAP curves during training are not shown here, but the final results are presented in the following table:
| Model | mAP@0.5 (%) | mAP@0.5:0.95 (%) |
|---|---|---|
| SSD | 72.67 | 31.67 |
| focal_loss | 85.47 | 40.37 |
| focal_loss+cbam | 85.97 | 41.80 |
| fpn+cbam+focal_loss | 86.06 | 44.93 |
The aerial dataset is more challenging due to the small size of the defects and the complexity of the background. The full model again achieves the best mAP@0.5 of 86.06% and a significantly higher mAP@0.5:0.95 of 44.93%, indicating better localization quality. The improvements validate the effectiveness of our design choices for small-object detection in solar panel inspection.
We further examined the per-class performance on the aerial dataset. The AP values for each defect type are displayed in the following table:
| Defect Class | SSD | focal_loss | cbam+focal_loss | fpn+cbam+focal_loss |
|---|---|---|---|---|
| HSP | 75.1 | 82.8 | 83.2 | 83.9 |
| GB | 86.0 | 88.5 | 91.0 | 90.3 |
| CRP | 56.9 | 85.1 | 83.7 | 84.0 |
For HSP, the fusion of CBAM and FPN improves the AP from 82.8% to 83.9%. For GB, the addition of FPN slightly reduces the AP from 91.0% to 90.3%, which may be due to overfitting to the larger objects represented by the GB class. However, for CRP, which has the fewest samples (104 instances), Focal Loss provides a dramatic improvement from 56.9% to 85.1%, and the final model maintains an AP of 84.0%, demonstrating the benefit of the loss function in handling rare classes.
Detection System Implementation
To make the proposed detection models practically usable, we developed a solar panel defect detection system based on PySide6, the official Python binding for the Qt framework. PySide6 provides a rich set of GUI components, such as buttons, text displays, file dialogs, and image viewers, which we leveraged to build an interactive interface. The system architecture includes a main detection window and a defect information recording table.
The detection window allows the user to load an image or video file, select the appropriate detection model based on the application scenario, and visualize the results with bounding boxes and confidence scores. It also includes an operator ID input field for traceability. The defect information recording window logs every detection result, including the image filename, defect type, coordinates, and confidence, and can export the summary to a spreadsheet via the “Save” button. This makes it easy to integrate the system into manufacturing or maintenance workflows.
We tested the system with several sample images containing different types of defects. For instance, an image with a crack defect was processed, and the system correctly identified two crack instances with confidence scores of 76% and 87%. Similarly, images with black core and thick line defects were accurately detected. For aerial images, we selected the small-target detection model, which successfully detected glass breakage defects with confidence scores above 90%. These tests confirm that the system is functional and reliable for real-world applications.
Conclusion
In this paper, we presented a comprehensive study on deep learning based defect detection for solar panels. We proposed a lightweight SSD network, MobileNetV2-C-SSD, which replaces the cumbersome VGG16 backbone with MobileNetV2 and applies CLAHE image enhancement. The model achieves higher mAP on the PVEL-AD dataset while reducing the model size by a factor of six. To address the challenging problem of small defect detection in aerial images, we integrated Focal Loss, CBAM attention, and FPN into the framework. Extensive experiments demonstrated that the combined model substantially improves detection accuracy and robustness, especially for rare and small-scale defects.
Furthermore, we implemented a PySide6-based detection system that allows users to switch between the two models according to the specific application scenario. The system provides a friendly graphical interface for image and video inspection, making it suitable for both factory quality control and photovoltaic plant maintenance. Although our results are promising, there is still room for improvement. Future work will focus on expanding the dataset with more diverse defect types, investigating advanced denoising techniques to handle images corrupted by noise, and optimizing the model for deployment on embedded devices. We believe that the proposed methods and system offer a valuable reference for the intelligent inspection of solar panels and contribute to the broader goal of sustainable energy production.
