Real-Time Solar Panel Defect Detection with Lightweight YOLOv5

Solar panels are the core components of photovoltaic power generation systems, and their surface defects—such as cracks, dirt, and hot spots—seriously degrade the power conversion efficiency and operational lifetime of solar panels. Traditional manual inspection methods suffer from low efficiency, high labor costs, and inconsistent quality. The integration of unmanned aerial vehicles (UAVs) with intelligent inspection has opened a new pathway for diagnosing solar panel diseases. Deep learning-based object detection techniques have achieved remarkable progress in industrial defect detection, yet balancing accuracy and real-time performance remains an open challenge. In this work, I present a real-time detection framework based on a lightweight YOLOv5 model specifically designed for solar panel surface defect identification. The proposed method addresses the diversity of defect scales and the complexity of background interference while maintaining a compact model suitable for embedded deployment.

Defects on solar panel surfaces exhibit significant variations in scale, shape, and texture. For example, micro-cracks require fine local features, whereas large hot spots demand global contextual information. Moreover, defects are often mixed with background shadows, dust, and grid textures, making feature extraction difficult. To tackle these challenges, I introduce a multi-scale feature extraction and fusion strategy. The backbone network, named L-CSPDarknet53, incorporates cross-stage partial (CSP) connections and depthwise separable convolutions to reduce computational complexity while preserving multi-scale feature representation. Additionally, a channel shuffle operation is applied after group convolutions to enhance cross-group information exchange. In the loss function, I replace the conventional CIoU with Focal-EIoU to explicitly optimize width and height errors and handle the imbalance between easy and hard samples. Furthermore, the MetaAconC activation function is integrated to adaptively adjust activation thresholds, improving sensitivity to subtle defects. Extensive experiments on a public solar panel defect dataset demonstrate that the proposed method achieves superior detection accuracy and real-time inference speed compared with existing approaches.

Related Work

Various methods have been proposed for solar panel defect detection. One common approach is based on improved K-means clustering, which segments hot spot regions in infrared images by optimizing the clustering algorithm. Although this method performs well under specific illumination conditions, it relies on manually designed features and exhibits limited generalization capability, especially for small defects in complex backgrounds. Another line of research employs multi-source image fusion, combining visible light and infrared image features to improve robustness. While this fusion-based method enhances detection accuracy by leveraging multimodal data, it suffers from high computational complexity and poor real-time performance, making it difficult to satisfy the requirements of large-scale photovoltaic power plant inspections.

In contrast, deep learning-based detectors, especially one-stage object detectors such as YOLO, offer a better trade-off between speed and accuracy. However, standard YOLO models are often too heavy for edge devices on UAVs. Therefore, I propose a lightweight YOLOv5 architecture that reduces the parameter count and computational cost without sacrificing detection precision. The design choices are grounded in the principles of efficient neural network design, including depthwise separable convolutions, group convolutions, and lightweight attention mechanisms.

Proposed Method

Feature Extraction and Fusion for Solar Panel Defects

To effectively detect defects with diverse visual characteristics, the feature extractor must capture both fine-grained local details and high-level semantic information. In the proposed L-CSPDarknet53 backbone, I introduce three CSP modules, denoted as CSP1X where X=1,2,3. Each module follows a dual-branch structure. In the first branch, a standard CBS block (Conv+BN+SiLU) performs initial feature extraction. In the second branch, an improved residual unit called D_Resunit is used to mine deeper features. To reduce computational cost, I replace traditional convolutions with a combination of group convolution and depthwise separable convolution (DSConv).

Group convolution divides the input feature maps into multiple groups along the channel dimension, with each group convolving independently. The number of parameters becomes \(1/G\) of that of a standard convolution, where \(G\) is the number of groups. The parameter ratio is given by:

\[
\frac{n \cdot (C/G) \cdot K^2}{n \cdot C \cdot K^2} = \frac{1}{G}
\]

where \(n\) is the number of convolution kernels, \(C\) is the number of input channels, and \(K\) is the kernel size. Although group convolution significantly reduces parameters, it also isolates information across different channel groups, weakening the global representational power. To mitigate this issue, I insert a channel shuffle operation after the group convolution. Channel shuffle periodically reorganizes the output feature channels from different groups, allowing subsequent convolutional layers to receive inputs from all groups. This mechanism promotes cross-group feature interaction and enhances the model’s ability to learn complex feature patterns—particularly beneficial for fine-grained visual tasks such as detecting micro-cracks on solar panels.

Depthwise separable convolution further decomposes a standard convolution into a depthwise convolution (DWConv) followed by a pointwise convolution (PWConv). DWConv applies a single convolution kernel per input channel to capture spatial features, while PWConv uses \(1\times1\) convolutions to combine channels. The computational cost ratio compared with standard convolution is:

\[
\frac{D_K^2 \cdot m \cdot H \cdot W + m \cdot n \cdot H \cdot W}{D_K^2 \cdot m \cdot n \cdot H \cdot W} = \frac{1}{n} + \frac{1}{D_K^2}
\]

