In the field of photovoltaic energy, solar panel quality inspection is critical for ensuring long-term performance and reliability. Electroluminescence (EL) imaging captures infrared images of solar cells under reverse bias, revealing defects such as cracks and micro-cracks as dark regions. Manual inspection of these images is time-consuming and error-prone, motivating the development of automated defect detection systems. Deep learning-based object detectors, particularly the YOLO family, have shown promise due to their balance of speed and accuracy. However, existing methods often struggle with feature extraction from infrared images and real-time performance requirements. In this work, we propose an improved detection algorithm based on YOLOv8n, incorporating a BiFormer vision transformer with bi-level routing attention as the backbone to dynamically adjust attention range and enhance feature representation. We further introduce a squeeze-and-excitation (SE) attention mechanism in the neck network to improve sensitivity to critical channels. Finally, we develop a Better Student Learning Method (BSLM), a semi-supervised approach that leverages unlabeled data to boost model accuracy without additional annotation effort. Extensive experiments on the PVEL-AD dataset demonstrate that our method achieves 83.9% mAP@0.5, outperforming YOLOv8n by 3.1%, while running at 101.01 FPS. With BSLM, the mAP@0.5 further increases to 90.7%, significantly improving detection performance for solar panel defects.
Keywords: solar panel, infrared image, object detection, YOLO, attention mechanism, semi-supervised learning, BiFormer, SE attention.
1. Introduction
Solar panels are a cornerstone of renewable energy generation. During manufacturing and operation, defects such as cracks, hot spots, and electrode degradation can significantly reduce conversion efficiency. Infrared imaging via electroluminescence (EL) is widely used to capture internal defects; the resulting images show darker regions where current flow is impeded. Traditional manual inspection is labor-intensive and subjective, driving research into computer vision techniques.
Object detection algorithms based on convolutional neural networks (CNNs) have been successfully applied to industrial defect detection. Among them, the YOLO series offers a favorable trade-off between speed and accuracy. However, several challenges remain. First, existing detection models like YOLOv3, YOLOv5, and YOLOv8 often suffer from overfitting due to excessive use of fully connected layers, and they struggle to adapt to varying defect sizes and shapes. Second, the networks lack a mechanism to focus on the most informative regions, leading to wasted computation and missed detections. Third, obtaining large-scale annotated datasets for solar panel defects is expensive and prone to human error.
To address these issues, we propose an enhanced YOLOv8n model integrated with the BiFormer attention mechanism. BiFormer employs a two-level routing strategy that dynamically adjusts the receptive field, enabling the model to capture multi-scale features and improve generalization. Additionally, we insert a Squeeze-and-Excitation (SE) block in the feature pyramid network to reweight channel-wise features, suppressing irrelevant information and enhancing defect-relevant cues. To alleviate the burden of manual annotation, we introduce a semi-supervised learning framework named Better Student Learning Method (BSLM), which iteratively uses a teacher model to generate pseudo-labels on unlabeled data, then trains a student model on the combined dataset. This process significantly improves detection accuracy without requiring additional labeled images.
The main contributions of this paper are:
- We replace the standard C2f modules in the early stages of the YOLOv8n backbone with BiFormer blocks, reducing overfitting and enabling adaptive attention to objects of various sizes.
- We incorporate an SE attention module in the last layer of the neck network to highlight important feature channels, improving detection of small cracks in solar panel infrared images.
- We propose BSLM, a novel semi-supervised approach that iteratively refines pseudo-labels and boosts model performance by up to 6.8% mAP without extra annotation.
The rest of the paper is organized as follows. Section 2 details the proposed methodology, including the improved network architecture and the BSLM training strategy. Section 3 describes the experimental setup, dataset, and evaluation metrics. Section 4 presents and analyzes the results from ablation studies, comparative experiments, and BSLM validation. Section 5 concludes the paper.
2. Methodology
2.1 Overall Framework
Our improved YOLOv8n model is built upon the lightweight YOLOv8n architecture to satisfy real-time detection requirements. The key modifications are:
- Replace the first two C2f modules in the backbone with BiFormer blocks (as shown in the dashed red region in the network diagram).
- Insert an SE attention module after the last C2f block in the neck network.
The overall structure is illustrated in the figure below. The input infrared image (640×640×3) is processed through a backbone with BiFormer and standard convolutional layers, followed by a neck that fuses multi-scale features using PANet and an SE block, and finally a detection head that outputs bounding boxes and class probabilities.

