Enhanced Solar Panel Defect Detection via Global and Local Feature Fusion

The increasing global energy demand and growing environmental concerns have significantly accelerated the adoption of renewable energy sources. Among these, photovoltaic (PV) power generation stands out as a pivotal technology. At the heart of any PV system are the solar panels, whose quality and integrity directly determine the system’s energy conversion efficiency, long-term reliability, and operational safety. Solar panels are frequently installed in harsh outdoor environments—deserts, mountains, rooftops—where they are persistently exposed to extreme weather conditions such as intense UV radiation, thermal cycling, hail, and mechanical stress. These factors can induce various defects like cracks, micro-fractures, finger interruptions, soldering failures, and potential-induced degradation. Such defects not only cause a permanent drop in power output but can also lead to severe safety hazards like hot spots, arcing, or even fires. Therefore, developing efficient, accurate, and automated defect detection methods is of paramount importance for ensuring the economic viability and safe operation of PV plants throughout their lifespan.

Traditional inspection of solar panels relies heavily on manual methods, which are time-consuming, costly, subjective, and impractical for large-scale solar farms. Machine vision-based automated inspection has emerged as the dominant solution. Two primary imaging modalities are used: Infrared Thermography (IRT) and Electroluminescence (EL) imaging. IRT captures the heat signature of operating solar panels, revealing “hot spots” caused by defective cells acting as resistors. While useful for on-site inspection, IRT images often suffer from lower resolution and can be influenced by ambient conditions. In contrast, EL imaging is a more sensitive and precise technique. It requires applying a forward bias to the solar panels in a dark environment, causing them to emit light proportional to the local minority carrier diffusion length. Defective areas, where the electrical activity is compromised, appear as dark regions, shadows, or distinct patterns against a bright background. EL imaging provides high-resolution, high-contrast images that are exceptionally well-suited for detailed defect characterization and is widely used in laboratory and factory settings. Consequently, our research focuses on defect detection using EL imagery of solar panels.

In the realm of computer vision, deep learning, particularly Convolutional Neural Networks (CNNs), has revolutionized object detection. Single-stage detectors like the YOLO (You Only Look Once) series offer an excellent balance between speed and accuracy, making them popular for real-time applications. Their success has extended to the inspection of solar panels, where various improved versions of YOLOv5, YOLOv7, and YOLOv8 have been proposed. Common enhancements include integrating advanced attention mechanisms (e.g., CA, EMA), employing feature pyramid networks for multi-scale fusion, using deformable convolutions, and applying data augmentation strategies to address challenges like small defect size and imbalanced datasets. While these CNN-based approaches have achieved notable progress, they possess an inherent limitation: a restricted receptive field. Standard convolutions excel at extracting local features—edges, textures, and patterns—but struggle to model long-range dependencies and global contextual relationships within an image. For solar panels, this can mean missing subtle defects that are context-dependent or misclassifying defects when they appear in complex, cluttered backgrounds.

The Transformer architecture, initially dominant in Natural Language Processing (NLP), has made significant inroads into computer vision. Vision Transformers (ViTs) and their variants (e.g., Swin Transformer) process images as sequences of patches and utilize self-attention mechanisms to model global interactions across all patches simultaneously. This gives them a powerful capability to understand the global context of a scene. Detection frameworks like DETR (Detection Transformer) have demonstrated the potential of this paradigm. However, pure Transformer models often require large amounts of training data, can be computationally intensive, and may lack the innate inductive biases of CNNs that are beneficial for capturing low-level, local image features crucial for identifying fine cracks or tiny spots on solar panels.

This dichotomy presents a clear opportunity: CNNs are masters of local feature extraction, while Transformers are masters of global context modeling. A synergistic combination of these two paradigms promises a more robust and comprehensive feature representation for the demanding task of solar panels defect detection. This article presents a novel detection algorithm, the Global and Local Feature enhanced YOLOX (GLF-YOLOX), designed to harness the complementary strengths of both architectures. The core contributions are threefold:

  1. A dual-branch backbone network that seamlessly integrates a CNN pathway (CSPDarknet53) for local detail extraction and a Transformer pathway (Swin Transformer) for global context modeling.
  2. A novel Global and Local Enhanced Attention Mechanism (GLE-AM) that dynamically fuses features from both branches, enhancing the model’s focus on defective regions while strengthening detailed feature representation.
  3. A detection head augmented with Transformer Encoder Layers (TEL) to refine global feature modeling and optimize feature expression, significantly boosting classification accuracy for different defect types on solar panels.