where \(m\) is the number of input channels, \(n\) is the number of output channels, \(D_K\) is the kernel size, and \(H,W\) are the feature map dimensions. With a common \(3\times3\) convolution, this decomposition reduces the computational cost to roughly one-ninth of that of a standard convolution. To preserve spatial information, I adopt a \(3\times3\) average pooling for the residual connection in the D_Resunit.

To further improve sensitivity to subtle defects, I introduce the MetaAconC activation function in the feature fusion stage. MetaAconC dynamically adjusts the activation threshold for each neuron, enabling adaptive selection of activated states and effectively mitigating the “gradient vanishing” problem. The resulting L-CSPDarknet53 backbone maintains strong feature extraction capability while being computationally light, making it suitable for deployment on embedded devices in UAV inspection systems.

Loss Function Improvement for Real-Time Monitoring

The original YOLOv5 loss function combines bounding box regression loss, objectness loss, and classification loss. The regression loss uses CIoU, which considers the overlapping area, center point distance, and aspect ratio. However, the aspect ratio term is based on relative values, leading to inaccurate fitting for large defects such as elongated cracks. Additionally, conventional data processing does not adequately account for difficult samples caused by blur, occlusion, and background clutter, resulting in suboptimal gradient updates.

To overcome these issues, I adopt the Focal-EIoU loss instead of CIoU. The EIoU loss explicitly decomposes the width and height differences and computes the \(L2\) distances between the predicted bounding box and the ground truth box. The definition is:

\[
L_{EIoU} = 1 – IoU + \frac{\rho^2(\mathbf{b}, \mathbf{b}^{gt})}{c^2} + \frac{\rho^2(w, w^{gt})}{w_c^2} + \frac{\rho^2(h, h^{gt})}{h_c^2}
\]

where \(\mathbf{b}\) and \(\mathbf{b}^{gt}\) are the center point coordinates of the predicted and ground truth boxes, \(w\) and \(h\) are the width and height of the predicted box, \(w_c\) and \(h_c\) are the width and height of the minimum enclosing rectangle, \(c\) is the diagonal length of the minimum enclosing rectangle, and \(\rho(\cdot)\) denotes the Euclidean distance. By directly optimizing the width and height errors, EIoU improves localization accuracy, especially for objects with extreme aspect ratios.

To address the severe imbalance between easy and hard samples, I incorporate the Focal Loss mechanism. Focal Loss applies a dynamic scaling factor to the standard cross-entropy loss, down-weighting the loss contribution from well-classified (easy) samples and focusing training on hard samples. In the context of bounding box regression, I combine Focal Loss with EIoU to obtain the Focal-EIoU loss:

\[
L_{Focal-EIoU} = IoU^{\gamma} \cdot L_{EIoU}
\]

where \(\gamma\) is a focusing parameter typically set between 0.5 and 2.0. This loss function effectively reduces the gradient dominance of easy negative samples and directs the optimization process toward challenging cases, improving the model’s robustness in scenarios with small defects and blurred edges.

Multi-Scale Feature Fusion and Activation

YOLOv5 employs a feature pyramid network to integrate multi-scale features at three resolutions: \(160\times160\), \(80\times80\), and \(40\times40\). This enables the detection of both small objects (e.g., micro-cracks) and large objects (e.g., hot spots) on solar panels. In the proposed lightweight model, I further add a small-object detection layer to enhance the detection of subtle defects. This layer uses higher-resolution feature maps with rich spatial details, improving recall for tiny defects.

In addition, the MetaAconC adaptive activation function is integrated during feature fusion. Unlike fixed activation functions such as ReLU or SiLU, MetaAconC learns to adjust the activation threshold based on the input feature distribution. When the input contains weak but meaningful defect patterns, the activation response is amplified to highlight the subtle features in deeper layers. Conversely, for background noise or redundant features, the activation strength is suppressed, preventing interference with the main features. This data-driven soft threshold adjustment not only enhances the model’s generalization to different defect types but also improves the fusion and transmission efficiency of multi-scale weak defects in the feature pyramid network.

The overall detection pipeline forms a closed loop: lightweight model design → embedded deployment → multi-scale detection → real-time feedback. This architecture delivers low-latency and high-precision detection for solar panel inspections in photovoltaic power stations.

Experiments and Results

Experimental Setup

To evaluate the proposed lightweight YOLOv5 method, I compare it against two baseline methods: a K-means clustering-based method (denoted as Baseline A) and a multi-source fusion method (denoted as Baseline B). All experiments are conducted in the same hardware environment, as summarized in Table 1.

Table 1: Experimental Platform Configuration
Item Specification
Operating System Ubuntu 20.04 LTS
CPU Intel i7-12700K
GPU NVIDIA RTX 3090 (24 GB VRAM)
Frameworks PyTorch 1.12.0 (proposed), OpenCV 4.5.5 (Baseline A), TensorFlow 2.8.0 (Baseline B)
Memory 64 GB DDR4

