HBGF-YOLO: Enhanced Defect Detection for Solar Panels

As a researcher focused on computer vision applications in renewable energy, I have encountered significant challenges in detecting small-scale defects on solar panels using unmanned aerial vehicle (UAV) infrared imagery. The accurate identification of defects such as hot spots, cracks, and grid breaks on solar panels is critical for ensuring operational efficiency and system stability, especially under the national strategic goals of carbon peak and carbon neutrality. Traditional methods, including K-means clustering and support vector machine-based multi-feature fusion, have achieved some progress but often struggle with high computational complexity and limited adaptability to diverse scenarios. To address these issues, I propose a novel object detection algorithm named HBGF-YOLO, built upon an enhanced YOLO11n architecture. This algorithm integrates three key innovations: the Rep-HGNetV2 backbone for efficient feature extraction, a BiFPN-GLSA feature fusion framework for comprehensive multi-scale context capture, and a feature enhancement fusion module (FEFM) for dynamic cross-layer feature integration. Through extensive experiments on a specialized dataset of UAV-captured infrared images of solar panels, I demonstrate that HBGF-YOLO significantly improves detection accuracy while reducing model complexity, making it highly suitable for real-time deployment on UAV platforms.

To build a robust dataset for training and evaluation, I collected infrared images of solar panels using a DJI M300 RTK UAV equipped with a FLIR XT2 thermal camera. The dataset comprises 3,225 thermal images covering five defect categories: large-area hot spots (dmjrb), single hot spots (dyrb), abnormal low temperature (ycdw), diode short-circuit (ejgdl), and normal state (zc). Each image captures multiple solar panel modules, and I manually annotated each module using Labelimg to ensure accurate defect representation. To improve model generalization and mitigate label imbalance, I applied data augmentation techniques such as random rotation, horizontal flip, and noise addition, expanding the dataset to 6,773 images. The following table summarizes the label distribution across all annotated solar panel modules:

Table I: Dataset Label Distribution for Solar Panel Modules
Label Counts
dmjrb 1373
dyrb 1678
ycdw 1125
ejgdl 1049
zc 4870

The dataset was split into training, validation, and test sets in a 7:2:1 ratio. All experiments were conducted on an Intel Core i5-12400F processor with an RTX 4060Ti GPU, using PyTorch 1.12 and Python 3.9. Training parameters included an input size of 640×640, batch size of 16, 300 epochs, SGD optimizer, and an initial learning rate of 0.01. Evaluation metrics included precision (P), recall (R), mean average precision at IoU threshold 0.5 (mAP50), and mAP50-95, along with model parameters (Params) and floating-point operations (FLOPs). The formulas for these metrics are as follows:

$$P = \frac{N_{TP}}{N_{TP} + N_{FP}}$$

$$R = \frac{N_{TP}}{N_{TP} + N_{FN}}$$

$$mAP = \frac{1}{n} \sum_{k=1}^n AP_k$$

where \(N_{TP}\), \(N_{FP}\), and \(N_{FN}\) represent true positives, false positives, and false negatives, respectively.

The first key innovation in HBGF-YOLO is the replacement of the original YOLO11n backbone with Rep-HGNetV2. The original YOLO11n uses a BottleNeck backbone that, while effective, results in relatively high parameter count and computational cost. To address this, I adapted the lightweight HGNetV2 backbone from the RT-DETR model, which employs HGStem and HGBlock modules for efficient feature extraction. HGNetV2 incorporates depthwise separable convolutions (DWConv) to significantly reduce parameters and FLOPs. For a standard convolution with input channels \(C_{in}\), output channels \(C_{out}\), kernel size \(K \times K\), and feature map dimensions \(H \times W\), the parameter count \(P\) and FLOPs \(F\) are:

$$P = C_{in} \cdot C_{out} \cdot K \cdot K$$

$$F = C_{in} \cdot C_{out} \cdot H \cdot W \cdot K \cdot K$$