Architecture of the GLF-YOLOX Model

The overall architecture of GLF-YOLOX is built upon the efficient anchor-free YOLOX framework but is comprehensively enhanced across the backbone, neck, and head components. The network follows a multi-scale prediction paradigm, generating feature maps at three different scales to detect defects of varying sizes on solar panels.

Dual-Branch Backbone Network

The backbone is responsible for extracting rich, hierarchical features from the input EL image of the solar panels. Instead of relying on a single architecture, we propose a parallel dual-branch design.

CNN Branch (Local Feature Specialist): This branch is based on CSPDarknet53, a CNN variant known for its efficiency and effectiveness. It processes the image through a series of convolutional layers with increasing depth and stride. Its strength lies in its hierarchical convolutional filters that excel at capturing local spatial patterns—the fine edges of a crack, the texture of a cell, or the sharp boundary of a black core. As the network deepens, the feature maps’ spatial resolution decreases (from H/4 to H/32), while their semantic depth and channel count increase. This branch provides a strong foundation of localized, detail-oriented features critical for pinpointing small defects on solar panels.

Transformer Branch (Global Context Specialist): This branch is implemented using a Swin Transformer. The input image is first split into non-overlapping patches (e.g., 4×4), which are treated as visual tokens. A linear embedding layer projects these tokens into a feature space. The core of this branch is the Swin Transformer Block, which employs Window-based Multi-head Self-Attention (W-MSA) and Shifted Window-based MSA (SW-MSA). The W-MSA computes self-attention within local windows, making the computation efficient. The SW-MSA shifts these windows in the next layer, enabling cross-window communication and thus building a hierarchical representation with a global receptive field. This mechanism allows the branch to understand relationships between distant parts of the solar panels image—for instance, correlating a suspicious shadow in one cell with the overall pattern of cell interconnection.

The two branches operate in parallel. At corresponding stages (i.e., producing feature maps of the same spatial resolution), their outputs are concatenated. This simple yet powerful operation creates a unified feature map that carries both fine-grained local details from the CNN and rich long-range contextual information from the Transformer. This fused feature set is far more expressive for the complex task of diagnosing solar panels than features from either branch alone.

Global and Local Enhanced Attention Mechanism (GLE-AM)

Mere concatenation of features is a naive fusion strategy. To intelligently recalibrate and enhance the fused features, we introduce the GLE-AM module. It is inserted after the fusion points in the network’s neck. The goal of GLE-AM is to dynamically highlight the most salient regions for defect detection on solar panels by explicitly modeling and reconciling differences between global and local feature characteristics.

Let the input fused feature map be denoted as \( X \in \mathbb{R}^{C \times H \times W} \). The GLE-AM operates through three coordinated sub-modules:

  1. Global Feature Enhancement Module (GFEM): This module aims to capture the deviation of each spatial location from the global average context. First, a global average pooling (GAP) is applied to \(X\) to obtain a channel-wise global descriptor \(X_{1} \in \mathbb{R}^{C}\):
    $$ X_{1} = \text{GAP}(X) = \frac{1}{H \times W} \sum_{i=1}^{H} \sum_{j=1}^{W} X_{:, i, j} $$
    This vector represents the “average” feature across the entire image of the solar panels. We then compute the absolute difference between the original feature map and this broadcasted global average. This difference map, \(X_{\text{abs}}\), highlights areas where local features significantly deviate from the global norm—potential locations of anomalies or defects.
    $$ X_{\text{abs}} = | X – X_{1} | $$
  2. Local Feature Enhancement Module (LFEM): This module focuses on capturing salient local contrasts. It applies both max pooling and average pooling operations spatially to generate two distinct feature maps, \(X_{m}\) and \(X_{a}\), which emphasize the most active and the average local features, respectively. Their difference pinpoints regions of high local variation or edge information, which are often associated with defect boundaries on solar panels.
    $$ X_{2} = X_{m} – X_{a} $$
  3. Squeeze-and-Excitation (SE) Block: This is a standard channel attention mechanism. It squeezes global spatial information into a channel descriptor via both average and max pooling, then learns to excite (re-weight) the channels based on their importance for the task of detecting defects in solar panels.
    $$ \text{SE}(X) = \sigma( C_{2}(C_{1}(X_{\text{avg1d}})) + C_{2}(C_{1}(X_{\text{max1d}})) ) $$
    where \(C_{1}\) and \(C_{2}\) are 1D convolutions, and \(\sigma\) is the sigmoid function.

