Improved YOLOv11n-Based Defect Detection Algorithm for Solar Panels

In our work, we propose an enhanced YOLOv11n framework for detecting defects in solar panels. The original YOLOv11n exhibits deficiencies in small-target detection and insufficient contextual feature fusion when applied to photovoltaic defect scenarios. To address these issues, we introduce three key modules: the SPPF‑LDESKA module in the backbone, the ESCM module in the neck, and the LSCD detection head. Extensive experiments on a publicly available solar panel dataset demonstrate that our method improves mean Average Precision (mAP@50) by 2.3% while reducing computational cost by 6.25% compared with the baseline YOLOv11n. The proposed algorithm maintains real-time inference speed and is well suited for practical solar panel defect inspection tasks.

Solar panels are critical components in photovoltaic power generation systems. Their performance and quality directly influence power generation efficiency and safety. Common defects such as cracks, grid fractures, and stains can significantly degrade panel performance: for example, a 0.5 mm wide and 0.1 mm deep scratch may cause a local efficiency drop of 5%–8%, an average annual power degradation rate of 2.8%, and shorten the service life by 3–5 years. Grid fractures obstruct current transmission and can lead to hot‑spot effects, which may even cause fires. Moreover, every 1 °C temperature rise reduces the output power by approximately 0.4%–0.5%, and surface contamination under high‑temperature and high‑humidity conditions can induce PID (Potential Induced Degradation) effects, accelerating power attenuation. Therefore, accurate and efficient detection of defects in solar panels is of paramount importance.

Deep learning based object detection has become the mainstream approach for automated inspection. One‑stage detectors such as the YOLO series predict bounding boxes and class labels directly, offering a good balance between speed and accuracy. Among them, YOLOv11n is the latest lightweight version released by Ultralytics in September 2024. Its backbone uses C3k2 modules, C2PSA modules (integrating position‑sensitive attention), and the SPPF (Spatial Pyramid Pooling Fast) module. The neck adopts a PAN (Path Aggregation Network) structure combined with C3k2 modules for multi‑scale feature fusion. The detection head follows the YOLOv8 design but employs depthwise separable convolutions in the classification branch to improve efficiency. However, in the context of solar panel defect detection, the tiny sizes of cracks and grid fractures, together with the low contrast of stains, lead to missed detections and insufficient precision. To overcome these limitations, we propose the following improvements.

Methodology

2.1 SPPF-LDESKA Module

The original SPPF module applies max‑pooling with different kernel sizes to capture multi‑scale features. However, for small defects like thin cracks, the pooling operation may cause loss of fine details. We introduce the Large Separable Kernel Attention (LSKA) mechanism, which expands the receptive field through separable convolutions and dilated convolutions while keeping computational cost low. Furthermore, we enhance the LSKA by integrating a lightweight detail‑enhanced convolution (LDEConv) that combines model lightweighting and detail feature reinforcement.

The LSKA mechanism processes the input feature map \(F_C \in \mathbb{R}^{C \times H \times W}\) through two stages. First, depthwise separable convolutions extract local features along the horizontal and vertical directions:

$$
Q_C = \text{DWConv}_{(2d-1) \times (2d-1)}(F_C)
$$

where \(d\) is the dilation rate. Then, a depthwise dilated convolution with kernel size \(k \times k\) (with dilation rate \(d\)) captures global context:

$$
T_C = \text{DW-D-Conv}_{k \times k}(Q_C)
$$

After that, a \(1 \times 1\) convolution generates the attention map:

$$
A_C = \text{Conv}_{1 \times 1}(T_C)
$$

The final output of LSKA is:

$$
E_C = A_C \odot F_C
$$

where \(\odot\) denotes the Hadamard product. The attention mechanism adaptively weights different spatial regions, emphasizing important defect areas.

To preserve fine details, we embed the LDEConv concept into the LSKA. The LDEConv uses a differential detail enhancement stream that computes the pixel‑wise difference between the feature and its average pooling result:

$$
D(x) = x – \text{avgpool}(x)
$$

This differential feature is then concatenated with the original feature and passed through a depthwise separable convolution and a pointwise convolution, followed by the LSKA attention. The resulting SPPF‑LDESKA module (as shown in the structure diagram) replaces the original SPPF in the backbone. It combines the multi‑scale representation capability of SPPF with the enhanced detail sensitivity and global context awareness provided by LSKA and LDEConv, thereby improving the detection of small defects in solar panels.

Table 1: Comparison of backbone module variants on the solar panel dataset.
Models P (%) R (%) Parameters GFLOPs mAP@50 (%)
YOLOv11n (baseline) 85.0 83.8 2,590,425 6.4 87.5
Variant I (depthwise + 1×1) 81.6 75.8 2,343,537 5.7 80.1
Variant II (LDEConv only with DW) 85.2 83.0 3,411,809 8.6 87.2
Variant III (LDEConv only with PW) 86.4 81.4 3,161,045 6.3 86.0
SPPF-LSKA (without LDEConv) 86.5 83.5 2,855,633 6.5 88.0
SPPF-LDESKA (ours) 86.8 83.2 2,485,854 6.3 88.5

