In the context of the global energy restructuring, the contradiction between the growing demand for energy and the urgent need to reduce carbon emissions has become one of the central challenges of our time. Solar energy, as a clean, inexhaustible and widely distributed renewable energy source, has attracted considerable attention from governments, researchers and industries. Among all solar energy utilization technologies, the solar panel is the key device that directly converts sunlight into electricity. The performance of a solar panel strongly affects the efficiency and safety of the entire photovoltaic power generation system. In many countries, large-scale photovoltaic power plants have been deployed in deserts, hillsides, rooftops and even on water surfaces. However, the outdoor installation environment makes solar panels vulnerable to various defects, such as dust accumulation, cracks, hot spots, broken grids, stains, and foreign object attachment. These defects can significantly reduce the photoelectric conversion efficiency of the solar panel and, in severe cases, cause corrosion of the protective layer, short circuits in the internal circuit, and even fire hazards. Therefore, it is essential to perform reliable and efficient defect detection on solar panels.

In this dissertation, I focus on the problem of solar panel defect detection from aerial images captured by unmanned aerial vehicles. Traditional manual inspection of solar panel defects is time-consuming, labor-intensive, and often inaccurate. In order to solve these problems, I propose a deep-learning-based defect detection framework for solar panels. The proposed framework includes image enhancement, image feature extraction, an improved YOLOv4 model, and the introduction of the SKnet attention mechanism. The experimental results show that the proposed method can effectively improve the detection accuracy of small solar panel defects and reduce the false detection rate.
1. Background and Research Significance
The global energy system is undergoing a profound transformation. With the increasing depletion of fossil fuels and the growing severity of environmental pollution, the development of clean and renewable energy has become a common goal for many countries. Solar photovoltaic power generation is one of the most promising clean energy technologies. According to statistics, the global installed capacity of photovoltaic systems has been growing rapidly in recent years. In 2020, China’s newly installed photovoltaic capacity reached 48.2 GW, with a year-on-year increase of 60%. China’s total installed photovoltaic capacity reached 253 GW, ranking first in the world. Photovoltaic power generation in 2020 reached 2605 kWh, and the average utilization rate of photovoltaic systems exceeded 97.9%.
Although the utilization of solar energy has increased rapidly, the operation and maintenance of photovoltaic power plants still face many challenges. The solar panel is the core component of a photovoltaic power station. Its photoelectric conversion efficiency directly determines the power generation efficiency of the entire power plant. During long-term outdoor operation, solar panels are exposed to harsh environmental conditions, including strong ultraviolet radiation, temperature changes, wind and sand, rain, snow, hail, and bird droppings. These factors can cause various types of damage to the surface and internal structure of solar panels. Furthermore, dust accumulation on the surface of solar panels can block sunlight, reducing the amount of light reaching the photovoltaic cells. If dust accumulates for a long time, it may corrode the glass cover and cause micro-cracks or hot spots.
| Defect type | Visual characteristic | Causes |
|---|---|---|
| Shape defects | Missing corners, broken edges, cracks | Impact, abrasion, wind and sand |
| Color defects | Hot spots, local dark areas | Shading, cell damage, mismatch |
| Texture defects | Stains, wheel marks, abnormal spots | Manufacturing or manual handling issues |
| Dust accumulation | Grey or brown layer on the surface | Environmental deposition |
Solar panel defects not only reduce power generation efficiency but also shorten the service life of solar panels. For example, cracks in solar cells may lead to local short circuits and hot spots, which can further damage the module. Broken fingers or busbars may cause a significant drop in output power. Therefore, the development of an efficient, accurate, and low-cost defect detection system for solar panels is of great practical importance.
2. Literature Review of Solar Panel Defect Detection
In recent years, researchers have proposed various methods for solar panel defect detection. These methods can be generally divided into three categories: gradient-feature-based methods, clustering-based methods, and machine-learning-based methods.
2.1 Gradient-Feature-Based Detection Methods
Gradient-based methods use the intensity difference between the defective region and the surrounding normal region. In a solar panel image, the boundary of a defect usually has a large gradient value because the brightness changes sharply. Anwar and Tsai proposed a method that combines gradient information with anisotropic diffusion. This method sharpens high-gradient regions and smooths low-gradient regions, allowing the algorithm to preserve the defect features while suppressing noise. Tsai also proposed a gradient-based edge detection method combined with mean shift. The algorithm calculates the gradient direction entropy and then applies mean-shift smoothing to the entropy map. This method can automatically find the number of clusters and preserve edge features while reducing noise.
2.2 Clustering-Based Detection Methods
Clustering-based methods divide the image into defect and non-defect regions using segmentation algorithms. The K-Means algorithm is widely used for this purpose. The algorithm first chooses the number of clusters and initial cluster centers. Then, each pixel is assigned to the nearest center. The cluster centers are updated by calculating the mean coordinates of all points in each cluster. This procedure is repeated until convergence. In solar panel defect detection, K-Means clustering can separate defect areas from the background by grouping pixels with similar intensity or color characteristics.
Another common method is the Otsu thresholding method, which is a maximum inter-class variance method. The algorithm determines an optimal threshold by maximizing the variance between the foreground and background classes. After binarization, the defect region can be extracted. Some researchers have proposed combining L0 gradient minimization with K-Means clustering for solar panel defect detection. This method smooths the image and removes background texture noise while preserving edges, and then performs clustering to extract the defect region.
2.3 Machine-Learning-Based Detection Methods
Machine-learning-based methods have become increasingly popular for solar panel defect detection. Support vector machines and convolutional neural networks are widely used classifiers. In a typical approach, images are first labeled as defective or non-defective. Feature vectors are extracted from the labeled samples using local descriptors. Then, the feature vectors are used to train a support vector machine classifier. With the development of deep learning, more advanced methods such as Faster R-CNN, SSD, and YOLO have been applied to solar panel defect detection. These methods can automatically learn hierarchical feature representations from raw images and achieve real-time detection with high accuracy.
| Category | Advantages | Disadvantages |
|---|---|---|
| Gradient-based methods | Good performance on high-contrast defects | Sensitive to noise and complex backgrounds |
| Clustering-based methods | Simple implementation, no training required | Many parameters need manual tuning |
| Machine-learning methods | High accuracy, strong generalization, real-time capability | Requires large annotated dataset and computing resources |
From the comparison above, deep-learning-based methods are more suitable for solar panel defect detection because they can recognize defects with high precision and speed. Therefore, in this dissertation, I choose YOLOv4 as the basic detection framework and introduce the SKnet attention mechanism to improve its performance on small solar panel defects.
3. Fundamentals of Deep Learning and Convolutional Neural Networks
Deep learning is a branch of machine learning that uses multi-layer neural networks to learn representations from data. Convolutional neural networks are the most important deep learning models for image processing and computer vision tasks.
3.1 The Artificial Neuron
The basic component of a neural network is the artificial neuron, also called a perceptron. A neuron receives input signals, multiplies them by weights, adds a bias, and passes the result through an activation function. The mathematical expression is:
$$
y = f\left( \sum_{i=1}^{n} w_i x_i + b \right)
$$
where \(x_i\) are the input signals, \(w_i\) are the weights, \(b\) is the bias, and \(f\) is the activation function. The activation function introduces nonlinearity, which allows the network to learn complex patterns.
3.2 Convolutional Neural Network Structure
A convolutional neural network typically consists of the following layers:
- Input layer: performs data preprocessing such as grayscale conversion and normalization.
- Convolutional layer: extracts local features using convolution kernels.
- Activation layer: introduces nonlinearity using functions such as ReLU, sigmoid, or tanh.
- Pooling layer: reduces the spatial size of feature maps while preserving important information.
- Fully connected layer: maps the extracted features to the final classification output.
The convolution operation can be expressed as:
$$
F(i,j) = \sum_{m} \sum_{n} I(i+m, j+n) K(m,n)
$$
where \(I\) is the input image, \(K\) is the convolution kernel, and \(F\) is the output feature map. Pooling operations include max pooling and average pooling. Max pooling selects the maximum value from each local region, while average pooling computes the average value. These operations help reduce the number of parameters and control overfitting.
3.3 Traditional Object Detection Algorithms
Before the rise of deep learning, traditional object detection algorithms such as Viola-Jones, HOG, and DPM were widely used. The Viola-Jones algorithm achieved real-time face detection by using Haar-like features and an AdaBoost classifier. The HOG algorithm calculates histograms of oriented gradients in local image blocks and is robust to illumination changes. The DPM detector uses a root filter and part filters to represent an object with multiple components. Although these methods have been largely replaced by deep learning methods, they contain important ideas such as feature pyramids and bounding box regression.
3.4 Modern Object Detection Models
Modern object detection models can be divided into two categories: two-stage detectors and one-stage detectors.
Two-stage detectors, such as R-CNN, Fast R-CNN, Faster R-CNN, and SPP-Net, first generate candidate regions called region proposals, and then classify each region and refine its bounding box. R-CNN uses selective search to generate about 2000 candidate boxes, extracts features using a convolutional neural network, and then uses a support vector machine for classification. SPP-Net introduces spatial pyramid pooling to allow input images of arbitrary sizes. Fast R-CNN improves the speed by sharing computation through the ROI pooling layer. Faster R-CNN replaces selective search with a region proposal network, which makes the whole detection pipeline trainable.
One-stage detectors, such as SSD and YOLO, directly predict both class probabilities and bounding box coordinates from feature maps. YOLO divides the input image into a grid and performs classification and regression for each grid cell. The YOLO family has undergone many improvements. YOLOv2 introduces batch normalization, anchor boxes, and multi-scale training. YOLOv3 uses a deeper backbone network called Darknet-53 and introduces feature pyramid networks to improve small object detection. YOLOv4 further improves the performance by combining CSPDarknet53, PANet, and various data augmentation techniques.
In this dissertation, I choose YOLOv4 as the baseline model because it achieves a good balance between speed and accuracy for solar panel defect detection.
4. Image Processing and Feature Extraction for Solar Panel Images
Images captured by unmanned aerial vehicles often suffer from distortion, noise, and poor visibility due to weather conditions. These problems can reduce the accuracy of defect detection. Therefore, image preprocessing is necessary before feeding the images into the detection model.
4.1 Image Distortion Correction
Optical lenses cause distortion in captured images. There are two main types of lens distortion: radial distortion and tangential distortion. Radial distortion comes from the bending of light rays, while tangential distortion is caused by the lens not being perfectly parallel to the image plane. The Brown model is widely used to describe lens distortion. The distorted point coordinates can be corrected by:
$$
x_u = x_d + \delta_x(x_d, y_d)
$$
$$
y_u = y_d + \delta_y(x_d, y_d)
$$
where \((x_d, y_d)\) are the distorted coordinates and \((x_u, y_u)\) are the undistorted coordinates. The distortion terms \(\delta_x\) and \(\delta_y\) are usually modeled as:
$$
\delta_x = x_d(k_1 r^2 + k_2 r^4 + k_3 r^6) + p_1(3x_d^2 + y_d^2) + 2p_2 x_d y_d
$$
$$
\delta_y = y_d(k_1 r^2 + k_2 r^4 + k_3 r^6) + p_2(x_d^2 + 3y_d^2) + 2p_1 x_d y_d
$$
where \(r^2 = x_d^2 + y_d^2\), \(k_1, k_2, k_3\) are radial distortion coefficients, and \(p_1, p_2\) are tangential distortion coefficients. By estimating these parameters, we can correct the distortion in solar panel images and improve the quality of defect detection.
4.2 Haze Removal
Haze and fog can severely degrade the visibility of solar panel images captured by drones. I adopt the dark channel prior method for haze removal. The dark channel of an image is defined as:
$$
J^{dark}(x) = \min_{c \in \{r,g,b\}} \left( \min_{y \in \Omega(x)} J^c(y) \right)
$$
where \(J^c\) is the color channel of the image and \(\Omega(x)\) is a local patch centered at pixel \(x\). According to the dark channel prior, for a haze-free outdoor image, the dark channel value tends to be zero:
$$
J^{dark}(x) \to 0
$$
The haze formation model is commonly expressed as:
$$
I(x) = J(x)t(x) + A(1-t(x))
$$
where \(I(x)\) is the observed hazy image, \(J(x)\) is the clean image, \(A\) is the global atmospheric light, and \(t(x)\) is the transmission map. Using the dark channel prior, the estimated transmission is:
$$
\tilde t(x) = 1 – \omega \min_{c} \left( \min_{y \in \Omega(x)} \frac{I^c(y)}{A^c} \right)
$$
where \(\omega\) is a parameter between 0 and 1. Finally, the hazy image is recovered by:
$$
J(x) = \frac{I(x) – A}{\max(t(x), t_0)} + A
$$
where \(t_0\) is a lower bound to avoid division by zero. Experimental results show that haze removal significantly improves the visual quality of solar panel images.
4.3 Color Features
Color features are widely used in image recognition because they are relatively insensitive to changes in object size and orientation. The color histogram describes the global distribution of colors in an image. The color moment is a compact feature representation. The first-order moment is the mean, the second-order moment is the variance, and the third-order moment is the skewness. These moments are defined as:
$$
\mu_i = \frac{1}{N}\sum_{j=1}^{N} P_{ij}
$$
$$
\sigma_i = \sqrt{\frac{1}{N}\sum_{j=1}^{N} (P_{ij} – \mu_i)^2}
$$
$$
s_i = \frac{1}{N}\sum_{j=1}^{N} (P_{ij} – \mu_i)^3
$$
where \(P_{ij}\) is the value of the \(i\)-th color component of the \(j\)-th pixel and \(N\) is the total number of pixels. Color moments are simple but have limited discriminative power, so they are often used with other features.
4.4 Texture Features
Texture features describe the spatial arrangement of pixel intensities. The gray-level co-occurrence matrix is a common method for texture feature extraction. The gray difference statistics method defines the difference between a pixel and its neighbor as:
$$
\Delta g(x,y) = g(x,y) – g(x+\Delta x, y+\Delta y)
$$
The average, contrast, and entropy of the gray difference histogram can be used to describe texture roughness:
$$
Mean = \frac{1}{N}\sum_i i p(i)
$$
$$
Contrast = \sum_i i^2 p(i)
$$
$$
Entropy = -\sum_i p(i) \log_2 p(i)
$$
The autocorrelation function is another way to measure texture roughness. For an image \(f(x,y)\), the autocorrelation function is defined as:
$$
C(\varepsilon, \eta) = \frac{\sum_{x} \sum_{y} f(x,y) f(x+\varepsilon, y+\eta)}{\sum_{x} \sum_{y} f(x,y)^2}
$$
A rough texture tends to have a slowly decaying autocorrelation curve, while a smooth texture decays quickly.
In this dissertation, I use Gabor filters for texture feature extraction. The two-dimensional Gabor filter is defined as:
$$
G(x,y,\theta,f) = \exp \left( -\frac{x’^2 + \gamma^2 y’^2}{2\sigma^2} \right) \cos(2\pi f x’)
$$
where \(x’ = x\cos\theta + y\sin\theta\), \(y’ = -x\sin\theta + y\cos\theta\), \(\sigma\) is the scale parameter, \(\theta\) is the orientation, and \(f\) is the frequency. Gabor filters can extract multi-scale and multi-directional texture information from solar panel images.
4.5 Shape Features
Shape features describe the geometric structure of an object. The Fourier shape descriptor is a classical shape representation method. The boundary points of an object are represented as complex numbers:
$$
s(k) = x(k) + j y(k)
$$
The discrete Fourier transform of the boundary gives the Fourier descriptor:
$$
a(u) = \sum_{k=0}^{N-1} s(k) e^{-j 2\pi u k / N}
$$
The inverse Fourier transform reconstructs the shape. The invariant moment method is also used to describe shape features. Hu moments are invariant to translation, rotation, and scaling, which makes them suitable for recognizing solar panel defects of different sizes and orientations.
4.6 Fusion of Texture and Shape Features
In solar panel defect detection, defects such as cracks and stains may be similar in color to dust or dirt. Using only shape features may cause false detection. I propose to fuse texture features with shape features to improve the discriminative ability of the model. The shape feature extraction method is used to obtain the global structure of defects, and the Gabor texture feature extraction method is used to describe the local texture details. The two feature sets are then combined into a single feature vector. This fusion method can effectively distinguish solar panel defects from non-defective areas such as dust and stains.
5. Improved YOLOv4 Model for Solar Panel Defect Detection
5.1 Dataset Construction
In my experiment, I obtained a dataset of solar panel images from an online platform. A total of 728 images were manually annotated using the LabelImg tool. Each image was labeled with rectangles around the defect areas. The defects were classified into two categories: “defect” and “dust”. The annotation information includes the image file name, image width and height, class name, and the bounding box coordinates.
| filename | Width | Height | Class | Xmin | Ymin | Xmax | Ymax |
|---|---|---|---|---|---|---|---|
| Cel0001.png | 300 | 300 | defect | 64 | 114 | 84 | 192 |
| Cel0001.png | 300 | 300 | dust | 144 | 82 | 154 | 96 |
The annotated data were converted into the VOC format for training the YOLOv4 model. The dataset was divided into training and testing sets with a ratio of 9:1.
5.2 YOLOv4 Algorithm
YOLOv4 is a one-stage object detector that achieves high speed and high accuracy. The backbone of YOLOv4 is CSPDarknet53, which is a modified version of Darknet53 that combines the design of Cross Stage Partial networks. The neck of YOLOv4 uses the PANet structure to fuse multi-scale features from different layers. The head retains the YOLOv3 detection head. YOLOv4 also uses the Mish activation function:
$$
Mish(x) = x \cdot \tanh\left( \ln(1+e^x) \right)
$$
During training, YOLOv4 uses Mosaic data augmentation, label smoothing, CIOU loss, and cosine annealing learning rate decay. These techniques improve the robustness and generalization of the model.
5.3 SKnet Attention Mechanism
SKnet is an attention mechanism that dynamically selects different convolution kernel sizes based on the input features. The SKnet module consists of three parts: Split, Fuse, and Select. In the Split stage, the input feature map is processed by multiple branches with different kernel sizes. In the Fuse stage, the resulting feature maps are summed element-wise:
$$
U = \tilde{U}_1 + \tilde{U}_2 + \cdots + \tilde{U}_L
$$
Then global average pooling is applied to generate channel statistics:
$$
s_c = F_{gp}(U_c) = \frac{1}{H \times W} \sum_{i=1}^{H} \sum_{j=1}^{W} U_c(i,j)
$$
Next, a fully connected layer generates a low-dimensional feature vector:
$$
z = F_{fc}(s) = \delta(W s)
$$
where \(\delta\) is the ReLU activation function, \(W\) is the weight matrix, and the dimension \(d\) is determined by:
$$
d = \max\left( \frac{C}{r}, L \right)
$$
where \(C\) is the number of channels, \(r\) is the reduction ratio, and \(L\) is the number of branches. In the Select stage, softmax is used to compute the attention weights for each branch. The final output is the weighted sum of the branch features:
$$
V = \sum_{i=1}^{L} a_i \tilde{U}_i
$$
where \(a_i\) are the softmax attention weights. This mechanism enables the network to adaptively choose the most suitable receptive field for each region, which is beneficial for detecting solar panel defects of various sizes.
5.4 Embedded Design of SKnet in YOLOv4
I consider three different positions to insert the SKnet module into the YOLOv4 network:
- YOLOv4-SKnet-A: insert SKnet after the concat and add layers in the backbone network.
- YOLOv4-SKnet-B: insert SKnet after the concat layers in the neck network.
- YOLOv4-SKnet-C: insert SKnet before the detection heads.
The backbone network extracts rich low-level and mid-level features. By inserting SKnet into the backbone, the network can better select appropriate convolution kernels for extracting solar panel defect features. The neck network fuses multi-scale features, and inserting SKnet there may help re-weight the fused features. The detection head directly predicts the final results, and inserting SKnet before the head may improve the classification and regression performance.
5.5 Experimental Setup
The experiments were conducted on a hardware platform with an Intel Xeon Silver 4110 CPU and an NVIDIA GeForce RTX 2080 Ti GPU. The software environment included Windows, Python 3.7, and PyTorch 1.2.0. The input image size was set to 416 by 416. The initial learning rate was 0.001, and it was decayed by a factor of 0.1 every 50 epochs. The momentum was 0.9, the weight decay coefficient was 0.0005, and the batch size was 8. The SGD optimization algorithm was used, and the total number of training epochs was 200.
5.6 Evaluation Metrics
I used precision, recall, F1 score, and mean average precision to evaluate the performance of the model. These metrics are defined as:
$$
P = \frac{TP}{TP + FP}
$$
$$
R = \frac{TP}{TP + FN}
$$
$$
F1 = \frac{2PR}{P + R}
$$
$$
mAP = \frac{1}{C} \sum_{i=1}^{C} AP_i
$$
where \(TP\) is the number of true positives, \(FP\) is the number of false positives, \(FN\) is the number of false negatives, \(C\) is the number of classes, and \(AP_i\) is the average precision of class \(i\). The average precision is computed as:
$$
AP = \int_0^1 P(R) \, dR
$$
5.7 Experimental Results
The experimental results on the solar panel defect dataset are shown in Table 4.
| Model | Precision (%) | Recall (%) | mAP@0.5 (%) |
|---|---|---|---|
| YOLOv4 baseline | 60.2 | 72.4 | 71.2 |
| YOLOv4-SKnet-A | 57.2 | 74.5 | 73.5 |
| YOLOv4-SKnet-B | 59.5 | 71.3 | 69.4 |
| YOLOv4-SKnet-C | 52.4 | 76.2 | 70.3 |
From the results, I observe that inserting the SKnet module into the backbone network (YOLOv4-SKnet-A) improves the mAP@0.5 from 71.2% to 73.5%, which is an improvement of 2.3%. However, inserting SKnet into the neck or detection head does not lead to clear improvements; in fact, it may even decrease the detection accuracy. The reason is that the backbone network contains more low-level and middle-level feature information, which is crucial for detecting small solar panel defects. By applying the attention mechanism in the backbone, the model can focus more effectively on the important spatial and channel features of solar panel defects.
The improved model also improves the confidence score for small defects. Compared with the original YOLOv4 model, the improved model can detect dusty regions and cracks on solar panels with higher confidence. The proposed method also successfully identifies small dust regions that were missed by the original model.
6. Conclusion and Future Work
In this dissertation, I have studied the application of deep learning for solar panel defect detection. The main contributions of my work are as follows.
First, to solve the problems of image distortion and haze in aerial solar panel images, I have proposed an image enhancement method that combines distortion correction and dark channel haze removal. The simulation results show that the processed images have significantly better visual clarity and can provide more useful information for subsequent defect detection.
Second, because solar panel defects are often very similar to the normal surface in color and shape, I have proposed a feature extraction method that fuses shape and texture features. The fusion method can better highlight the local features of defects and reduce the false detection of dust and stains as defects.
Third, I have proposed an improved YOLOv4 model by inserting the SKnet attention mechanism into different layers of the network. Through careful experiments, I found that inserting SKnet into the backbone layer improves the detection accuracy of small solar panel defects. The mAP@0.5 is improved by 2.3%, and the model is more precise and effective for small-target detection.
There are still several directions for future research. The proposed method can be further improved by testing more advanced attention mechanisms, such as coordinate attention or transformer-based modules. In addition, the detection of extremely small defects and defects with low contrast remains a challenge. In the future, I plan to explore multi-scale feature enhancement, more efficient data augmentation, and lightweight network design for real-time solar panel defect detection on edge devices. The integration of the proposed detection system with unmanned aerial vehicle inspection platforms also deserves further study.
In summary, the research on solar panel defect detection based on deep learning has important theoretical and practical value. It can effectively improve the power generation efficiency of photovoltaic systems, reduce equipment failures, lower operation and maintenance costs, and ensure the safe and efficient operation of photovoltaic power generation systems.