The final attention weight map \(\theta\) is computed by a synergistic combination of these three elements. The SE weights provide a channel-wise importance scaling. The GFEM’s absolute difference (\(X_{\text{abs}}\)) modulates these weights spatially based on global deviation, and the LFEM’s difference (\(X_{2}\), passed through a sigmoid) further refines them based on local contrast. The enhanced output feature map \(X_{\text{out}}\) is then obtained via a residual connection:
$$ \theta = \sigma(\text{SE}(X)) \otimes (X_{\text{abs}} \odot \sigma(X_{2})) $$
$$ X_{\text{out}} = X + \theta $$
where \(\otimes\) denotes broadcast element-wise multiplication and \(\odot\) denotes element-wise multiplication. This process ensures that features corresponding to potential defect sites on the solar panels are amplified, while irrelevant background features are suppressed.

Detection Head with Transformer Encoder Layers

YOLOX uses a decoupled head, separating the tasks of classification (identifying the defect type) and regression (locating the defect bounding box). We enhance the classification branch by integrating a lightweight Transformer Encoder Layer (TEL). Defects on solar panels, such as different types of cracks or black cores, can have visually similar features, making precise classification challenging. The TEL module brings global contextual reasoning directly into the decision process for each potential defect region.

For each scale’s feature map, the classification branch consists of a standard convolutional layer working in parallel with the TEL path. The TEL first reshapes and embeds the feature region, adding positional encodings to retain spatial information. It then processes this sequence through a Multi-Head Self-Attention (MHSA) layer and a Feed-Forward Network (FFN). The MHSA allows the model to relate the features of the current region to all other features in the context window, helping to disambiguate confusing patterns based on their broader context within the solar panels image. The refined feature sequence is then reshaped back and contributes to the final classification logits. This design significantly boosts the model’s ability to correctly categorize subtle defect types.

Experimental Setup and Analysis

To validate the effectiveness of GLF-YOLOX, we conducted extensive experiments on a dataset of solar panels EL images.

Dataset and Implementation Details

The dataset comprises 3,700 high-quality EL images, annotated with five common defect types prevalent in solar panels:

  • Crack: Linear or nonlinear fractures in the silicon wafer.
  • Black Core: A central dark region often indicating severe cell damage.
  • Thick Line: Busbars or fingers appearing abnormally wide, suggesting metallization issues.
  • Finger Interruption: Breaks in the thin conductive grid lines on the cell.
  • Star Crack: Radial cracks emanating from a central point.

The dataset was split into 2,960 images for training and 740 for validation. The model was trained using SGD optimizer with an initial learning rate of 0.001, a weight decay of 0.0005, and a total of 200 epochs. The primary evaluation metric was the mean Average Precision (mAP@0.5), which averages the precision across all recall levels for all defect classes. We also report Precision (Pr), Recall (Rc), model parameters, FLOPs, and inference time.

Table 1: Dataset Composition for Solar Panels Defect Detection
Defect Class Description Training Samples Validation Samples
Crack Linear fractures in silicon wafer ~600 ~150
Black Core Central dark region indicating severe damage ~600 ~150
Thick Line Abnormally wide busbars or fingers ~580 ~145
Finger Interruption Breaks in conductive grid lines ~590 ~147
Star Crack Radial cracks from a central point ~590 ~148
Total 2,960 740

Ablation Studies

Ablation studies were conducted to dissect the contribution of each proposed component in GLF-YOLOX for inspecting solar panels. The baseline is the standard YOLOX with its CSPDarknet53 backbone.

Table 2: Ablation Study on GLF-YOLOX Components
Backbone Attention Head (TEL) mAP (%) Params (M) FLOPs (G)
CNN (CSPDarknet53) 87.30 4.82 6.79
Transformer (Swin) 86.44 10.12 12.53
Dual-Branch 88.72 15.43 19.75
Dual-Branch SE 89.43 16.09 22.32
Dual-Branch CBAM 90.28 16.67 23.74
Dual-Branch GLE-AM 91.80 17.36 24.53
Dual-Branch GLE-AM Yes 93.10 21.93 29.37