In contrast, for DWConv, the parameter count \(P_{DW}\) and FLOPs \(F_{DW}\) are:

$$P_{DW} = C_{in} \cdot K \cdot K + C_{in} \cdot C_{out}$$

$$F_{DW} = C_{in} \cdot H \cdot W \cdot K \cdot K + C_{in} \cdot C_{out} \cdot H \cdot W$$

The ratio of DWConv to standard convolution parameters and FLOPs is:

$$\frac{P_{DW}}{P} = \frac{F_{DW}}{F} = \frac{1}{C_{out}} + \frac{1}{K^2}$$

This reduction is fundamental to achieving a lightweight design. To further enhance detection precision without increasing inference cost, I integrated reparameterized convolution (RepConv) into the HGBlock structure. During training, RepConv fuses features from a 3×3 convolution (local details), a 1×1 convolution (channel interaction), and a batch normalization branch (distribution retention). During inference, these branches are merged into a single 3×3 convolution, preserving the multi-branch training advantages while maintaining the parameter efficiency of a standard convolution. Table II compares the performance of various backbones on the solar panel defect detection task:

Table II: Backbone Network Performance Comparison for Solar Panel Defect Detection
Backbone P (%) R (%) mAP50 (%) mAP50-95 (%) Params (M) FLOPs (G)
BottleNeck (Original) 84.7 78.3 83.4 70.9 2.6 6.3
ShuffleNetV2 80.3 73.8 78.7 66.9 1.6 3.6
EfficientViT 84.0 77.1 80.7 68.7 3.8 8.1
MobileNetV4 84.1 77.3 80.9 68.7 5.4 21.0
StartNet 85.6 76.5 81.2 68.9 1.9 5.0
FasterNet 85.8 80.2 83.1 70.5 3.9 9.2
HGNetV2 84.6 77.5 82.9 70.8 2.2 5.9
Rep-HGNetV2 84.5 81.2 84.2 71.9 2.1 5.7

As shown in Table II, adopting Rep-HGNetV2 yields a mAP50 of 84.2% and mAP50-95 of 71.9%, which are 0.8% and 1.0% higher than the original model, respectively, while reducing parameters by 19.2% and FLOPs by 9.5%. This demonstrates the effectiveness of combining hierarchical gradient feature extraction with reparameterization for solar panel defect detection.

Building upon Rep-HGNetV2, I next focused on enhancing feature fusion to improve multi-scale defect detection. The original YOLO11n uses a PANet structure for feature fusion, but this approach lacks the bidirectional cross-scale connections needed for effective integration of low-level spatial details and high-level semantic information. I replaced PANet with the bidirectional feature pyramid network (BiFPN) from the EfficientDet model. BiFPN introduces weighted feature fusion with learnable parameters, enabling dynamic adjustment of contributions from different scales. The weighted fusion formula is:

$$O = \sum_{i} \frac{w_i}{\epsilon + \sum_{j} w_j} \cdot I_i$$

where \(w_i\) are learnable weights and \(\epsilon\) is a small constant to avoid numerical instability. This mechanism allows the network to prioritize important features, such as those from small defect regions, while suppressing background noise. To further enhance the discriminability of features, I introduced the global-local self-attention mechanism (GLSA) between the backbone and BiFPN. GLSA divides the input feature map \(X\) into two branches: a global spatial attention (GSA) branch for capturing long-range dependencies across the entire solar panel, and a local spatial attention (LSA) branch for focusing on fine-grained details of small defects. The GLSA computation is as follows:

$$X_0, X_1 = \text{split}(X)$$

$$\text{Att}_G(X_0) = \text{Softmax}(\text{transpose}(\text{Conv}_{1\times1}(X_0)))$$

$$\text{GSA}(X_0) = \text{MLP}(\text{Att}_G(X_0) \otimes X_0) + X_0$$

