Solar panel efficiency is paramount for renewable energy systems, yet environmental exposure frequently induces defects such as hot spots, physical damage, electrical failures, debris coverage, and soiling. Accurate and real-time detection of these anomalies is critical for maintaining performance and prolonging lifespan. However, existing deep learning models often suffer from high computational burden, large parameter counts, and poor adaptation to complex backgrounds, leading to false positives and missed detections. In this work, we propose a lightweight yet highly accurate defect detection framework built upon YOLOv8, specifically tailored for solar panel inspection. Our approach integrates several innovations: a feature extraction backbone based on the efficient StarNet architecture, a triple attention mechanism (Triplet) for multi-scale feature enhancement, an improved spatial pyramid pooling module (SPPF‑AM), a deformable convolution block (C2f_DSConv2D), a spatial context awareness module (SCAM) for noise suppression, and an enhanced bounding box regression loss (ECIoU). Extensive experiments on a self‑collected solar panel defect dataset demonstrate that our model reduces parameters by 35% and computational cost by 29.6%, while improving mAP@50 from 85.9% to 89.7%.

Figure above illustrates a typical high‑quality solar panel. Defects of various scales and types require a robust detection method that balances accuracy, speed, and model size for deployment on resource‑constrained edge devices such as drones.
1. Methodology
1.1 Lightweight Backbone: StarNet
We replace the original YOLOv8n backbone with StarNet, a fast feature extraction network built upon the “star operation”. The star operation performs element‑wise multiplication of two linearly transformed feature vectors, effectively mapping input into an exponentially higher‑dimensional implicit feature space without increasing computational complexity. Given input \( \mathbf{X} \in \mathbb{R}^{d} \), the operation is defined as:
$$ \omega_{1}^{\mathsf{T}}\mathbf{x} \cdot \omega_{2}^{\mathsf{T}}\mathbf{x} = \sum_{i=1}^{d+1}\sum_{j=1}^{d+1} \omega_{1}^{i}\omega_{2}^{j} x_{i}x_{j} $$
Stacking multiple star‑operation layers yields an implicit feature space of dimension \(\mathcal{O}((d/2)^{2l})\) after \(l\) layers. StarNet consists of four hierarchical stages, each using depthwise convolution, Batch Normalization, and ReLU6 activations. This design reduces parameters and FLOPs while preserving representation power. Using StarNet, our model’s parameter count drops by 26.3% and FLOPs by 19.8% compared to the baseline YOLOv8n.
1.2 Triplet Attention Module
To enhance multi‑scale defect feature extraction, we insert a Triplet attention module at the end of the backbone. Triplet captures cross‑dimensional interactions through three parallel branches, each applying rotation, Z‑pool, convolution, and Sigmoid activation. The three output tensors are averaged to produce the final attention map:
$$ \mathbf{Y} = \frac{1}{3}\left( \hat{\mathbf{X}}_{1}\sigma(\psi_{1}(\hat{\mathbf{X}}_{1}^{*})) + \hat{\mathbf{X}}_{2}\sigma(\psi_{2}(\hat{\mathbf{X}}_{2}^{*})) + \mathbf{X}\sigma(\psi_{3}(\hat{\mathbf{X}}_{3}^{*})) \right) $$
This mechanism focuses the network on defect‑relevant regions, improving detection of small‑scale anomalies such as micro‑cracks or early‑stage hot spots.
1.3 Improved Spatial Pyramid Pooling (SPPF‑AM)
The original SPPF module in YOLOv8 uses only max pooling of various kernel sizes. We augment it by concatenating the outputs of AdaptiveMaxPool2d and MaxPool2d, enabling the model to capture both local and global contextual information without a fixed output size. The enhanced module (SPPF‑AM) processes input through a Conv layer followed by parallel pooling branches, then concatenates them. This design strengthens the model’s ability to handle defects of varying dimensions, from large debris to tiny electrical faults.
1.4 C2f_DSConv2D: Lightweight Deformable Convolution
We replace the standard C2f blocks in the neck network with C2f_DSConv2D, which integrates Distribution‑Shift Convolution (DSConv). DSConv reduces convolution kernel size via a Variable Quantization Kernel (VQK) and two distribution shifters (KDS and CDS), maintaining output quality while significantly lowering memory and computation. The resulting C2f_DSConv2D block provides richer gradient flow and efficient resource utilization, reducing parameter count by 9.9% and FLOPs by 5.6% relative to the baseline.
1.5 Spatial Context Awareness Module (SCAM)
SCAM is inserted into the feature fusion network to suppress noise and irrelevant background. It consists of three branches: one uses global average pooling (GAP) and global max pooling (GMP) to integrate global information, a second applies 1×1 convolution for linear transformation, and a third simplifies key‑value pairs. The outputs are combined via matrix multiplication and Hadamard product. The module computes pixel‑wise spatial context as:
$$ Q_{i}^{j} = P_{i}^{j} + \alpha_{i}^{j} \sum_{k=1}^{N_{i}} \frac{\exp(\omega_{qk} P_{i}^{j})}{\sum_{n=1}^{N_{i}} \exp(\omega_{qk} P_{i}^{n})} \cdot \omega_{v} P_{i}^{j} $$
where \(\alpha_{i}^{j}\) is derived from the concatenation of GAP and GMP outputs. SCAM effectively aligns local features, reduces feature loss for weak defects, and improves discriminability between defect and background.
1.6 Enhanced Bounding Box Loss: ECIoU
Standard CIoU loss considers overlap, center distance, and aspect ratio, but may suffer from slow convergence when training on diverse defect shapes. We design ECIoU by combining CIoU and EIoU terms:
$$ \mathcal{L}_{\text{ECIoU}} = 1 – \text{IoU} + \alpha\nu + \frac{\rho^{2}(b^{\text{gt}},b)}{c^{2}} + \frac{\rho^{2}(h^{\text{gt}},h)}{c_{h}^{2}} + \frac{\rho^{2}(w^{\text{gt}},w)}{c_{w}^{2}} $$
Here \(\alpha = \frac{\nu}{(1-\text{IoU})+\nu}\) and \(\nu = \frac{4}{\pi^{2}} (\arctan\frac{w^{\text{gt}}}{h^{\text{gt}}} – \arctan\frac{w}{h})^{2}\). ECIoU accelerates convergence and improves localization accuracy for solar panel defects of various aspect ratios.
2. Experimental Setup
2.1 Dataset
We collected a custom dataset of solar panel images using a DJI M300 drone equipped with a Zenmuse H20T camera. The dataset contains 12,533 images annotated with five defect categories: hot spots, physical damage, electrical damage, foreign object coverage, and soiling. The distribution is shown in Table 1. Data was split into training (70%), validation (20%), and test (10%) sets.
| Defect Type | Number of Samples |
|---|---|
| Hot spot | 1,506 |
| Physical damage | 2,200 |
| Electrical damage | 1,880 |
| Foreign object coverage | 3,900 |
| Soiling | 3,047 |
2.2 Implementation Details
Experiments were conducted on an NVIDIA GeForce RTX 4060 GPU with 16 GB RAM under Windows 10. We used PyTorch 1.12, CUDA 12.2, and Python 3.8. Training ran for 200 epochs with batch size 16, SGD optimizer (initial learning rate 0.01, momentum 0.9, weight decay 0.001), and cosine learning rate decay. Transfer learning was applied using COCO2017 pre‑trained weights to initialize the YOLOv8n backbone, then fine‑tuned on our solar panel dataset.
2.3 Evaluation Metrics
We report precision (P), recall (R), mean average precision at IoU threshold 0.5 (mAP@0.5), number of parameters (Params in millions), and computational complexity (GFLOPs). Definitions:
$$ P = \frac{TP}{TP+FP}, \quad R = \frac{TP}{TP+FN}, \quad mAP = \frac{1}{n}\sum_{i=1}^{n} AP_{i} $$
where \(AP_{i}\) is the area under the precision‑recall curve for class \(i\).
3. Ablation Study
We performed a comprehensive ablation to evaluate the contribution of each proposed module. Results are summarized in Table 2. Starting from baseline YOLOv8n (mAP@0.5 = 85.9%), adding StarNet alone reduces parameters by 26.3% while mAP drops to 85.6%. Incorporating Triplet or SPPF‑AM individually boosts mAP by ~0.5% but increases complexity. Using C2f_DSConv2D yields 86.4% mAP with only 5.4M parameters. The SCAM module further improves mAP to 86.9%, and ECIoU loss alone raises it to 87.6%. The full model (SN+YOLOv8 with all modules) achieves 89.7% mAP, while reducing Params from 5.7M to 3.7M (−35%) and GFLOPs from 8.1 to 5.7 (−29.6%).
| SN | Triplet | SPPF‑AM | C2f_DSConv2D | SCAM | ECIoU | GFLOPs | R (%) | mAP@0.5 (%) | Params (M) |
|---|---|---|---|---|---|---|---|---|---|
| ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | 8.1 | 83.9 | 85.9 | 5.7 |
| ✓ | ✗ | ✗ | ✗ | ✗ | ✗ | 6.5 | 84.2 | 85.6 | 4.2 |
| ✗ | ✓ | ✗ | ✗ | ✗ | ✗ | 21.5 | 84.5 | 86.4 | 11.7 |
| ✗ | ✗ | ✓ | ✗ | ✗ | ✗ | 8.3 | 84.4 | 85.1 | 5.9 |
| ✗ | ✗ | ✗ | ✓ | ✗ | ✗ | 7.3 | 84.4 | 86.4 | 5.4 |
| ✗ | ✗ | ✗ | ✗ | ✓ | ✗ | 8.0 | 85.2 | 86.9 | 5.8 |
| ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | 8.2 | 85.6 | 87.6 | 5.7 |
| ✓ | ✓ | ✗ | ✗ | ✗ | ✗ | 15.4 | 82.1 | 84.1 | 8.0 |
| ✓ | ✓ | ✓ | ✓ | ✗ | ✗ | 5.7 | 83.2 | 85.0 | 3.9 |
| ✓ | ✓ | ✓ | ✓ | ✓ | ✗ | 5.7 | 86.5 | 88.6 | 3.9 |
| ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | 5.7 | 87.1 | 89.7 | 3.7 |
4. Comparison with State‑of‑the‑Art
We compared our final model (denoted “Ours”) against several popular object detectors on the same solar panel dataset. Table 3 reports the results. Our method achieves the best trade‑off between accuracy and efficiency: 90.1% precision, 87.1% recall, 89.7% mAP@0.5, with only 3.7M parameters and 5.7 GFLOPs. In contrast, YOLOv8s (the larger version) yields 89.0% mAP but with 21.2M parameters and 28.4 GFLOPs. Our model outperforms YOLOv5n, YOLOv7‑tiny, YOLOv9t, and two‑stage detectors like Faster R‑CNN and SSD by a large margin while being significantly lighter.
| Model | P (%) | R (%) | mAP@0.5 (%) | Params (M) | GFLOPs |
|---|---|---|---|---|---|
| Faster R‑CNN | 56.3 | 74.1 | 76.3 | 108.2 | 302.8 |
| SSD | 68.5 | 73.8 | 78.5 | 93.1 | 150.5 |
| EfficientDet | 77.3 | 75.2 | 80.4 | 70.7 | 90.8 |
| YOLOv5n | 80.6 | 85.7 | 87.7 | 4.0 | 8.6 |
| YOLOv7‑tiny | 79.3 | 65.4 | 72.3 | 11.5 | 13.2 |
| YOLOv8n | 80.6 | 83.9 | 85.9 | 5.7 | 8.1 |
| YOLOv8s | 81.2 | 84.7 | 89.0 | 21.2 | 28.4 |
| YOLOv9t | 82.2 | 85.3 | 86.4 | 5.0 | 10.7 |
| RE‑DETR | 83.3 | 84.2 | 87.5 | 38.3 | 230.6 |
| Ours | 90.1 | 87.1 | 89.7 | 3.7 | 5.7 |
5. Generalization Performance
To evaluate generalization capability, we further tested our model on the public PVELAD dataset (36,543 near‑infrared solar cell images with 12 defect classes). Table 4 compares our method with YOLOv8n on this unseen dataset. Our model achieves 88.9% mAP@0.5 (versus 85.0%) with only 3.9M parameters, confirming strong cross‑dataset robustness.
| Model | P (%) | R (%) | mAP@0.5 (%) | Params (M) |
|---|---|---|---|---|
| YOLOv8n | 81.2 | 84.0 | 85.0 | 5.7 |
| Ours | 87.6 | 86.4 | 88.9 | 3.9 |
6. Qualitative Analysis
Visual comparisons on sample test images show that our model reliably detects all defect instances with high confidence, while competing methods (YOLOv5n, YOLOv7‑tiny, YOLOv8n, YOLOv8s, YOLOv9t) often miss small defects or produce overlapping bounding boxes. Our lightweight design does not sacrifice accuracy; instead, it reduces false positives and false negatives even under cluttered backgrounds.
7. Conclusion
In this work, we presented a lightweight and accurate solar panel defect detection algorithm based on YOLOv8. By integrating StarNet backbone, Triplet attention, SPPF‑AM, C2f_DSConv2D, SCAM, and ECIoU loss, we achieved a parameter reduction of 35%, FLOPs reduction of 29.6%, and an mAP@0.5 improvement from 85.9% to 89.7%. The model exhibits strong generalization on the public PVELAD dataset. Future work will focus on further improving detection accuracy for minority defect classes (e.g., hot spots and electrical damage) and deploying the algorithm on dual‑light drones for real‑time inspection in field environments. The proposed framework provides a practical solution for intelligent solar panel maintenance with limited computational resources.