As shown in Table 1, the proposed SPPF‑LDESKA module achieves the highest precision (86.8%) and mAP@50 (88.5%) among all backbone variants, while maintaining low parameter count (2.49M) and FLOPs (6.3 GFLOPs). This demonstrates the effectiveness of combining LDEConv with LSKA in the SPPF structure for solar panel defect detection.

2.2 ESCM Module in the Neck

The feature pyramid network (FPN) in YOLOv11n fuses multi‑scale features via upsampling and concatenation. However, traditional convolution layers have fixed receptive fields and are insufficient for capturing long‑range dependencies. The Context‑Guided Feature Modulation (CGFM) module was originally proposed to address this issue. We redesign it into an Efficient Shared Convolutional Module (ESCM) by incorporating the ECA (Efficient Channel Attention) mechanism and shared‑weight convolutions.

In the original CGFM, the input feature map is first processed by a 3×3 convolution to reduce spatial size and expand channels:

$$
T’ = \text{Conv}_{3\times3}(T), \quad T \in \mathbb{R}^{C \times H \times W},\; T’ \in \mathbb{R}^{2C \times \frac{H}{2} \times \frac{W}{2}}
$$

Then, two parallel branches are used: one with a 3×3 convolution for local details, and another with a 3×3 dilated convolution (rate=2) for global context. The outputs are concatenated, passed through BN + PReLU, and then global average pooling and two fully connected layers generate channel‑wise attention weights. Finally, the weighted features are added to the original.

In our ESCM, we replace the fully connected layers with the ECA module, which performs 1D convolution along the channel dimension to enable efficient local cross‑channel interaction without dimensionality reduction. The ECA module’s operation can be expressed as:

$$
\omega = \sigma(\text{Conv1D}_k(\text{GAP}(X)))
$$

where \(k\) is the kernel size of the 1D convolution, \(\sigma\) is the sigmoid function, and \(\omega\) is the channel attention vector. Moreover, we introduce shared‑weight convolutions (shared conv) for the two branches: both the local and global branches use the same convolutional kernel weights, which reduces redundant parameters and avoids repeated learning of similar features. The resulting ESCM structure is shown in the network diagram. The ESCM effectively enhances context‑aware adaptive adjustment during multi‑scale feature fusion while keeping the model lightweight.

Table 2: Comparison of feature fusion module variants.
Models P (%) R (%) Parameters GFLOPs mAP@50 (%)
YOLOv11n (baseline) 85.0 83.8 2,590,425 6.4 87.5
Variant IV (ECA only) 87.3 80.2 2,322,802 6.5 87.3
Variant V (shared conv only) 83.5 84.0 2,668,881 6.8 87.5
CGFM (original) 87.0 81.8 2,238,897 6.3 88.8
ESCM (ours) 88.0 82.4 2,488,546 6.3 89.7

From Table 2, the ESCM module achieves the best mAP@50 (89.7%) with a competitive parameter count (2.49M) and the same FLOPs as the original CGFM. The substitution of ECA and shared convolution improves the precision and recall balance, demonstrating the suitability of ESCM for solar panel defect detection where both local and global contexts are crucial.

2.3 Lightweight Shared Convolutional Detection Head (LSCD)

The original YOLOv11n detection head uses four 3×3 convolutions and two 2D convolutions, which contribute significantly to the total model complexity. To reduce parameters while preserving detection accuracy, we design the Lightweight Shared Convolutional Detection Head (LSCD). The LSCD consists of multiple Conv_GN (convolution + group normalization) and Conv2d operations that are shared across different detection scales. The core idea is to use a single set of convolutional weights for feature extraction before the final classification/regression branches, thus reducing redundant computations. The structure of LSCD is illustrated in the network diagram.

Table 3: Comparison of detection head variants.
Models P (%) R (%) Parameters GFLOPs mAP@50 (%)
DyHead 86.9 84.5 2,587,588 6.0 86.5
Detect-Efficient 87.7 84.2 2,599,675 6.0 87.8
Detect-LADH 88.0 85.8 2,558,776 5.9 88.0
Detect-LSCD (ours) 88.6 85.3 2,420,622 5.9 88.5

As shown in Table 3, the LSCD head achieves the highest mAP@50 (88.5%) while having the smallest parameter count (2.42M) and FLOPs (5.9 GFLOPs) among the compared heads. This indicates that the shared convolution design effectively reduces redundancy without sacrificing detection performance on solar panel defects.

Experiments

3.1 Dataset and Settings

We evaluate our method on a public solar panel defect dataset containing 2,400 images with a resolution of 640×640 pixels. There are three defect categories: Crack, Grid fracture, and Stain. The dataset is split into 1,920 training images and 480 validation images (8:2 ratio). Training is performed on an NVIDIA GeForce RTX 4060 (8 GB) GPU with CUDA 12.4, PyTorch 1.7.1. The batch size is 8, the number of workers is 8, and the optimizer is SGD with an initial learning rate of 0.001. We train for 200 epochs with default YOLOv11n settings.