$$\text{Att}_L(X_1) = \text{Sigmoid}(\text{Conv}_{1\times1}(\text{DWConv}_{3\times3}(\text{Conv}_{1\times1}))) \times 3 + X_1$$

$$\text{LSA}(X_1) = \text{Att}_L(X_1) \odot X_1 + X_1$$

$$Y = \text{Conv}_{1\times1}(\text{Concat}(\text{GSA}(X_0), \text{LSA}(X_1)))$$

Table III compares the performance of various attention mechanisms integrated with the Rep-HGNetV2 and BiFPN baseline:

Table III: Attention Mechanism Comparison for Solar Panel Defect Detection
Attention P (%) R (%) mAP50 (%) mAP50-95 (%) Params (M) FLOPs (G)
CAFM 82.4 80.3 83.7 71.0 2.3 8.4
CPCA 83.5 79.2 84.5 71.7 1.8 7.3
MLCA 85.9 79.9 84.9 72.3 1.5 5.6
SegNext 84.2 82.2 85.1 72.3 1.7 6.4
GLSA 86.2 82.6 85.2 72.6 1.7 6.2

GLSA achieves the highest mAP50 (85.2%) and mAP50-95 (72.6%), along with competitive P and R values, demonstrating its effectiveness in capturing both global context and local details critical for detecting small defects on solar panels.

The third innovation is the feature enhancement fusion module (FEFM), designed to further refine cross-layer feature integration. YOLO11n uses simple concatenation for feature fusion, which treats all features equally and fails to adapt to the varying importance of different feature maps. FEFM introduces a two-stage cascade optimization: first, it enhances low-level features using coordinate attention (CA) to emphasize spatial location information; second, it applies context modeling (CM) to generate channel-wise weights from edge features, guiding the dynamic calibration of features. The coordinate attention mechanism computes positional weights as follows:

$$z_h(c) = \frac{1}{W} \sum_{0 \le i \le W} x_c(h,i)$$

$$z_w(c) = \frac{1}{H} \sum_{j} x_c(j,w)$$

$$f = \delta(\text{Conv}_{1\times1}([z_h, z_w]))$$

$$g_h = \sigma(\text{Conv}_h(f))$$

$$g_w = \sigma(\text{Conv}_w(f))$$

$$F_{out} = x \times g_h \times g_w$$

The context modeling module generates attention maps using a 1×1 convolution and softmax function, then performs matrix multiplication for feature integration:

$$F_{CMout} = I * (z(\text{Conv}_{1\times1}(I)))$$

where \(I\) is the input feature map, \(z\) denotes softmax, and \(*\) represents matrix multiplication. By applying FEFM after the BiFPN-GLSA architecture, the model dynamically recalibrates feature weights, strengthening semantic propagation for tiny defect regions. Table IV presents the ablation study quantifying each module’s contribution:

Table IV: Ablation Study on Solar Panel Defect Detection
RH BF GL FE P (%) R (%) mAP50 (%) mAP50-95 (%) Params (M) FLOPs (G)
84.7 78.3 83.4 70.9 2.6 6.3
84.5 81.2 84.2 71.9 2.1 5.7
85.1 81.5 84.7 72.8 1.8 6.1
86.2 82.6 85.2 72.6 1.7 6.2
87.3 81.7 85.5 73.2 1.6 5.8

As shown in Table IV, the complete HBGF-YOLO model (including Rep-HGNetV2, BiFPN, GLSA, and FEFM) achieves a precision of 87.3% and recall of 81.7%, with mAP50 of 85.5% and mAP50-95 of 73.2%. Compared to the original YOLO11n, this represents improvements of 2.6%, 3.4%, 2.1%, and 2.3% in P, R, mAP50, and mAP50-95, respectively, while reducing parameters by 38.5% and FLOPs by 7.9%. These results confirm the synergistic benefits of the proposed modules for solar panel defect detection.

