In the pursuit of addressing global ecological challenges and mitigating the catastrophic consequences of global warming, renewable energy sources have garnered significant attention. Among these, solar energy is particularly promising due to its ubiquity and long annual irradiation hours, making photovoltaic (PV) power generation a focal point of renewable energy research. The core component of any solar power system is the solar panel, which converts sunlight into electricity. However, the manufacturing process of solar panels is a complex, multi-factor-coupled procedure where any anomaly can lead to product defects. Timely identification of these defects is crucial for maintaining high production quality and efficiency. Traditional manual inspection methods rely on visual assessment, which is prone to missed detections, especially for subtle imperfections, and suffers from high labor costs and fatigue-induced inefficiency. Consequently, deep learning-based approaches have been increasingly adopted for defect detection tasks, offering superior generalization, robustness, and precision without requiring handcrafted feature engineering.
Existing methods for solar panel defect detection often achieve high accuracy but at the cost of large model parameters, making them unsuitable for deployment on resource-constrained mobile or edge devices. To strike a better balance between accuracy and computational efficiency, we propose a lightweight network named LPV-YOLO, built upon the YOLOv5s architecture. Our approach focuses on reducing model complexity while maintaining competitive detection performance for five common solar panel defects: cracks, scratches, hot spots, black edges, and power loss.
This paper presents three key innovations. First, we introduce GhostMCov and C3MGhost modules, which replace traditional convolution and C3 blocks in the backbone network. These modules leverage the Ghost bottleneck concept combined with the Mish activation function to drastically reduce parameter count and computational cost while preserving feature extraction capability. Second, to compensate for potential accuracy loss due to lightweighting, we design a novel Multi-scale Spatial Pyramid Pooling with SimAM attention (MSSPPF) module. This module integrates a parameter-free attention mechanism into the spatial pyramid pooling layer, enhancing multi-scale feature fusion without increasing parameters or FLOPs. Third, we embed Squeeze-and-Excitation (SE) channel attention modules into the neck network to strengthen the model’s focus on informative channel features, thereby improving defect detection accuracy.
Experimental results on a PV-Multi-Defect dataset demonstrate that LPV-YOLO achieves a mean average precision (mAP) of 93.8% at a frame rate of 70.42 FPS, while reducing parameters by 49%, model size by 46%, and computational cost by 50% compared to the original YOLOv5s. These improvements make LPV-YOLO highly suitable for real-time solar panel defect detection on mobile devices with limited resources.
1. Related Work
Considerable research has been conducted on solar panel defect detection using deep learning. Fan et al. (2022) employed a ResNet-based feature fusion model with self-attention to aggregate shallow and deep features for micro-crack detection, achieving high accuracy via transfer learning. Huang et al. (2023) introduced a novel LC attention mechanism with Leaky ReLU to improve small-target defect detection in solar panels, increasing precision by 2.5%. Jiang et al. (2023) utilized transfer learning with EL images and fine-tuning to achieve accurate solar cell defect detection. However, these methods often involve high model complexity and large parameter counts, limiting real-time applicability.
To reduce model complexity, lightweight networks have been explored. El-rashidy (2022) proposed a cost-efficient network using MobileNetV2 and linear discriminant analysis for solar cell defect clustering. Chen et al. (2023) integrated deformable convolution into YOLOv5 to expand receptive fields for small defects, improving mAP by 3%. In contrast, our approach directly redesigns the backbone with Ghost modules and incorporates parameter-free attention, achieving significant compression while maintaining accuracy.
2. Methodology
2.1 Overall Architecture of LPV-YOLO
The proposed LPV-YOLO network retains the four-stage structure of YOLOv5s: input, backbone, neck, and detection head. The backbone is reconstructed using lightweight Ghost modules, the neck incorporates SE attention, and the SPP layer is enhanced with SimAM attention to form the MSSPPF module. The network architecture is illustrated conceptually (without referencing specific figure numbers).
2.2 Lightweight Ghost Modules with Mish Activation
To reduce model parameters while maintaining training stability, we first replace the standard Conv module with a CBM module that uses the Mish activation function instead of SiLU or ReLU. Mish, defined as \( f_{\text{Mish}}(x) = x \cdot \tanh(\ln(1+e^x)) \), is smoother and helps prevent overfitting, improving generalization and convergence speed.
Next, we integrate the CBM module with the Ghost module to create GhostMCov and C3MGhost blocks. The Ghost module, as introduced in GhostNet, decomposes traditional convolution into two steps: (1) a standard convolution generating a small number of intrinsic feature maps, and (2) a series of cheap linear operations (e.g., depthwise convolutions) producing ghost feature maps. These are concatenated to form the final output, significantly reducing computational cost.
Let the input feature map have dimensions \( c \times h \times w \). The kernel size of the standard convolution is \( k \), and the number of output channels is \( n \). We generate \( \frac{n}{s} \) intrinsic maps via standard convolution, then apply \( s-1 \) linear transformations (each with kernel size \( d \)) to produce ghost maps. The computational cost comparison is:
\[
\text{Cost}_{\text{standard}} = n \cdot h’ \cdot w’ \cdot c \cdot k \cdot k
\]
\[
\text{Cost}_{\text{Ghost}} = \frac{n}{s} \cdot h’ \cdot w’ \cdot c \cdot k \cdot k + (s-1) \cdot \frac{n}{s} \cdot h’ \cdot w’ \cdot d \cdot d
\]
\[
\text{Compression ratio } r_s = \frac{\text{Cost}_{\text{standard}}}{\text{Cost}_{\text{Ghost}}} \approx s
\]
Since \( c \) is typically large and \( s \ll c \), the computation is reduced by approximately a factor of \( s \). In our implementation, we replace all Conv (except the first layer) and C3 modules in the backbone with GhostMCov and C3MGhost, leading to a 49% reduction in parameters.
2.3 Multi-scale Spatial Pyramid Pooling with SimAM Attention (MSSPPF)
The original YOLOv5s applies SPP at the end of the backbone, concatenating features from three parallel max-pooling layers with different kernel sizes (5, 9, 13) to capture multi-scale context. However, max-pooling can discard fine details. To address this, we propose MSSPPF, which modifies the SPP structure in three ways:
- Replace parallel pooling with sequential pooling (all with kernel size 5) to reduce repeated computation and improve speed.
- Introduce a Mish activation function after each convolution.
- Add a SimAM attention module before the final output. SimAM is a parameter-free attention mechanism that identifies important neurons by computing their energy function. For a target neuron \( t \) in a channel, the energy \( e_t \) is defined as:
\[
e_t = \frac{4(\hat{\sigma}^2 + \lambda)}{(t – \hat{\mu})^2 + 2\hat{\sigma}^2 + 2\lambda}
\]
where \( \hat{\mu} \) and \( \hat{\sigma}^2 \) are the mean and variance of all neurons in that channel, and \( \lambda \) is a regularization coefficient. Lower energy implies greater distinctiveness. The output feature map \( \tilde{X} \) is obtained by applying a sigmoid function to the inverse energy:
\[
\tilde{X} = \sigma\left(\frac{1}{E}\right) \odot X
\]
where \( E \) is the matrix of all \( e_t \) across spatial and channel dimensions. This module enhances feature representation without adding parameters or FLOPs, compensating for accuracy loss from the lightweight backbone.
2.4 Channel Attention SE in Neck
To further improve detection accuracy, we embed Squeeze-and-Excitation (SE) blocks after each C3MGhost module in the neck network. SE attention adaptively recalibrates channel-wise feature responses by first squeezing global spatial information into a channel descriptor via global average pooling, then exciting it through two fully connected layers to generate weights. These weights are applied to the original feature maps, emphasizing informative channels and suppressing less useful ones. This mechanism enhances the model’s ability to detect subtle defects like scratches and hot spots.
3. Dataset and Preprocessing
3.1 Dataset Description
We use the PV-Multi-Defect dataset, which originally contains 1,107 images of size 600×600 pixels, annotated with five defect types: cracks, scratches, hot spots, black edges, and power loss. Examples of each defect are summarized in the table below.
| Defect Type | Sample Image Description |
|---|---|
| Crack | Irregular dark shapes, sometimes accompanied by scratches |
| Scratch | Very thin lines close to background color, subtle |
| Hot Spot | Bright white blocks, often clustered |
| Black Edge | Narrow dark strips along edges of individual cells |
| Power Loss | Relatively regular rectangular regions, large area |
3.2 Re-annotation and Data Augmentation
Upon inspecting the dataset, we identified missing labels and imprecise bounding boxes. We re-annotated all images using the LabelImg tool, increasing the number of annotated instances from 4,235 to 4,631. To address class imbalance, we employed Cycle-GAN for data augmentation. Cycle-GAN performs unpaired image-to-image translation using two generators and two discriminators, with cycle-consistency loss to preserve content while changing style. The loss function is:
\[
L = L_{\text{GAN}} + L_{\text{cycle}}
\]
\[
L_{\text{GAN}} = \mathbb{E}_{y \sim p_{\text{data}}(y)} [\log D_Y(y)] + \mathbb{E}_{x \sim p_{\text{data}}(x)} [\log(1 – D_Y(G(x)))] + \text{(similar for F and }D_X\text{)}
\]
\[
L_{\text{cycle}} = \mathbb{E}_{x \sim p_{\text{data}}(x)} [\|F(G(x)) – x\|_1] + \mathbb{E}_{y \sim p_{\text{data}}(y)} [\|G(F(y)) – y\|_1]
\]
This augmentation expanded the dataset to 4,463 images with 14,444 defect instances. The expanded dataset was split into training (80%) and validation (20%) sets.
4. Experiments and Analysis
4.1 Experimental Setup
All experiments were conducted on a Windows 10 system with an NVIDIA GeForce RTX 2080Ti GPU, Python 3.8, and CUDA 11.1. Input images were resized to 640×640. Training parameters are listed below.
| Parameter | Value |
|---|---|
| Optimizer | SGD |
| Epochs | 300 |
| Batch Size | 16 |
| Momentum | 0.937 |
| Initial Learning Rate | 0.001 |
| Weight Decay | 0.0005 |
| IoU Threshold | 0.6 |
4.2 Evaluation Metrics
We use mean Average Precision (mAP), number of parameters, model size, FLOPs, and frame rate (FPS) as metrics. Precision (P) and Recall (R) are defined as:
\[
P = \frac{TP}{TP + FP}, \quad R = \frac{TP}{TP + FN}
\]
\[
AP = \int_0^1 P(R) dR, \quad mAP = \frac{1}{n} \sum_{i=1}^n AP_i
\]
where TP, FP, and FN denote true positives, false positives, and false negatives, respectively.
4.3 Training and Convergence
The training loss curves (box loss, objectness loss, classification loss) all converge smoothly after 300 epochs, with box loss around 0.03, objectness loss below 0.015, and classification loss near zero, indicating stable learning.
4.4 Ablation Study
We conduct ablation experiments to evaluate each component’s contribution. The baseline is YOLOv5s. We progressively add: (A) Ghost modules (MGhost), (B) MSSPPF, and (C) SE attention, forming LPV-YOLO. Results are summarized in the table below.
| Model | mAP (%) | Params (×10⁶) | Size (MB) | FLOPs (G) | FPS |
|---|---|---|---|---|---|
| Baseline (YOLOv5s) | 94.4 | 7.23 | 13.7 | 16.5 | 91.74 |
| + MGhost | 92.1 | 3.70 | 7.42 | 8.2 | 67.11 |
| + MGhost + MSSPPF | 93.3 | 3.70 | 7.36 | 8.2 | 65.52 |
| LPV-YOLO | 93.8 | 3.71 | 7.40 | 8.3 | 70.42 |
Results show that:
– MGhost reduces parameters, size, and FLOPs by ~49%, 46%, and 50% respectively, with a 2.3% drop in mAP.
– Adding MSSPPF recovers 1.2% mAP without increasing parameters or FLOPs.
– Adding SE further improves mAP by 0.5%, achieving 93.8% while keeping the model lightweight.
– The final LPV-YOLO achieves a 70.42 FPS, satisfying real-time requirements.
4.5 Comparison with State-of-the-Art
We compare LPV-YOLO with YOLOv5s, YOLOv7, SSD300, and RetinaNet on the same dataset.
| Model | mAP (%) | Params (×10⁶) | Size (MB) | FLOPs (G) | FPS |
|---|---|---|---|---|---|
| YOLOv5s | 94.4 | 7.23 | 13.7 | 16.5 | 91.74 |
| YOLOv7 | 88.0 | 9.33 | 19.0 | 26.7 | 107.53 |
| SSD300 | 77.7 | 34.30 | 90.0 | 51.6 | 71.00 |
| RetinaNet | 72.2 | 41.90 | 139.0 | 212.0 | 42.90 |
| LPV-YOLO (Ours) | 93.8 | 3.71 | 7.4 | 8.3 | 70.42 |
LPV-YOLO achieves the highest mAP among all lightweight models, with the smallest parameter count and model size. Compared to YOLOv5s, it sacrifices only 0.6% mAP while being 51% smaller. Its FPS of 70.42 is sufficient for real-time inspection on edge devices.
4.6 Per-class Performance
Detailed performance for each defect type is shown below.
| Defect Type | Precision (%) | Recall (%) | mAP@0.5 (%) | mAP@0.5:0.95 (%) |
|---|---|---|---|---|
| Crack | 88.7 | 89.7 | 93.2 | 65.7 |
| Hot Spot | 87.6 | 87.8 | 92.5 | 60.3 |
| Black Edge | 91.1 | 85.5 | 97.1 | 62.7 |
| Scratch | 80.1 | 85.7 | 87.0 | 46.4 |
| Power Loss | 96.0 | 96.9 | 99.1 | 90.5 |
| All | 88.7 | 91.1 | 93.8 | 65.1 |
Power loss and black edges achieve the highest detection rates, while scratches and hot spots are more challenging but still reach 87.0% and 92.5% mAP respectively. These results demonstrate the robustness of LPV-YOLO across diverse defect types in solar panels.
5. Conclusion
We propose LPV-YOLO, a lightweight and efficient network for detecting five common defects on solar panels: cracks, scratches, hot spots, black edges, and power loss. By replacing standard convolution with GhostMCov and C3MGhost modules, introducing a parameter-free MSSPPF attention module, and embedding SE channel attention in the neck, our model reduces parameters by 49%, model size by 46%, and FLOPs by 50% while maintaining a high mAP of 93.8% at 70.42 FPS. Compared to state-of-the-art detectors like YOLOv7, SSD300, and RetinaNet, LPV-YOLO achieves superior accuracy with the smallest model footprint. This makes it an ideal solution for real-time solar panel defect inspection on resource-constrained edge devices, contributing to improved quality control in photovoltaic manufacturing.