Analysis:

  1. Dual-Branch Efficacy: Using only the CNN or Transformer branch alone yields lower mAP (87.30%, 86.44%). Their combination in a dual-branch architecture immediately boosts performance to 88.72%, demonstrating the complementary nature of local and global feature extraction for analyzing solar panels.
  2. Attention Mechanism Comparison: Introducing attention mechanisms further improves results. Our proposed GLE-AM (91.80%) outperforms both the standard SE (89.43%) and CBAM (90.28%) mechanisms. This validates GLE-AM’s superior ability to dynamically fuse and enhance global-local feature differences specific to defect regions on solar panels.
  3. Detection Head Enhancement: Finally, incorporating the Transformer Encoder Layer (TEL) into the detection head pushes the mAP to a peak of 93.10%. This confirms that refining feature representation with global context at the final classification stage is highly beneficial for accurately distinguishing between subtle defect types on solar panels.

We also evaluated different combinations of CNN and Transformer architectures within the dual-branch backbone to find the optimal pairing for solar panels inspection.

Table 3: Dual-Branch Backbone Component Comparison
CNN Branch Transformer Branch mAP (%)
DarkNet53 PVT 88.65
DarkNet53 Swin 90.27
ResNet50 Swin 90.93
DenseNet121 Swin 91.14
CSPDarknet53 Swin 93.10

The combination of CSPDarknet53 and Swin Transformer proved to be the most effective, achieving the highest mAP. This is attributed to CSPDarknet53’s efficient gradient flow and feature reuse combined with Swin Transformer’s hierarchical and shifted-window global modeling, making it particularly adept at handling the multi-scale defect structures found in solar panels.

Comparison with State-of-the-Art Methods

We compared GLF-YOLOX against a wide range of mainstream object detectors and recent specialized models for solar panels defect detection.

Table 4: Performance Comparison with State-of-the-Art Methods
Method mAP (%) Precision (%) Recall (%) Inference Time (ms) Params (M)
Faster R-CNN 69.63 67.91 68.88 148.94 28.36
YOLOv3 64.49 62.82 63.92 19.48 61.57
YOLOv4 73.65 71.92 72.83 17.66 63.98
YOLOv5 78.18 76.77 77.59 16.87 7.09
YOLOX 87.57 85.92 86.47 14.69 10.59
Gbh-YOLOv5 90.03 87.94 88.79 18.95 17.92
RAFBSD 90.86 89.57 89.02 18.21 23.75
YOLOv8-MNS 91.28 88.75 89.21 16.53 14.50
GLF-YOLOX (Ours) 93.10 92.43 91.57 19.01 21.93

Analysis: GLF-YOLOX achieves the highest mAP, precision, and recall among all compared methods. It outperforms the strong baseline YOLOX by approximately 5.5% in mAP and surpasses recent specialized models for solar panels inspection by 1-2%. This significant margin underscores the effectiveness of our holistic approach to feature fusion and enhancement. While the inference time (19.01 ms) is slightly higher than some ultra-fast models like YOLOv5, it remains well within the requirements for real-time or high-throughput inspection of solar panels in an industrial setting. The trade-off in parameters and computation is justified by the substantial gain in detection accuracy and robustness, which is critical for reliable quality control of solar panels.

Conclusion

In this article, we have presented GLF-YOLOX, a novel and robust algorithm for automatic defect detection in solar panels using Electroluminescence imagery. The core insight driving this work is the complementary strength of Convolutional Neural Networks in local feature extraction and Vision Transformers in global context modeling. By architecting a dual-branch backbone network, we ensure the model captures both the fine-grained details of micro-cracks and the overarching structural context of the panel. The proposed Global and Local Enhanced Attention Mechanism (GLE-AM) acts as an intelligent fusion module, dynamically highlighting salient defect regions by reconciling global and local feature characteristics. Furthermore, augmenting the detection head with Transformer Encoder Layers refines the final feature representation, leading to more accurate defect classification.

Comprehensive experiments on a dedicated dataset of solar panels EL images demonstrate the superiority of GLF-YOLOX. It achieves a state-of-the-art mAP of 93.10%, outperforming a wide array of mainstream and specialized detectors. The ablation studies confirm the individual and cumulative contributions of each proposed component. This work provides a powerful and effective framework for the quality inspection of solar panels, which can contribute to improving the reliability, efficiency, and safety of photovoltaic power generation systems. Future work may explore further model lightweighting for edge deployment, integration with multi-modal data (e.g., combining EL and IRT), and extension to a wider variety of defect types and degradation modes observed in field-aged solar panels.

Scroll to Top