The network receives a 640×640 RGB image and passes through the backbone: a 3×3 convolution extracts initial features (160×160), then two C2f blocks and two BiFormer blocks further refine features at 80×80 and 40×40 scales. After an SPPF module, the neck network upsamples and concatenates features, with SE applied at the final 20×20 layer before the detection head.
2.2 BiFormer Attention Mechanism
To overcome the limitations of fixed-size fully connected layers and improve generalization, we adopt the BiFormer module. BiFormer follows a vision transformer pyramid structure with four stages. At each stage, overlapping patch embedding is applied to capture local pixel relationships, and subsequent patch merging increases channel depth while reducing spatial resolution. The core of BiFormer is the bi-level routing attention (BRA), which dynamically selects relevant key/value pairs for each query, enabling sparse global attention.
Given an input feature map of size H×W×C, it is first reshaped into regions of size S×S. The number of regions is
$$ N_r = \frac{HW}{S^2} $$
After linear projection, we obtain query Q, key K, and value V:
$$ Q = X_r W_q, \quad K = X_r W_k, \quad V = X_r W_v $$
where Xr is the region-level feature map with shape Nr × S2 × C, and Wq, Wk, Wv are learnable weight matrices.
The bi-level routing first computes a coarse region-to-region affinity matrix to select top-k relevant regions for each query region. Then, fine-grained attention is applied within the union of the selected regions. This sparse mechanism reduces computational cost while preserving global context.
Each BiFormer block (as shown in the detailed diagram) consists of a 3×3 depthwise convolution for relative position encoding, followed by layer normalization (LN), bi-level routing attention, another LN, and a multi-layer perceptron (MLP) with two fully connected layers and GELU activation.
By replacing the first two C2f modules with BiFormer blocks, our model achieves dynamic attention ranges, adapting to different defect shapes and sizes in solar panel infrared images.
2.3 SE Attention Mechanism
To further enhance feature representation, we insert a Squeeze-and-Excitation (SE) block at the last layer of the neck network (20×20 feature map). The SE module performs global feature recalibration:
- Squeeze: Global average pooling compresses spatial dimensions H×W into a channel descriptor of size 1×1×C.
- Excitation: Two fully connected layers (with reduction ratio r) learn channel-wise dependencies, followed by a sigmoid activation to produce per-channel weights.
- Scale: The weights are multiplied element-wise with the original feature map, emphasizing important channels and suppressing irrelevant ones.
Formally, given an input feature U of shape H×W×C, the squeeze operation produces z:
$$ z_c = \frac{1}{H \times W} \sum_{i=1}^{H} \sum_{j=1}^{W} u_c(i,j) $$
The excitation operation computes weights s:
$$ s = \sigma( W_2 \cdot \text{ReLU}( W_1 z ) ) $$
where W1 reduces channels to C/r and W2 restores to C. Finally, the output is:
$$ \tilde{x}_{c} = s_c \cdot u_c $$
Incorporating SE in the neck ensures that the detector focuses on defect-relevant channels, improving detection of subtle cracks in solar panel infrared images.
2.4 Better Student Learning Method (BSLM)
Manual annotation of solar panel defects is costly and error-prone. To leverage abundant unlabeled data, we propose BSLM, a semi-supervised learning strategy inspired by Noisy Student. The training process consists of iterative rounds:
- Train a teacher model on the labeled dataset L (723 images).
- Use the teacher to generate pseudo-labels (hard labels with highest confidence) on unlabeled dataset U1 (1728 images).
- Combine L and pseudo-labeled U1 to train a student model.
- The trained student becomes the new teacher, and step 2–3 are repeated with the next unlabeled set U2 (1728 images).
- After three rounds, the final student model is obtained, which achieves significantly higher accuracy.
The iterative refinement allows the model to gradually incorporate high-quality pseudo-labels, effectively increasing the training data without additional human effort. We use data augmentation (Mosaic, rotation, etc.) during student training to improve robustness.
The process is summarized in the following table:
| Round | Teacher Model | Unlabeled Data | Training Data | Student Model |
|---|---|---|---|---|
| 0 | Initial (trained on L) | — | L (723) | Baseline |
| 1 | Round0 Student | U1 (1728) | L + pseudo U1 | Student1 |
| 2 | Student1 | U2 (1728) | L + pseudo U1 + pseudo U2 | Student2 |
| 3 | Student2 | U3 (1729) | L + pseudo U1 + pseudo U2 + pseudo U3 | Student3 |
Note: All unlabeled datasets are disjoint. The teacher adds noise (e.g., dropout, stochastic depth) during inference to generate diverse pseudo-labels.
3. Experimental Setup
3.1 Dataset and Preprocessing
We evaluate our method on the PVEL-AD dataset, which contains infrared images of solar panels with various defects. We select all images containing cracks (6,218 images). We randomly choose 1,033 images and split them into training set (723), validation set (206), and test set (104). The remaining 5,185 images are divided into three equal unlabeled sets: U1 (1,728), U2 (1,728), and U3 (1,729). All images are resized to 640×640 pixels. Annotations are made using the LabelImg tool, with bounding boxes for crack defects.
3.2 Implementation Details
Experiments are conducted on an NVIDIA A30 GPU (24GB memory) with PyTorch 1.13.1 and CUDA 11.4. The input size is 640×640. Training uses SGD optimizer with momentum 0.937, weight decay 5e-4, initial learning rate 0.01, and cosine annealing scheduler. We train for 300 epochs with batch size 16. Data augmentation includes Mosaic, random horizontal flip, and color jitter. For BSLM, we train the teacher for 300 epochs, then train each student for 300 epochs with the same hyperparameters but with higher noise (dropout rate 0.3).
3.3 Evaluation Metrics
We adopt the following metrics:
- mAP@0.5: Mean average precision at IoU threshold 0.5.
- mAP@0.5:0.95: Mean average precision averaged over IoU thresholds from 0.5 to 0.95.
- Precision and Recall at confidence threshold 0.25.
- FPS: Frames per second on the test set.
- Parameters (in millions) and FLOPs (in billions).
4. Results and Discussion
4.1 Ablation Study on BiFormer Integration
To verify the effectiveness of the BiFormer backbone, we compare YOLOv8n (baseline) with a version where the first two C2f blocks are replaced by BiFormer blocks (denoted as v8n_B). Results are shown in Table 2.
| Model | Input Size | mAP@0.5 | mAP@0.5:0.95 | FPS | Params (M) | FLOPs (G) |
|---|---|---|---|---|---|---|
| YOLOv8n | 640×640 | 0.808 | 0.490 | 128.21 | 3.16 | 8.9 |
| v8n_B | 640×640 | 0.815 | 0.506 | 96.15 | 3.23 | 10.9 |
v8n_B improves mAP@0.5 by 0.7% and mAP@0.5:0.95 by 1.6% over the baseline, albeit with a slight drop in FPS (still >96, meeting real-time requirements). The additional parameters come from the BiFormer attention layers.
4.2 Ablation Study on Different Attention Modules in Neck
To find the best attention module, we add CA, SA, CoTA, CBAM, and SE to the last layer of the neck of v8n_B. Results are listed in Table 3.
| Model | mAP@0.5 | mAP@0.5:0.95 | Precision | Recall |
|---|---|---|---|---|
| v8n_B | 0.815 | 0.506 | 0.752 | 0.759 |
| v8n_B+CA | 0.820 | 0.503 | 0.750 | 0.791 |
| v8n_B+SA | 0.825 | 0.533 | 0.788 | 0.738 |
| v8n_B+CoTA | 0.818 | 0.508 | 0.794 | 0.777 |
| v8n_B+CBAM | 0.824 | 0.519 | 0.778 | 0.777 |
| v8n_B+SE | 0.839 | 0.531 | 0.755 | 0.798 |
The SE module yields the highest mAP@0.5 (83.9%), improving by 2.4% over v8n_B. The recall is also the best, indicating fewer missed defects in solar panel images.
4.3 Ablation Study on SE Placement
We investigate the optimal layer for inserting the SE module. Table 4 shows mAP values when SE is inserted at different layers (layer indices correspond to the backbone/neck positions).
| Model | mAP@0.5 | mAP@0.5:0.95 | Precision | Recall |
|---|---|---|---|---|
| v8n_B | 0.815 | 0.506 | 0.752 | 0.759 |
| +layer 1 | 0.813 | 0.507 | 0.735 | 0.767 |
| +layer 4 | 0.808 | 0.507 | 0.817 | 0.698 |
| +layer 6 | 0.814 | 0.492 | 0.778 | 0.775 |
| +layer 10 | 0.824 | 0.505 | 0.765 | 0.780 |
| +layer 17 | 0.508 | 0.513 | 0.784 | 0.748 |
| +layer 20 | 0.813 | 0.491 | 0.727 | 0.773 |
| +layer 23 | 0.839 | 0.531 | 0.755 | 0.798 |
Layer 23 corresponds to the last layer of the neck before the detection head. Deeper layers benefit more from SE because they contain higher-level semantic features with more channels; the recalibration is more effective there.
4.4 Comparative Experiments with State-of-the-Art Detectors
We compare our final model (v8n_B_SE) with YOLOv3, YOLOv5 series, YOLOv6 series, YOLOv7 series, and YOLOv8 series on the same test set. Results are shown in Table 5.
| Model | Input Size | mAP@0.5 | mAP@0.5:0.95 | FPS | Params (M) | FLOPs (G) |
|---|---|---|---|---|---|---|
| YOLOv3-tiny | 640×640 | 0.806 | 0.442 | 256.41 | 8.7 | 13.0 |
| YOLOv3 | 640×640 | 0.818 | 0.486 | 104.17 | 61.5 | 155.3 |
| YOLOv3-spp | 640×640 | 0.817 | 0.492 | 102.04 | 62.6 | 156.1 |
| YOLOv5n | 640×640 | 0.797 | 0.464 | 163.93 | 1.8 | 4.2 |
| YOLOv5s | 640×640 | 0.792 | 0.474 | 175.44 | 7.0 | 15.9 |
| YOLOv5m | 640×640 | 0.756 | 0.434 | 140.85 | 20.9 | 48.2 |
| YOLOv5l | 640×640 | 0.777 | 0.467 | 116.28 | 46.1 | 108.2 |
| YOLOv5x | 640×640 | 0.782 | 0.471 | 82.64 | 86.2 | 204.6 |
| YOLOv6n | 640×640 | 0.586 | 0.295 | 35.36 | 11.4 | 4.7 |
| YOLOv6s | 640×640 | 0.670 | 0.353 | 34.93 | 18.5 | 45.3 |
| YOLOv6m | 640×640 | 0.613 | 0.352 | 32.66 | 34.9 | 85.8 |
| YOLOv6l | 640×640 | 0.767 | 0.456 | 29.28 | 59.6 | 150.7 |
| YOLOv7 | 640×640 | 0.795 | 0.482 | 36.29 | 37.2 | 105.1 |
| YOLOv7d | 640×640 | 0.713 | 0.415 | 30.33 | 152.9 | 198.3 |
| YOLOv7e | 640×640 | 0.712 | 0.434 | 30.72 | 110.4 | 144.3 |
| YOLOv7w | 640×640 | 0.717 | 0.417 | 35.79 | 80.9 | 102.4 |
| YOLOv7x | 640×640 | 0.764 | 0.467 | 32.54 | 70.8 | 188.9 |
| YOLOv8n | 640×640 | 0.808 | 0.490 | 128.21 | 3.2 | 8.9 |
| YOLOv8s | 640×640 | 0.787 | 0.468 | 123.46 | 11.1 | 28.6 |
| YOLOv8m | 640×640 | 0.765 | 0.467 | 104.17 | 25.9 | 79.1 |
| YOLOv8l | 640×640 | 0.806 | 0.514 | 80.65 | 43.6 | 165.7 |
| YOLOv8x | 640×640 | 0.803 | 0.508 | 65.79 | 68.2 | 258.1 |
| v8n_B_SE (Ours) | 640×640 | 0.839 | 0.531 | 101.01 | 3.1 | 10.3 |
Our model achieves the highest mAP@0.5 among all compared detectors, surpassing YOLOv8n by 3.1%, YOLOv3 by 2.1%, and YOLOv5n by 4.2%. The parameter count is only 3.1M, which is even slightly lower than YOLOv8n (3.2M), demonstrating efficiency. Although the FPS (101.01) is lower than some lightweight models like YOLOv3-tiny, it still comfortably exceeds the real-time requirement of 30 FPS. Our method strikes an excellent balance between accuracy and speed for solar panel defect detection.
4.5 BSLM Semi-Supervised Learning Results
We apply BSLM on the base improved model (v8n_B_SE). Starting with 723 labeled images, we iteratively incorporate unlabeled sets. Table 6 shows the mAP@0.5 and FPS after each round.
| Model | Input Size | mAP@0.5 | FPS |
|---|---|---|---|
| v8n_B_SE (baseline) | 640×640 | 0.839 | 101.01 |
| BSLM Round 1 | 640×640 | 0.901 | 83.33 |
| BSLM Round 2 | 640×640 | 0.906 | 84.03 |
| BSLM Round 3 | 640×640 | 0.907 | 94.34 |
After the first round, mAP jumps from 83.9% to 90.1%, an improvement of 6.2%. Subsequent rounds bring marginal gains, reaching 90.7% after three rounds. The FPS recovers from 83.33 to 94.34 after the third round, likely due to more stable weights. The BSLM effectively leverages unlabeled data to dramatically improve detection accuracy for solar panel cracks without manual annotation.
4.6 Visual Comparison
We compare the detection results of YOLOv8n and our v8n_B_SE on sample infrared images of solar panels. Our method successfully detects more cracks and produces fewer false negatives, especially for small and low-contrast defects. The improved attention mechanisms help the model focus on defect regions, while BSLM further refines the decision boundaries.
5. Conclusion
We have presented an enhanced YOLOv8n-based framework for detecting cracks in infrared images of solar panels. By replacing early C2f blocks with BiFormer modules, the network dynamically adjusts attention to handle diverse defect sizes, reducing overfitting. The addition of an SE attention block in the neck improves channel-wise feature recalibration, boosting the detection of subtle cracks. Furthermore, the proposed Better Student Learning Method (BSLM) iteratively incorporates unlabeled data, yielding a substantial 6.8% increase in mAP@0.5 without any extra labeling effort. Extensive experiments demonstrate that our method achieves state-of-the-art performance (83.9% mAP@0.5 initially, 90.7% after BSLM) while maintaining real-time inference (101.01 FPS). This work provides a practical and efficient solution for automated solar panel defect inspection in industrial settings.
Future work could explore integrating additional attention mechanisms or extending the semi-supervised framework to other types of defects (e.g., hot spots, snail trails) in solar panel infrared images. Furthermore, deploying the model on edge devices could enable real-time, on-site inspection.
