Hot spot detection in solar panels is a critical task for maintaining photovoltaic (PV) system efficiency and preventing fire hazards. Traditional methods relying on manual inspection or infrared imaging suffer from low efficiency and high cost. Existing deep learning algorithms typically require large-scale annotated datasets for training, but in real-world scenarios, hot spot samples are extremely scarce. Few-shot learning offers a promising solution to alleviate this data dependency, yet many current approaches still face issues of insufficient detection accuracy and poor generalization. In this study, I propose an improved few-shot learning algorithm specifically designed for hot spot detection in solar panels. The algorithm employs a meta-learning framework combined with a dynamic task adaptation module and a hybrid loss function. Experimental results on a self-built infrared dataset demonstrate significant improvements in precision and F1-score compared to baseline methods such as MAML and ProtoNet.
Hot spots on solar panels are localized regions of elevated temperature caused by defects such as cell cracks, solder joint failures, partial shading, or aging. These defects not only reduce power output but can also lead to accelerated degradation or even catastrophic failure. Accurate and timely detection of hot spots is therefore essential for the safe and economical operation of PV plants. Convolutional neural network (CNN) based models have been widely adopted for defect detection, but they require large amounts of labeled data. In practice, collecting and annotating hot spot samples is challenging due to their rarity and variability across different environmental conditions—for instance, hot spots appear concentrated in high-temperature areas under strong summer sunlight, while they manifest as diffuse patterns under weak winter illumination. Furthermore, the limited number of available samples makes it difficult to train robust models. Few-shot learning, particularly meta-learning, addresses this issue by enabling models to learn from a small number of examples per class, thereby adapting quickly to new tasks. However, standard meta-learning methods like Model-Agnostic Meta-Learning (MAML) and Prototypical Networks (ProtoNet) often underperform when applied to hot spot detection because they rely on fixed matching strategies that cannot handle the large morphological variance and class imbalance characteristic of hot spot samples. To overcome these limitations, I propose an enhanced algorithm that incorporates a dynamic task adaptation module and a hybrid loss function tailored to the physical properties of hot spots. The core contributions of this work are: (1) a dynamic matching mechanism that adjusts prototype generation and similarity thresholds based on sample distribution; (2) a mixed loss combining triplet loss with temperature-aware constraints; and (3) extensive experiments showing superior performance over existing methods.
Methodology
Meta-Learning Strategy
The core idea of meta-learning is to train a model on a distribution of tasks so that it can quickly adapt to new tasks with only a few examples. In the context of hot spot detection for solar panels, each task corresponds to a specific photovoltaic panel image set containing a support set (few labeled hot spot and normal samples) and a query set (unlabeled samples to be classified). The meta-training phase consists of two loops: an inner loop where the model adapts to each task using its support set, and an outer loop where the meta-parameters are updated based on the performance on the query set across all tasks. Let \( p(T) \) denote the task distribution, and for each task \( T_i \) we have a support set \( D_{\text{support}} \) and a query set \( D_{\text{query}} \). The meta-parameters \( \theta \) are updated as follows:
$$
\theta_i’ = \theta – \alpha \nabla_\theta \mathcal{L}_{T_i}(\theta; D_{\text{support}})
$$
where \( \alpha \) is the inner learning rate, \( \nabla_\theta \) is the gradient operator, and \( \mathcal{L}_{T_i} \) is the loss function for task \( T_i \) computed on the support set. After obtaining task-specific parameters \( \theta_i’ \), the meta-parameters are updated by:
$$
\theta \leftarrow \theta – \beta \nabla_\theta \sum_{T_i \sim p(T)} \mathcal{L}_{T_i}(\theta_i’; D_{\text{query}})
$$
where \( \beta \) is the meta-learning rate. This two-stage optimization allows the model to learn transferable knowledge that facilitates fast adaptation when only a few labeled samples are available for a new panel. In my approach, I design the meta-learner to be a feature extractor followed by a classifier; the feature extractor is shared across tasks, while the classifier is fine-tuned per task.
Dynamic Task Adaptation Module
Standard meta-learning approaches for classification typically generate fixed class prototypes (e.g., mean features of the support set) and then assign query samples to the nearest prototype. This fixed strategy is suboptimal for solar panel hot spot detection because hot spot samples exhibit high intra-class variability (e.g., different shapes, sizes, and temperature gradients) and are often contaminated by noise such as dirt, dust, or uneven illumination. To address this, I introduce a dynamic task adaptation module that adjusts the matching logic based on the distribution characteristics of the current task. The module consists of two main components: a sample distribution feature bank and a dynamic matching controller.
The sample distribution feature bank extracts three types of information from the support and query sets in real time: (1) morphological distribution of hot spots—computes the area, circularity, and temperature standard deviation of hot spot regions to determine whether they are small and concentrated or large and diffuse; (2) interference distribution—categorizes background noise types such as stain interference, uneven illumination, or no significant interference; (3) distribution similarity between support and query sets—uses KL divergence to measure the feature distribution difference and detect domain shifts.
Based on the feedback from the feature bank, the dynamic matching controller adaptively modifies three aspects of the matching process:
- Prototype generation: Instead of using the simple mean of support features, I employ a clustering-weighted prototype. Specifically, I apply DBSCAN (Density-Based Spatial Clustering of Applications with Noise) to the support set hot spot features and separate them into core samples (near the cluster center with stable features) and edge samples (far from the center, possibly affected by noise). The prototype is then computed as a weighted average: core samples receive weights of 0.6–0.7, while edge samples receive weights of 0.3–0.4. This prevents outlier samples from skewing the prototype representation.
- Similarity threshold adjustment: The classification threshold is dynamically set based on the interference level. If strong interference (e.g., stain coverage) is detected in the support set, the features of hot spots and normal regions become less separable; thus, the matching threshold is lowered by 10%–15% (e.g., from 0.60 to 0.51) to reduce false negatives. Conversely, if the query set shows high feature variance due to uneven illumination, the threshold is raised to filter out false positives.
- Task adaptation iteration: An online sample screening mechanism is introduced. After each matching round, I evaluate the confidence of samples classified as hot spots based on their temperature and morphological features. High-confidence samples (confidence > 0.85) are temporarily added to the support set to update the prototype. This dynamic expansion is especially beneficial in extreme few-shot scenarios (e.g., 1-shot) where the initial support set is very small, allowing the model to iteratively accumulate reliable samples and improve prototype accuracy.
The overall architecture of the dynamic task adaptation module is conceptually depicted below (note: no figure reference is included in the text); the module takes as input the support and query features, passes them through the distribution feature extraction and matching controller, and outputs adapted prototypes and thresholds for the classification layer.
Hybrid Loss Function
Loss functions guide the network to learn discriminative features between hot spots and normal regions. The standard triple loss used in many meta-learning frameworks pulls anchor and positive samples together while pushing anchor and negative samples apart. However, it only considers feature similarity in the embedding space and ignores the physical temperature property of hot spots. For solar panels, a region with high visual similarity to a hot spot might actually be a normal area with a different temperature, leading to misclassification. To incorporate the physical constraint, I design a hybrid loss function that combines triplet loss with a temperature-constrained loss:
$$
L_{\text{mix}} = a L_{\text{triplet}} + b L_{\text{temp}}
$$
where \( a \) and \( b \) are weighting coefficients that balance the contributions of feature semantics and temperature constraints.
The triplet loss \( L_{\text{triplet}} \) is defined as:
$$
L_{\text{triplet}} = \max\big(d(f, p) – d(f, n) + \text{margin}, \; 0\big)
$$
where \( d(\cdot, \cdot) \) is the Euclidean distance, \( f \) is the feature vector of an anchor hot spot sample, \( p \) is the “hardest positive” (the support sample that is morphologically most different from the anchor), and \( n \) is the “hardest negative” (the query sample that is feature-wise closest to the anchor but belongs to the normal class). The margin is set to 0.5. This dynamic triplet construction forces the network to focus on the most confusing pairs, thereby enhancing discriminability.
The temperature-constrained loss \( L_{\text{temp}} \) is designed based on the physical principle that any hot spot region must have a temperature higher than its surroundings. I extract temperature feature vectors from the infrared image (pixel-wise temperature values) for each predicted region. The loss is formulated as:
$$
L_{\text{temp}} = \frac{\omega_1 \cdot \max\left( T_{\text{hot}} – T_{\text{pred}}, 0 \right) + \omega_2 \cdot \max\left( T_{\text{pred}} – T_{\text{normal}}, 0 \right)}{T_{\text{hot}} – T_{\text{normal}}}
$$
where \( T_{\text{pred}} \) is the mean temperature feature of the predicted region, \( T_{\text{hot}} \) is the preset hot spot temperature threshold (e.g., 60°C), \( T_{\text{normal}} \) is the normal region upper limit (e.g., 50°C), and \( \omega_1, \omega_2 \) are penalty weights that increase with temperature deviation. If a region is predicted as a hot spot but its temperature is below \( T_{\text{hot}} \), a penalty is applied; similarly, if a region predicted as normal has temperature above \( T_{\text{normal}} \), a penalty is incurred. This constraint ensures that the learned features align with the physical reality of hot spots in solar panels.
By integrating both losses, the network simultaneously optimizes for feature-level discrimination and temperature-consistency, reducing the risk of false detections caused by visually similar but physically normal areas. The overall network architecture consists of a shared feature extractor (a lightweight CNN) that outputs both visual features and temperature features. The dynamic task adaptation module then processes these features to produce adapted prototypes, and the hybrid loss is applied during both meta-training and meta-testing.
Experiments
Dataset
To evaluate the proposed algorithm, I constructed a dataset of solar panel infrared images using a Matrice 350 RTK drone equipped with a Zenmuse H30 series thermal camera. A total of 3,480 raw images were collected from multiple PV power plants under various weather conditions (sunny, cloudy) and seasons. The images contain hot spot defects marked by experts, reflecting abnormal temperature distributions caused by cell cracks, solder joint issues, partial shading, or aging. To prevent overfitting and increase the diversity of training samples, I applied data augmentation techniques to expand each image to 4,000 samples. The augmentation methods are summarized in the table below.
| Augmentation Method | Description |
|---|---|
| Horizontal/Vertical Flip | Mirror the image horizontally or vertically to generate new samples. |
| Rotation | Rotate the image by a random angle within ±30°. |
| Affine Transformation | Apply translation, scaling, and shearing operations. |
| Gaussian Noise Addition | Add Gaussian noise with zero mean and small variance to simulate sensor noise. |
| Color Jitter | Adjust brightness, contrast, saturation, and hue within a small range. |
Experimental Setup
All experiments were conducted on an NVIDIA GeForce RTX 3090 GPU with 24 GB memory. The model was implemented in PyTorch. The stochastic gradient descent (SGD) optimizer was used with a momentum of 0.9 and weight decay of 1e-4. The batch size was set to 16, and the total number of meta-training iterations was 300. The inner learning rate α was 0.01, and the outer meta-learning rate β was 0.001. For the hybrid loss, the weights a and b were empirically set to 0.7 and 0.3, respectively, with ω1 = 0.8 and ω2 = 0.2. The margin for triplet loss was 0.5. All experiments were repeated five times, and the average results are reported.
Evaluation Metrics
I used three standard metrics to evaluate detection performance: Precision, Recall, and F1-score. They are defined as:
$$
\text{Precision} = \frac{TP}{TP + FP}
$$
$$
\text{Recall} = \frac{TP}{TP + FN}
$$
$$
F1 = 2 \times \frac{\text{Precision} \times \text{Recall}}{\text{Precision} + \text{Recall}}
$$
where TP (true positive) is the number of hot spot regions correctly detected, FP (false positive) is the number of normal regions incorrectly classified as hot spots, and FN (false negative) is the number of actual hot spots missed by the model.
Results and Comparison
I compared the proposed method against two popular few-shot learning baselines: MAML and ProtoNet. All methods were evaluated under the 5-shot setting, meaning that each task had exactly five labeled hot spot samples and five labeled normal samples in the support set. The results are summarized in the table below.
| Method | Precision (%) | F1-score (%) | Recall (%) |
|---|---|---|---|
| MAML | 89.5 | 89.6 | 89.8 |
| ProtoNet | 90.3 | 90.4 | 90.5 |
| Proposed Method | 93.2 | 93.5 | 93.8 |
As shown, the proposed method outperforms both MAML and ProtoNet across all metrics. Specifically, precision improved by 3.7 percentage points over ProtoNet, recall improved by 3.3 percentage points, and F1-score improved by 3.1 percentage points. These gains are attributed to the dynamic task adaptation module, which better handles the morphological variability of hot spots in solar panels, and the hybrid loss function, which suppresses false positives caused by temperature-inconsistent detections. The dynamic prototype generation and threshold adjustment effectively reduce the impact of outlier samples and background noise, while the temperature constraint ensures that only physically plausible hot spots are detected.
Discussion
The experimental results confirm the effectiveness of the proposed improvements. In the challenging 5-shot scenario, the algorithm achieves over 93% F1-score, which is a significant improvement over standard meta-learning approaches. However, the current study has some limitations. The dataset was collected under controlled drone flight conditions, and the performance on video streams or under extreme weather conditions (e.g., heavy rain, snow) has not been validated. In future work, I plan to extend the evaluation to dynamic video-based detection, where the model can leverage temporal consistency to further reduce false alarms. Additionally, I aim to explore more advanced feature extractors and self-supervised pre-training to boost generalization across different solar panel types and degradation levels.

Conclusion
In this paper, I presented an improved few-shot learning algorithm for detecting hot spots in solar panels. The method integrates a dynamic task adaptation module that adjusts prototype generation, similarity thresholds, and support set expansion based on real-time distribution characteristics of the task. A hybrid loss function combining triplet loss with temperature-constrained loss ensures that the learned features are both discriminative and physically consistent with the thermal behavior of hot spots. Experiments on a self-built infrared dataset show that the proposed method achieves 93.2% precision and 93.5% F1-score in the 5-shot scenario, outperforming existing approaches like MAML and ProtoNet. This work demonstrates that combining meta-learning with domain-specific adaptation and physical constraints can significantly improve the reliability of hot spot detection in solar panels, thereby enhancing the operational efficiency and safety of photovoltaic power plants. Future research will focus on extending the framework to video-based detection and real-time deployment on edge devices.