To evaluate the generalizability of HBGF-YOLO, I conducted comparative experiments on the self-built solar panel dataset against state-of-the-art object detection algorithms. The results are summarized in Table V:

Table V: Comparative Results on Self-Built Solar Panel Dataset
Model P (%) R (%) mAP50 (%) mAP50-95 (%) Params (M) FLOPs (G)
Faster R-CNN 71.2 70.9 74.3 61.8 43.6 207.0
SSD 65.8 68.0 68.7 59.5 25.2 34.3
ShuffleNet v2 80.3 73.8 78.7 66.9 1.6 3.6
MobileNet v4 84.1 77.3 80.9 68.7 5.4 21.0
YOLOv3-tiny+ 80.5 77.2 78.7 68.6 9.4 15.7
YOLOv5n 77.7 76.2 78.5 65.9 2.1 5.8
YOLOv5n+ 78.2 76.0 79.1 66.7 13.2 24.3
YOLOv5sm+ 81.6 79.8 81.3 69.7 17.9 38.6
YOLOv8n 79.1 76.8 79.3 67.1 2.7 6.8
LS-YOLO 85.4 80.2 83.7 72.1 1.8 23.8
YOLOv10n 80.1 79.9 81.4 70.1 2.3 6.5
YOLO11n 84.7 78.3 83.4 70.9 2.6 6.3
HBGF-YOLO 87.3 81.7 85.5 73.2 1.6 5.8

HBGF-YOLO outperforms all compared models, including specialized small-target detectors like LS-YOLO and YOLOv5n+, achieving the highest mAP50 (85.5%) and mAP50-95 (73.2%) with the lowest parameter count (1.6M) and competitive FLOPs (5.8G). This demonstrates the effectiveness of the proposed architectural innovations for detecting small defects on solar panels.

I further validated the generalization capability of HBGF-YOLO on the MS COCO dataset, a standard benchmark for object detection. All models were trained and evaluated under identical settings. Table VI shows the results:

Table VI: Comparative Results on MS COCO Dataset
Model mAP50-95 (%) Params (M) FLOPs (G)
Faster R-CNN 36.4 42.1 207.0
SSD 25.1 27.4 33.6
YOLOv5n 28.0 1.9 4.5
YOLOv7-tiny 37.4 6.2 13.7
YOLOv8n 37.3 3.2 8.7
YOLOv9t 27.5 4.5 10.5
YOLOv10n 29.8 3.5 9.2
YOLO11n 39.5 2.6 6.5
HBGF-YOLO 40.3 1.7 5.9

On MS COCO, HBGF-YOLO achieves a mAP50-95 of 40.3%, surpassing all lightweight models including the original YOLO11n (39.5%), while maintaining the lowest parameter count (1.7M) and efficient FLOPs (5.9G). This confirms that the proposed architectural innovations—Rep-HGNetV2, BiFPN-GLSA, and FEFM—are not only effective for solar panel defect detection but also provide robust generalization across diverse detection scenarios.

In conclusion, the HBGF-YOLO algorithm effectively addresses the challenges of small-target defect detection in UAV-based infrared imagery of solar panels. By introducing the efficient Rep-HGNetV2 backbone with reparameterized convolutions, the BiFPN-GLSA feature fusion framework for multi-scale and contextual feature capture, and the FEFM module for dynamic cross-layer integration, I achieved significant improvements in detection accuracy and model efficiency. Experimental results on a specialized solar panel dataset demonstrate a 2.1% increase in mAP50 and 2.3% increase in mAP50-95 over the baseline YOLO11n, alongside a 38.5% reduction in parameters and 7.9% reduction in FLOPs. Comparative studies on the MS COCO dataset further validate the superior generalization and adaptability of HBGF-YOLO. This work provides an efficient and reliable solution for automated UAV inspection of solar panels, contributing to the safe and efficient operation of photovoltaic power plants.

Scroll to Top