As a researcher focused on the operational reliability of photovoltaic power stations, I have witnessed the rapid global expansion of solar energy infrastructure. Ensuring the long-term performance and safety of these installations is paramount. A critical component requiring constant vigilance is the solar panel itself. Subjected to harsh environmental conditions, individual cells or modules can develop defects such as hot spots (from cell failures or bypass diode faults) and areas of abnormal heating due to shading or physical damage. These defects not only reduce the power output of the affected solar panel but can also lead to safety hazards and accelerated degradation, impacting the entire array’s health.
Traditional manual inspection methods are impractical for the vast scale of modern utility-scale solar panel farms. The industry has thus shifted towards automated inspection using unmanned aerial vehicles (UAVs) equipped with thermal infrared cameras. Infrared thermography is ideal for this task, as faulty areas in a solar panel typically exhibit a temperature differential compared to healthy cells. However, analyzing the resulting aerial infrared imagery presents significant technical challenges. The defects often appear as very small targets within a large, complex image frame, with low contrast against varied backgrounds like rooftops, soil, or vegetation. This combination of small target size, cluttered background, and subtle thermal signatures makes accurate automated detection a difficult problem.

My work addresses this precise challenge. I propose a novel deep learning-based framework for the precise and efficient detection of defects in aerial infrared images of solar panel arrays. The core of my approach is an enhanced version of the YOLOv7 object detector, which I term YOLOv7-EPAN. This model is specifically engineered to improve the detection of small, subtle defects on solar panel surfaces by enhancing feature representation and localization accuracy.
Technical Challenges and Proposed Architecture
The standard YOLOv7 architecture, while fast and accurate for general object detection, has limitations when applied to our specific problem. Its convolutional layers in the Efficient Layer Aggregation Network (ELAN) may focus on local patterns and fail to capture the broader contextual information crucial for distinguishing a small hot spot from background thermal noise in a large solar panel image. Furthermore, the loss function used for bounding box regression can be overly sensitive to minor positional errors for tiny objects, hindering precise localization.
To overcome these issues, my YOLOv7-EPAN model incorporates three key innovations:
- CS-ELAN Module: Replaces the standard ELAN module with a design that integrates a Cross-Shaped Window Transformer (CSWinT) block alongside convolutional layers.
- Efficient Path Aggregation Network (EPAN): A redesigned neck network built entirely with CS-ELAN modules to strengthen multi-scale feature fusion.
- Optimized Loss Function: A hybrid loss that improves the regression accuracy for small bounding boxes.
1. The CS-ELAN Module: Capturing Global Context
The standard convolutional operations in YOLOv7 are excellent at extracting local features. However, for a small defect on a large, uniform solar panel, understanding the global context—what the “normal” panel area looks like—is vital to identify the “abnormal” hotspot. Vision Transformers have shown remarkable ability to model long-range dependencies. My CS-ELAN module fuses these strengths.
The CSWin Transformer employs a cross-shaped window self-attention mechanism. Instead of computing attention across the entire feature map (which is computationally heavy) or within small fixed squares, it partitions the features into horizontal and vertical stripes. Multi-head attention is split: one group computes attention within horizontal stripes, another within vertical stripes. This cross-shaped strategy efficiently captures global dependencies across the width and height of the feature map. The output is formulated as follows. For an input feature \(X\), the horizontal attention for the \(n\)-th head group is:
$$
\text{CSWin-Attention}(X) = \text{Concat}(h^1, …, h^K)W^O
$$
$$
h^k = \begin{cases}
\text{H-Attention}_n(X), & n=1,…,K/2 \\
\text{V-Attention}_n(X), & n=K/2+1,…,K
\end{cases}
$$
This mechanism allows the model to suppress irrelevant background information from the complex scene and focus on globally salient features—exactly what is needed to spot a small anomaly on a solar panel.
The structure of my proposed CS-ELAN module is detailed below. It takes an input feature and processes it through two parallel branches: one standard convolutional branch and one branch incorporating the CSWinT block for global context modeling. The features are then aggregated.
CS-ELAN Module Processing Steps:
- Input feature \(x_{in}\) is split and processed through two 1×1 convolutions: \(x_1, x_2\).
- \(x_1\) passes through a decomposed convolution block (Conv3) to produce \(x_3\).
- \(x_2\) is reshaped and fed into the CSWinT block to capture global relations, yielding \(x_4\).
- \(x_4\) goes through another Conv3 block, producing \(x_5\).
- All features \(x_1, x_2, x_3, x_4, x_5\) are concatenated and fused with a final convolution to produce the output \(x_{out}\).
This design ensures that both local detailed features (from convolutions) and global contextual features (from CSWinT) are preserved and combined to form a more powerful representation for defect detection in solar panel imagery.
2. EPAN: Enhanced Multi-Scale Feature Fusion
Object detectors typically use a Feature Pyramid Network (FPN) or Path Aggregation Network (PAN) to combine features from different depths of the backbone. Low-level features have high resolution and fine spatial details crucial for locating small defects on a solar panel, but lack semantic meaning. High-level features have strong semantic information but low resolution.
I construct an Efficient Path Aggregation Network (EPAN) using the CS-ELAN module as the fundamental building block. Replacing all feature fusion modules in the neck with CS-ELAN ensures that at every stage of multi-scale fusion, the model is enhancing features with both local and global context awareness. This significantly enriches the semantic information flowing through the pyramid, improving the model’s ability to express and detect the characteristics of small solar panel defects at various scales. The EPAN facilitates robust top-down and bottom-up information pathways, allowing fine-grained details from shallow layers to be semantically enriched by deep layers, and vice-versa.
3. Hybrid Loss Function for Precise Small-Object Localization
Accurate bounding box regression is critical. The standard CIOU loss considers overlap area, center point distance, and aspect ratio. However, for very small targets, even a few pixels of deviation represent a large relative error, making optimization sensitive and unstable.
I introduce a hybrid loss that combines the benefits of CIOU with the Normalized Wasserstein Distance (NWD) loss. NWD models a bounding box as a 2D Gaussian distribution and measures the similarity between boxes using the Wasserstein distance. It is particularly effective for small objects as it is less sensitive to minor spatial shifts. The NWD between two Gaussian distributions \(N_a\) and \(N_b\) (modeling boxes A and B) is:
$$
W_2^2(N_a, N_b) = \Vert ([cx_a, cy_a, \frac{w_a}{2}, \frac{h_a}{2}]^T, [cx_b, cy_b, \frac{w_b}{2}, \frac{h_b}{2}]^T) \Vert_2^2
$$
The NWD loss is then defined as:
$$
\text{Loss}_{NWD} = 1 – \text{NWD}(N_a, N_b) = 1 – \exp(-\frac{W_2^2(N_a, N_b)}{C})
$$
where \(C\) is a constant related to the dataset.
The final regression loss is a weighted combination:
$$
\text{Loss}_{re} = \lambda \cdot \text{Loss}_{CIOU} + (1 – \lambda) \cdot \text{Loss}_{NWD}
$$
By tuning the balance parameter \(\lambda\), the model learns to leverage the stability of NWD for small solar panel defect localization while retaining the comprehensive geometric fitting of CIOU.
Experimental Design and Dataset
To validate my approach, I conducted extensive experiments on a real-world aerial infrared dataset collected from operational photovoltaic power stations. The dataset consists of 3,013 infrared images (640×512 resolution) captured by UAVs, annotated with three critical defect types prevalent in solar panel maintenance: Cell Failure (localized hot spots), Diode Failure, and Occlusion (shading-induced heating). The dataset was split into 2,553 training and 460 testing images.
A statistical analysis of the annotated bounding boxes confirms the “small target” nature of the problem, which is central to inspecting large-scale solar panel arrays from an aerial perspective.
| Split | Images | Total Boxes | Cell Failure | Diode Failure | Occlusion |
|---|---|---|---|---|---|
| Training Set | 2,553 | 7,668 | 5,894 | 1,367 | 407 |
| Test Set | 460 | 1,566 | 1,382 | 119 | 65 |
| Target Size | Definition (Pixel Area) | Percentage in Dataset |
|---|---|---|
| Small | Area < 32² | ~85% |
| Medium | 32² ≤ Area < 96² | ~12% |
| Large | Area ≥ 96² | ~3% |
The experimental platform used an NVIDIA RTX 3090 Ti GPU. Models were trained for 400 epochs with standard data augmentation techniques like Mosaic and MixUp to improve generalization. The key evaluation metric was mean Average Precision (mAP), specifically mAP@0.5 (mAP50) and mAP@0.5:0.95 (mAP50:95), along with precision for small (AP_S) and medium (AP_M) objects as per COCO standards. Parameters and Frames Per Second (FPS) were also measured to assess model efficiency.
Ablation Study and Component Analysis
I performed a detailed ablation study to quantify the contribution of each proposed component. The baseline is the original YOLOv7 model. The results clearly demonstrate the effectiveness of each innovation in the context of solar panel defect detection.
| Experiment | Model Configuration | mAP50 (%) | mAP50:95 (%) | AP_S (%) | AP_M (%) | Params (M) | FPS |
|---|---|---|---|---|---|---|---|
| 1 | Baseline (YOLOv7) | 75.1 | 38.8 | 32.4 | 36.4 | 37.2 | 120 |
| 2 | + CS-ELAN (EPAN) | 80.3 | 40.9 | 35.5 | 36.5 | 35.3 | 83 |
| 3 | + EPAN & Loss (λ=0.1) | 80.9 | 40.6 | 35.8 | 36.2 | 35.3 | 83 |
| 4 | + EPAN & Loss (λ=0.3) | 80.6 | 40.3 | 35.6 | 35.2 | 35.3 | 83 |
| 5 | + EPAN & Loss (λ=0.5) [Ours] | 81.5 | 42.1 | 37.4 | 37.9 | 35.3 | 83 |
| 6 | + EPAN & Loss (λ=0.7) | 79.9 | 40.5 | 36.1 | 35.7 | 35.3 | 83 |
| 7 | + EPAN & Loss (λ=0.9) | 77.3 | 39.7 | 34.1 | 36.4 | 35.3 | 83 |
Analysis of Results:
- CS-ELAN/EPAN (Exp 2): Replacing the original neck with the EPAN structure brings a substantial gain of +5.2% mAP50 and +2.1% mAP50:95 over the baseline. Notably, small object precision (AP_S) improves by +3.1%. This confirms that the global context modeling in CS-ELAN is highly effective for identifying small defects in complex solar panel backgrounds. The parameter count even decreases slightly.
- Hybrid Loss (Exp 3-7): Integrating the NWD-based loss function provides further gains. The optimal balance is found at λ=0.5 (Exp 5), yielding the best overall performance: 81.5% mAP50 and 42.1% mAP50:95. Compared to using only EPAN (Exp 2), the hybrid loss adds +1.2% mAP50 and significantly boosts AP_S by +1.9% and AP_M by +1.4%. This validates that the hybrid loss specifically enhances localization accuracy for small and medium-sized solar panel defects.
- Efficiency: The final YOLOv7-EPAN model runs at 83 FPS, which, while lower than the original YOLOv7’s 120 FPS, remains highly suitable for real-time processing in UAV-based inspection systems. The 1.9M parameter reduction is also a positive outcome.
Comparison with State-of-the-Art Detectors
To firmly establish the superiority of my approach, I compared YOLOv7-EPAN against a wide range of modern object detectors on the solar panel defect test set. The results, shown below, highlight its leading performance.
| Model | mAP50 (%) | AP_S (%) | AP_M (%) | Params (M) | FPS |
|---|---|---|---|---|---|
| SSD | 35.1 | 19.6 | 25.6 | 23.75 | 16 |
| RetinaNet | 57.6 | 24.3 | 34.1 | 32.24 | 40 |
| YOLOv3 | 74.7 | 33.1 | 31.8 | 62.6 | 92 |
| YOLOv4 | 77.5 | 30.4 | 35.2 | 63.9 | 97 |
| YOLOv5s | 77.2 | 33.6 | 30.8 | 7.02 | 101 |
| YOLOv5l | 77.1 | 34.7 | 37.6 | 46.1 | 62 |
| YOLOX | 79.4 | – | – | 8.94 | 89 |
| TPH-YOLOv5 | 76.7 | 37.1 | 36.3 | 45.4 | 60 |
| YOLOv7 (Baseline) | 78.7 | 32.4 | 36.4 | 37.2 | 120 |
| YOLOv8 | 77.7 | 33.8 | 36.7 | 3.0 | 200 |
| YOLOv7-EPAN (Ours) | 81.5 | 37.4 | 37.9 | 35.3 | 83 |
Key Findings from the Comparison:
- Superior Accuracy: YOLOv7-EPAN achieves the highest mAP50 (81.5%) among all compared models, outperforming the next best (YOLOX at 79.4%) by a clear margin. It also shows the best performance on the critical metrics for solar panel inspection: AP_S (37.4%) and AP_M (37.9%).
- Effectiveness for Small Defects: My model surpasses specialized small-object detectors like TPH-YOLOv5 (which adds Transformer heads) by +4.8% mAP50 and +0.3% AP_S, while using fewer parameters and achieving higher FPS. This demonstrates the efficiency of my architectural integration.
- Balance of Speed and Accuracy: While models like YOLOv8 and YOLOv5s offer higher FPS, their detection accuracy, especially for small solar panel defects (AP_S), is significantly lower. YOLOv7-EPAN finds an optimal balance, delivering top-tier accuracy at 83 FPS, which is fully adequate for processing UAV video streams in real-time.
Conclusion and Impact
In this work, I have presented YOLOv7-EPAN, a robust deep learning framework specifically designed to address the challenging problem of defect detection in aerial infrared imagery of solar panel arrays. The core challenges—small target size, low contrast, and complex backgrounds—are tackled through three synergistic innovations: the context-aware CS-ELAN module, the enhanced multi-scale fusion of the EPAN network, and a hybrid localization loss function.
The experimental results are conclusive. On a real-world dataset, YOLOv7-EPAN achieves a state-of-the-art mAP50 of 81.5%, a 6.4% absolute improvement over the original YOLOv7. More importantly, it shows remarkable gains in detecting small defects (AP_S increased by 5.0%), which are the most common and最容易漏检的 faults in large-scale solar panel inspection. The model maintains a practical inference speed of 83 FPS, making it readily deployable for automated, UAV-based inspection systems.
This research provides a powerful and efficient tool for the renewable energy industry, enabling faster, more accurate, and more comprehensive health monitoring of photovoltaic power plants. By ensuring that defects in individual solar panel units are identified promptly, this technology contributes directly to maintaining high energy yield, prolonging infrastructure lifespan, and ensuring the safe operation of solar power assets. The architectural principles demonstrated here, particularly the fusion of convolutional and cross-shaped window attention mechanisms for small object detection, may also find valuable applications in other industrial inspection domains beyond photovoltaics.