For the proposed method, the lightweight YOLOv5 model is trained with the hyperparameters listed in Table 2. Baselines A and B use their original parameter settings to ensure fair comparison.

Table 2: Training Parameters for the Proposed Method
Parameter Value
Input size 640 × 640
Batch size 16
Initial learning rate 0.01 (cosine annealing)
Number of epochs 300
Optimizer SGD (momentum=0.937, weight decay=0.0005)

Dataset Description

The experiments use the public PV-FDD dataset, which contains three types of solar panel surface defects: cracks (thin, low-contrast defects), hot spots (local high-temperature regions), and dirt (irregular surface contamination). The dataset comprises 5,200 images, divided into a training set of 4,160 images and a test set of 1,040 images (80/20 split). To simulate real-world conditions, the test set includes varied illumination conditions (strong light, shadows) and complex backgrounds (e.g., vegetation occlusion).

Comparison Results

To verify the detection performance, I use mean Average Precision (mAP@0.5) and Recall as evaluation metrics. Table 3 presents the detection results for the three methods.

Table 3: Comparison of Detection Performance among Different Methods
Method mAP@0.5 (%) Recall (%) Parameters (M) FPS (f/s)
Baseline A (K-means clustering) 72.3 68.5 — 2.1
Baseline B (multi-source fusion) 85.6 79.2 108.9 8.7
Proposed (L-YOLOv5) 96.7 93.4 3.4 37.4

As observed from Table 3, the proposed method achieves a mAP of 96.7%, which is significantly higher than both baselines. This improvement is attributed to the end-to-end feature learning capability of deep learning, whereas traditional methods rely on manually designed features and thus have limited generalization. The recall of the proposed method is also considerably higher, indicating that the lightweight model reduces the miss rate for small targets such as micro-cracks. Furthermore, the proposed method runs at 37.4 frames per second (FPS), far exceeding both baselines, which makes it suitable for real-time inspection tasks on UAVs.

Ablation Study

To analyze the contribution of each improvement module, I conduct an ablation study on the proposed method. The results are reported in Table 4.

Table 4: Ablation Study on the Test Set (mAP@0.5)
Model Variant mAP (%) FPS (f/s) Parameters (M)
Original YOLOv5 93.4 25.1 13.7
+L-CSPDarknet53 92.6 40.4 3.1
+DC-SPP module 94.6 37.9 3.3
+Small-object detection layer (final) 96.7 37.4 3.4

From Table 4, it is clear that the L-CSPDarknet53 backbone reduces the parameter count by 77% and increases FPS by 61% at the cost of only 1.1% mAP degradation. The DC-SPP module, which employs dilated convolutions to preserve fine details, improves mAP by 2.0%. The small-object detection layer further enhances detection of subtle defects by 2.1%. These results confirm that each component contributes meaningfully to the overall performance and that the final model achieves a favorable balance between accuracy and efficiency.

Discussion

The high detection accuracy of the proposed lightweight YOLOv5 model on solar panel defects can be attributed to several key design choices. First, the use of depthwise separable convolutions and group convolutions dramatically reduces the computational burden, allowing the model to operate in real time on resource-constrained platforms. Second, the channel shuffle operation ensures that information flows across groups, preventing the loss of important feature interactions. Third, the Focal-EIoU loss directly optimizes the bounding box regression by decomposing width and height errors, which is particularly effective for defects with elongated shapes such as cracks. Finally, the MetaAconC activation function adapts to the input distribution, enhancing the network’s ability to detect weak defect signals against complex backgrounds.

Moreover, the proposed method demonstrates strong generalization across different defect types including cracks, hot spots, and dirt. The multi-scale feature fusion with the small-object detection layer ensures that both tiny and large defects are captured. In practical inspection scenarios, UAVs equipped with this model can rapidly scan large areas of solar panel arrays, identify defective panels, and provide real-time feedback to maintenance crews. The low parameter count also means that the model can be easily deployed on embedded devices such as NVIDIA Jetson or Raspberry Pi with appropriate optimization.

Conclusion

In this paper, I have proposed a real-time solar panel surface defect detection method based on a lightweight YOLOv5 architecture. The method incorporates several novel components: an efficient L-CSPDarknet53 backbone with group convolution and depthwise separable convolution, a channel shuffle mechanism to improve feature interaction, a Focal-EIoU loss to refine bounding box regression, and a MetaAconC activation function to enhance sensitivity to subtle defects. Experimental results on the PV-FDD dataset demonstrate that the proposed method achieves 96.7% mAP and 37.4 FPS, outperforming both a K-means clustering method and a multi-source fusion method. The ablation study confirms the effectiveness of each module.

In future work, I plan to improve the robustness of the model under extreme weather conditions such as rain and snow, and to explore joint detection strategies using multimodal data (e.g., infrared and visible light fusion). These efforts will promote the development of fully automated and highly reliable maintenance systems for solar panel installations, contributing to the long-term sustainability of photovoltaic power generation.

Scroll to Top