3.2 Evaluation Metrics

We adopt the following metrics: Precision (P), Recall (R), number of parameters (Parameters), computational cost (GFLOPs), and mean Average Precision at IoU threshold 0.5 (mAP@50). The definitions are:

$$
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 \(N\) is the number of classes.

3.3 Ablation Study

We conduct a comprehensive ablation study to verify the contribution of each proposed module. The results are presented in Table 4.

Table 4: Ablation study results on the solar panel dataset.
Baseline SPPF-LDESKA ESCM LSCD P (%) R (%) Parameters GFLOPs mAP@50 (%)
85.0 83.8 2,590,425 6.4 87.5
86.8 83.2 2,485,854 6.3 88.5
88.0 82.4 2,488,546 6.3 89.7
88.6 85.3 2,420,622 5.9 88.5
85.5 82.8 2,600,520 6.3 88.3
88.8 84.1 2,461,764 6.0 89.5

The full model (row 6) achieves the highest precision (88.8%) and mAP@50 (89.5%), with a parameter count of 2.46M and 6.0 GFLOPs. Compared with the baseline YOLOv11n, the precision improves by 4.5%, mAP@50 increases by 2.3%, while the FLOPs drop by 6.25%. Each module contributes positively to the final performance. When combining all three modules, the synergy is clearly demonstrated.

3.4 Comparison with State-of-the-Art Models

We compare our proposed method with several popular detectors on the same solar panel dataset. The results are summarized in Table 5.

Table 5: Performance comparison of different models on the solar panel dataset.
Models P (%) R (%) Parameters GFLOPs mAP@50 (%) FPS
Faster R-CNN 75.8 80.1 135,952,652 356.2 68.5 28
YOLOv5s 84.5 84.5 21,357,524 25.2 85.8 58
YOLOv7 84.6 85.8 37,889,766 145.2 85.6 93
YOLOv8n 85.5 83.3 3,006,233 8.1 87.4 94
YOLOv10n 85.6 82.0 2,708,210 8.4 87.5 98
YOLOv11n (baseline) 85.0 83.8 2,590,425 6.4 87.5 102
YOLOv12s 86.5 83.2 2,601,567 6.4 86.8 101
DT-DETR 86.6 83.5 2,750,664 6.5 87.4 107
Ours 88.8 84.1 2,461,764 6.0 89.5 118

Our model outperforms all compared methods in terms of mAP@50 (89.5%), precision (88.8%), and inference speed (118 FPS). It also achieves the smallest computational cost (6.0 GFLOPs) among the YOLO‑nano series, demonstrating that the proposed improvements are both effective and efficient for solar panel defect detection.

3.5 Generalization on PCB Defect Dataset

To verify the generality of our method, we also test the improved model on a PCB defect dataset from the Peking University Intelligent Robot Laboratory. The results are shown in Table 6.

Table 6: Performance on PCB defect dataset.
Models mAP@50 (%) Parameters FPS
Faster R-CNN 90.8 125,952,666 25
YOLOv5s 85.3 2,237,524 56
YOLOv7 88.1 37,789,756 99
YOLOv8n 91.1 3,185,233 92
YOLOv10n 92.8 2,691,209 97
YOLOv11n 93.5 2,590,425 101
YOLOv12s 94.8 2,601,567 103
DT-DETR 94.3 2,550,664 105
Ours 95.4 2,361,764 117

The proposed algorithm also achieves the highest mAP@50 (95.4%) on the PCB dataset, with a low parameter count and fast inference. This indicates that the improvements are not limited to solar panels but can be generalized to other industrial defect detection tasks.

3.6 Qualitative Analysis

Visual inspection of detection results confirms that our model (Ours) reduces missed detections compared with YOLOv10n and YOLOv11n. For example, thin cracks and small grid fractures that are often overlooked by the baseline are correctly identified by our method. The attention mechanism in SPPF‑LDESKA helps the model focus on defect regions, while the ESCM module better integrates multi‑scale context. The LSCD head further improves the bounding box regression accuracy.

Conclusion

In this work, we have presented an improved YOLOv11n algorithm for defect detection in solar panels. The proposed SPPF‑LDESKA module enhances the backbone’s ability to capture fine‑grained details and global context through the combination of LDEConv and LSKA attention. The ESCM module in the neck efficiently fuses multi‑scale features by integrating ECA channel attention and shared‑weight convolution, reducing redundant parameters while improving contextual adaptation. The lightweight shared convolutional detection head (LSCD) reduces computational overhead without sacrificing accuracy. Extensive experiments demonstrate that our method achieves a 2.3% improvement in mAP@50 (from 87.5% to 89.5%), a 4.5% increase in precision (from 85.0% to 88.8%), and a 6.25% reduction in FLOPs compared with the baseline YOLOv11n. Moreover, the model achieves 118 FPS inference speed, making it suitable for real‑time deployment in solar panel production lines and maintenance inspections. Future work may involve further optimizing the model for edge devices and expanding the defect categories to cover a wider range of photovoltaic cell anomalies.

Scroll to Top