Prototypical Network Based Defect Classification of Solar Panels

In my research, I focus on the challenging problem of classifying defects on solar panels using an improved prototypical network approach. Solar panels are critical components in photovoltaic power generation systems, and their surface defects such as cracks, grid breaks, black spots, and scratches can significantly reduce energy conversion efficiency, accelerate aging, and even create safety hazards. Traditional defect classification methods, including manual physical inspection and conventional machine learning algorithms, often fail to deliver satisfactory performance when the available defect samples are limited and highly complex. To address these issues, I propose an enhanced prototypical network framework that integrates a stronger feature embedding backbone, a hybrid pretraining strategy, and a refined distance metric. Through extensive experiments on both benchmark datasets and a real-world solar panel defect dataset, I demonstrate that my method achieves superior classification accuracy and robustness compared to existing approaches.

The rest of this article is organized as follows. First, I review the background and related work on solar panel defect classification and few-shot learning. Then, I present the details of my improved prototypical network, including the AResnet backbone, the attention mechanism, the new training mode, and the squared Euclidean distance metric. Next, I describe the experimental setup and discuss the results on benchmark datasets and on the solar panel defect dataset. Finally, I conclude with a summary of contributions and future research directions.

1. Background and Motivation

1.1 The Importance of Solar Panel Defect Classification

Solar energy is one of the most promising renewable energy sources due to its cleanliness, safety, and wide availability. Photovoltaic panels, also known as solar panels, convert sunlight directly into electricity. However, during manufacturing and long-term outdoor operation, solar panels inevitably suffer from various defects. These defects can be classified into several categories according to their appearance and origin. For example, processing-induced defects include cracks, chipping, and broken grids, while environment-induced defects include stains, discoloration, and black spots. More severe degradation processes can lead to hidden cracks, solder joint failures, and even complete cell malfunctions. All these defects reduce the power output and lifespan of solar panels, and they may pose serious risks to the entire photovoltaic system. Therefore, reliable and efficient defect classification technology is of great value to the photovoltaic industry.

Traditional approaches for solar panel defect classification mainly rely on manual visual inspection or physical testing methods. Manual inspection is time-consuming, subjective, and expensive, especially when large-scale solar farms require regular monitoring. Physical testing methods, such as ultrasonic resonance, laser scanning, and noise comparison, are often contact-based and may cause secondary damage to the panels. Moreover, these methods are usually designed for one specific defect type and cannot easily generalize to multiple defect categories in a single automated system.

In recent years, machine learning methods have been introduced to automate solar panel defect classification. These methods typically use image processing techniques to extract features from electroluminescence, photoluminescence, thermal, or visible light images of solar panels, and then apply classifiers such as support vector machines, convolutional neural networks, or their variants. While these approaches achieve reasonable performance when sufficient labeled training data are available, real-world industrial scenarios rarely provide a large number of defect samples for every category. Solar panel defects are rare events, and collecting and annotating them on a large scale is extremely costly. Consequently, conventional machine learning models often suffer from overfitting and poor generalization when trained on limited data.

1.2 Few-Shot Learning and Embedding Learning

Few-shot learning is a subfield of machine learning that aims to learn from very few labeled examples. The key idea is to leverage prior knowledge from related tasks or auxiliary datasets so that a model can quickly adapt to new classes with only a handful of samples. In image classification, few-shot learning has become an active research area, with many methods proposed in recent years. These methods can be broadly categorized into data-based, model-based, and algorithm-based approaches. Data-based methods augment or synthesize additional training samples. Algorithm-based methods optimize the learning procedure, for example by learning better optimizers or initialization strategies. Model-based methods design architectures that can effectively encode prior knowledge and generalize from few examples. Among model-based methods, embedding learning has gained popularity because of its simplicity and effectiveness.

Embedding learning, also known as representation learning, trains a neural network to map input images into a feature embedding space where samples of the same class are close to each other and samples from different classes are far apart. The similarity between samples is then computed using a distance metric, such as Euclidean distance or cosine similarity. One of the most representative embedding learning methods is the prototypical network, introduced by Snell et al. In this method, a prototype vector is computed for each class by averaging the embedded support samples of that class. An unseen query sample is classified by finding the nearest prototype in the embedding space. Prototypical networks have achieved excellent results on standard few-shot benchmarks and are particularly suitable for industrial applications because they require only a simple clustering-based inference procedure and are computationally efficient.

Table 1. Comparison of solar panel defect classification approaches
Method Category Advantages Disadvantages Representative Techniques
Manual Physical Methods High accuracy for specific defects; mature technology Subjective; expensive; may damage panels; low efficiency Ultrasonic waves, laser scanning, noise comparison
Conventional Machine Learning Automated; stable performance with sufficient data; low cost Requires large labeled datasets; limited generalization; overfitting risk SVM, CNN, DBCNN, U-Net
Few-Shot Learning (Prototypical Networks) Works well with limited data; strong feature embedding; fast adaptation Still sensitive to complex backgrounds; needs careful design of backbone and metrics Prototypical networks, matching networks, relation networks

Despite the advantages of prototypical networks, I identified three major limitations when applying them to solar panel defect classification. First, the commonly used backbone network, a simple four-layer convolutional network (ConvNet4), has limited feature extraction capability for complex industrial images. Solar panel defect images often contain noisy backgrounds, varying illumination, and tiny defect regions, making it difficult for a shallow network to capture task-relevant features. Second, the pretraining process relies solely on auxiliary data that may be unrelated to the target domain, causing the model to focus on task-irrelevant patterns. Third, the distance metric used for similarity calculation can be further optimized. The standard Euclidean distance treats all feature dimensions equally and may not provide sufficient discrimination between similar defect classes. To overcome these issues, I propose an improved prototypical network framework with three key modifications: a new AResnet backbone with attention mechanisms, a hybrid pretraining strategy that includes task-specific samples, and the use of squared Euclidean distance as the similarity metric.

2. Improved Prototypical Network

In this section, I present the architecture and the technical details of my improved prototypical network. I first describe the overall structure, then explain the embedding module, the attention mechanism, the pretraining mode, and finally the metric module.

2.1 Overall Framework

The proposed method follows the episodic training paradigm commonly used in few-shot learning. Each episode simulates a classification task where a support set (with K examples per class) and a query set (with unseen examples) are sampled from the available data. The model learns to classify query samples using only the support set. The improvement over the original prototypical network lies in three aspects:

1. The backbone network is replaced by AResnet, a residual network integrated with convolutional block attention modules (CBAM).
2. The pretraining step uses a combination of external auxiliary data and a subset of task-specific solar panel defect samples.
3. The distance metric is changed from Euclidean distance to squared Euclidean distance, which amplifies the differences between classes and simplifies computation.

A high-level illustration of my improved framework is shown below in the image.

The pseudo-code of the training and inference process is summarized in Algorithm 1.

Algorithm 1: Improved Prototypical Network for Solar Panel Defect Classification
1. Construct the AResnet backbone by adding CBAM modules to ResNet18.
2. Load auxiliary dataset D_aux and a random subset of task dataset D_task for pretraining.
3. Pre-train the feature embedding function f_phi using episodic training on the combined pretraining set.
4. For each training episode:
    a. Sample N classes from the task training set.
    b. Sample K support images and Q query images per class.
    c. Embed all images using f_phi to get feature vectors.
    d. Compute class prototypes as the mean of support feature vectors:
        C_k = (1/K) * sum_{i in support_k} f_phi(x_i)
    e. Compute squared Euclidean distances between query features and prototypes.
    f. Convert distances to probabilities via softmax and compute cross-entropy loss.
    g. Update phi using gradient descent.
5. Repeat until convergence.
6. Evaluate on test episodes using the same procedure.

2.2 Embedding Module: AResnet Backbone

The feature embedding module is the core component that determines the quality of the extracted features. A deeper and more powerful backbone can extract richer semantic information from solar panel defect images, which is crucial for accurate few-shot classification. I chose ResNet18 as the base architecture because it strikes a good balance between depth and computational cost. ResNet18 introduces residual blocks that mitigate the vanishing gradient problem and allow effective training of deep networks. The residual learning formulation can be expressed as:

$$
\mathbf{y} = \mathcal{F}(\mathbf{x}, \{W_i\}) + \mathbf{x}
$$

where \(\mathbf{x}\) is the input to the residual block, \(\mathcal{F}(\mathbf{x}, \{W_i\})\) represents the residual mapping to be learned, and \(\mathbf{y}\) is the output. By learning the residual instead of the full transformation, the network can be trained more easily and can adapt to increasing depth without performance degradation.

However, even a residual network with 18 layers may not be sufficiently sensitive to subtle defect patterns in solar panel images. To further enhance the feature extraction capability, I integrated the Convolutional Block Attention Module (CBAM) into ResNet18. CBAM is a lightweight and effective attention module that sequentially applies channel attention and spatial attention. The channel attention mechanism focuses on “what” is important in an image, while the spatial attention focuses on “where” the important regions are. The combined AResnet architecture is illustrated in the following block diagram.

Table 2. Architecture of AResnet
Layer Type Details
Conv1 Convolutional 7×7, 64 channels, stride 2
Pool Max Pooling 3×3, stride 2
CBAM 1 Channel+spatial attention Applied after first pooling
Conv2_x Residual blocks 2 residual blocks, 64 channels
Conv3_x Residual blocks 2 residual blocks, 128 channels
Conv4_x Residual blocks 2 residual blocks, 256 channels
Conv5_x Residual blocks 2 residual blocks, 512 channels
CBAM 2 Channel+spatial attention Applied after the last residual block
Pool Average Pooling Global average pooling
FC Fully Connected Used for classification or feature output

The channel attention module computes two pooling maps from the input feature map \(F\), namely average-pooled and max-pooled features. These are fed into a shared multi-layer perceptron to produce a channel attention vector \(M_c(F)\). The process is described by:

$$
M_c(F) = \sigma\left( MLP(\text{AvgPool}(F)) + MLP(\text{MaxPool}(F)) \right)
$$

where \(\sigma\) denotes the sigmoid function. The spatial attention module then takes the channel-refined feature map \(F’\) and applies both average pooling and max pooling along the channel dimension, concatenates them, and applies a convolutional layer to generate a spatial attention map \(M_s(F’)\):

$$
M_s(F’) = \sigma\left( \text{Conv}^{7\times7}\left( [\text{AvgPool}(F’), \text{MaxPool}(F’)] \right) \right)
$$

The final refined feature map is obtained by first multiplying the channel attention, then the spatial attention:

$$
F’ = M_c(F) \otimes F, \quad F” = M_s(F’) \otimes F’
$$

where \(\otimes\) denotes element-wise multiplication. By inserting CBAM after the first conv block and after the last residual block, AResnet is able to highlight defect-relevant features and suppress irrelevant background information. This is particularly beneficial for solar panel defect images, where defects may occupy only a small region and the background texture may distract the classifier.

2.3 Pretraining with Task-Specific Data

The original prototypical network pretrains the embedding function on a large auxiliary dataset such as Omniglot or CIFAR-100. In the solar panel defect domain, the target images are very different from everyday object images. A model pretrained solely on generic images may fail to capture the unique texture, lighting, and structural patterns of solar panel defects. To alleviate this problem, I adopted a semi-supervised style pretraining strategy: I randomly sampled a subset of the actual solar panel defect training images and combined them with an external auxiliary dataset of photovoltaic near-infrared images. The auxiliary dataset contains a large number of defect images with diverse backgrounds, which provides general prior knowledge about solar panel inspection. By including a certain portion of task-specific samples during pretraining, the embedding network learns parameters that are more aligned with the feature distribution of the target domain. This reduces the interference of task-irrelevant features and improves the convergence speed and final accuracy of the model.

Formally, let \(D_{aux}\) be the external auxiliary dataset and \(D_{task}\) be the solar panel defect training set. I construct a combined pretraining dataset \(D_{pre}\) as:

$$
D_{pre} = D_{aux} \cup D_{task}^{sample}
$$

where \(D_{task}^{sample}\) is a random subset extracted from \(D_{task}\). The pretraining episodes are sampled from \(D_{pre}\) in the same N-way K-shot format as the target task. This ensures that the model is exposed to both general feature patterns (from the auxiliary data) and task-specific feature patterns (from the solar panel defect samples). As a result, the learned embedding function becomes more robust and more transferable to the downstream defect classification task.

2.4 Metric Module: Squared Euclidean Distance

In the original prototypical network, Snell et al. used Euclidean distance to compute similarity. The Euclidean distance between two feature vectors \(a\) and \(b\) in an \(n\)-dimensional space is defined as:

$$
d_{Euclidean}(a,b) = \sqrt{\sum_{i=1}^{n} (a_i – b_i)^2}
$$

Although Euclidean distance is a reasonable choice, it may not provide sufficient separation between classes that have similar feature distributions. To enhance the discriminative power, I propose using the squared Euclidean distance:

$$
d_{Squared}(a,b) = \sum_{i=1}^{n} (a_i – b_i)^2
$$

The squared Euclidean distance preserves the ordering of distances but amplifies the differences between larger and smaller distances. This has two benefits. First, it increases the relative margin between close and distant classes, making it easier for the softmax function to produce a more confident probability distribution. Second, it avoids the expensive square-root computation, which improves computational efficiency. In the context of solar panel defect classification, where many defect classes share similar visual features (e.g., cracks and broken grids), using squared Euclidean distance can improve classification accuracy by increasing the separation between similar classes.

During inference, the probability that a query sample \(x\) belongs to class \(k\) is computed as:

$$
p(y=k|x) = \frac{\exp(-d_{Squared}(f_\phi(x), C_k))}{\sum_{k’} \exp(-d_{Squared}(f_\phi(x), C_{k’}))}
$$

where \(C_k\) is the prototype of class \(k\). The model is trained by minimizing the negative log-likelihood loss:

$$
\mathcal{L} = -\log p(y=k|x)
$$

over all query samples in the episode.

3. Benchmark Experiments

3.1 Experimental Setup

To validate the effectiveness of my improved prototypical network, I first conducted experiments on two standard few-shot benchmark datasets: Omniglot and CIFAR-100. The Omniglot dataset contains 50 alphabets with 1623 character classes, each drawn by 20 different people. It is commonly used for few-shot classification. The CIFAR-100 dataset has 100 classes with 600 images per class, which is more challenging because it contains natural color images with complex backgrounds. I compared the following methods:

1. K-Nearest Neighbors (KNN) – a classic machine learning method.
2. Linear Support Vector Machine (LSVM) – a classic machine learning method.
3. Original Prototypical Network (PN) with ConvNet4 backbone and Euclidean distance.
4. Improved Prototypical Network (IPN) with AResnet backbone, hybrid pretraining, and squared Euclidean distance.

The experiments were run on a workstation with an Intel i7-11800H CPU and 6GB GPU memory, using Python 3.6.5 with the PyTorch library. The evaluation metrics were classification accuracy and total experimental time. I designed two classification tasks: 2-way 10-shot and 4-way 20-shot. For classical methods, models were trained using random sampling without replacement. For few-shot methods, episodic training with the N-way K-shot setup was used, with 1000 episodes per iteration and 100 iterations in total.

Table 3. Experimental parameters for benchmark datasets
Dataset Method Sampling / Task Train classes/samples Validation classes/samples Test classes/samples
CIFAR-100 KNN / LSVM Random / 2-way and 4-way 80 / random 10 / random 10 / random
CIFAR-100 PN / IPN 2-way 10-shot / 4-way 20-shot 60 / ≥10 or ≥20 20 / ≥10 or ≥20 20 / 10 or 20
Omniglot KNN / LSVM Random / 2-way and 4-way 1300 / random 163 / random 160 / random
Omniglot PN / IPN 2-way 10-shot / 4-way 20-shot 1200 / ≥10 or ≥20 213 / ≥10 or ≥20 210 / 10 or 20

3.2 Results on Benchmark Datasets

The experimental results are summarized in Table 4. I observed that few-shot learning methods significantly outperformed classical machine learning methods on both datasets. The original prototypical network achieved accuracy of 72.5% on CIFAR-100 binary classification, while LSVM only reached 67.8%. On Omniglot, the difference was even larger: the prototypical network achieved 97.5% accuracy while LSVM only achieved 78.2%. The improved prototypical network further improved the accuracy to 73.2% on CIFAR-100 and 98.6% on Omniglot for the 2-way task. In terms of experimental time, classical methods took longer, especially KNN which required over 150 minutes. The prototypical networks were more efficient, with the improved version taking slightly longer than the original due to the more complex backbone.

Table 4. Performance comparison on benchmark datasets
Method Dataset Task Accuracy (%) Time (min)
KNN CIFAR-100 2-way 36.6 172
KNN CIFAR-100 4-way 28.3 185
KNN Omniglot 2-way 45.4 152
KNN Omniglot 4-way 37.9 170
LSVM CIFAR-100 2-way 67.8 148
LSVM CIFAR-100 4-way 58.3 155
LSVM Omniglot 2-way 78.2 135
LSVM Omniglot 4-way 69.6 142
Original PN CIFAR-100 2-way 72.5 113
Original PN CIFAR-100 4-way 68.3 121
Original PN Omniglot 2-way 97.5 81
Original PN Omniglot 4-way 94.9 93
Improved PN CIFAR-100 2-way 73.2 125
Improved PN CIFAR-100 4-way 69.6 129
Improved PN Omniglot 2-way 98.6 88
Improved PN Omniglot 4-way 95.2 97

These benchmark experiments confirm that my improved prototypical network maintains or improves accuracy compared to the original method on standard few-shot tasks. The improved backbone and attention mechanism contribute to better feature extraction, and the squared Euclidean distance provides better discrimination. The slight increase in processing time is acceptable given the significant gains in accuracy.

4. Solar Panel Defect Classification Experiments

4.1 Dataset Description

To evaluate the proposed method in a realistic industrial setting, I constructed a hybrid solar panel defect dataset. The dataset consists of two sources: a publicly available solar panel defect dataset from the University of Erlangen-Nuremberg (FAU) containing 2000 images, and an additional set of 273 images captured by industrial cameras from actual production lines. All images are grayscale with a resolution of 300×300 pixels. In total, there are 20 different defect categories, including cracks, broken grids, black cores, missing corners, and scratches. The defect categories can be divided into three groups based on their visual characteristics: shape-related defects (e.g., scratches, cracks, chipping), brightness-related defects (e.g., short circuits, dark spots, soldering issues), and position-related defects (e.g., broken grids, black edges, stains, misalignment).

For the external auxiliary dataset, I used the PVELAD dataset, which was jointly released by Hebei University of Technology and Beihang University. PVELAD contains 50 classes and a total of 36,543 near-infrared images of solar cells with various internal defects and heterogeneous backgrounds. Each image is also 300×300 in size. This auxiliary dataset provides a large and diverse set of defect patterns that are highly relevant to the target task.

Before conducting experiments, I performed data preprocessing. First, I removed all invalid samples that were corrupted or unreadable. Then, I cropped the defect regions from the original images and assigned them to the corresponding category folders. This step ensured that each image contained a single, clearly isolated defect, reducing the influence of background noise and multiple defects in one image.

4.2 Experimental Design

I designed two sets of experiments. In the first experiment, I compared the improved prototypical network with the original prototypical network and the classic KNN algorithm on 4-way (four-class) and 6-way (six-class) classification tasks. The experimental parameters are shown in Table 5. For the few-shot methods, two sampling settings were considered: 10-shot and 30-shot per class. The task dataset was split into training, validation, and test sets according to the number of categories. The test set always contained exactly the number of categories corresponding to the task (4 or 6), while training and validation sets contained more categories. The auxiliary dataset was similarly split for pretraining the embedding function.

Table 5. Parameter settings for solar panel defect classification
Dataset Method Task Training classes/samples Validation classes/samples Test classes/samples
Mixed solar panel defect dataset KNN 4-way 12/random 4/random 4/random
Mixed solar panel defect dataset KNN 6-way 8/random 6/random 6/random
Mixed solar panel defect dataset PN / IPN 4-way 10-shot 12/≥10 4/≥10 4/10
Mixed solar panel defect dataset PN / IPN 4-way 30-shot 12/≥30 4/≥30 4/30
Mixed solar panel defect dataset PN / IPN 6-way 10-shot 8/≥10 6/≥10 6/10
Mixed solar panel defect dataset PN / IPN 6-way 30-shot 8/≥30 6/≥30 6/30
PVELAD auxiliary dataset PN / IPN Used for pretraining 30/≥10 or ≥30 10/≥10 or ≥30 10/10 or 30

4.3 First Experiment: Comparison with Classical Methods

The results of the first experiment are shown in Table 6. KNN achieved very low accuracy, only 29.1% on the 4-way task and 37.4% on the 6-way task. The original prototypical network performed much better, with accuracies ranging from 67.5% to 69.8%. My improved prototypical network achieved the highest accuracies, reaching 70.3% on 4-way 10-shot, 71.4% on 4-way 30-shot, 70.9% on 6-way 10-shot, and 72.3% on 6-way 30-shot. In terms of time, KNN required around 180 minutes, while the few-shot methods took about two hours. The improved method took slightly longer than the original due to the more complex AResnet backbone, but the additional time was well justified by the accuracy improvement.

Table 6. Performance on solar panel defect dataset (first experiment)
Method Task Accuracy (%) Time (min)
KNN 4-way 29.1 178
KNN 6-way 37.4 189
Original PN 4-way 10-shot 68.2 114
Original PN 4-way 30-shot 69.8 126
Original PN 6-way 10-shot 67.5 132
Original PN 6-way 30-shot 68.6 145
Improved PN 4-way 10-shot 70.3 127
Improved PN 4-way 30-shot 71.4 133
Improved PN 6-way 10-shot 70.9 129
Improved PN 6-way 30-shot 72.3 135

4.4 Second Experiment: Ablation Study

To analyze the contribution of each improvement, I conducted an ablation study using a fixed 5-way 25-shot setting. I varied three factors: the backbone network (ConvNet4 vs. AResnet), the pretraining mode (auxiliary only vs. auxiliary plus task-specific samples), and the distance metric (cosine, Euclidean, or squared Euclidean). The results are shown in Table 7.

Table 7. Ablation study results based on 5-way 25-shot
Backbone Pretraining Mode Distance Metric Accuracy (%) Time (min)
ConvNet4 Auxiliary only Cosine 59.4 68
ConvNet4 Auxiliary only Euclidean 61.8 74
ConvNet4 Auxiliary only Squared Euclidean 63.9 70
ConvNet4 Auxiliary + task Cosine 61.1 76
ConvNet4 Auxiliary + task Euclidean 63.5 83
ConvNet4 Auxiliary + task Squared Euclidean 65.2 80
AResnet Auxiliary only Cosine 65.6 122
AResnet Auxiliary only Euclidean 68.9 132
AResnet Auxiliary only Squared Euclidean 70.1 125
AResnet Auxiliary + task Cosine 67.2 140
AResnet Auxiliary + task Euclidean 70.3 153
AResnet Auxiliary + task Squared Euclidean 71.7 146

The ablation study reveals several important findings. First, replacing ConvNet4 with AResnet leads to a substantial accuracy increase across all configurations. For example, with auxiliary-only pretraining and squared Euclidean distance, the accuracy rises from 63.9% to 70.1%. Second, adding task-specific samples to the pretraining process improves accuracy by about one to three percentage points depending on the backbone and metric. Third, the squared Euclidean distance consistently outperforms both cosine distance and Euclidean distance. Interestingly, the squared Euclidean distance is also slightly faster than Euclidean distance because it avoids the square root operation. Overall, the best configuration is AResnet with auxiliary+task pretraining and squared Euclidean distance, achieving 71.7% accuracy. This confirms that all three improvements contribute positively to the classification performance of solar panel defects.

5. Discussion

5.1 Why the Improved Backbone Matters

The results clearly demonstrate the critical role of the feature embedding backbone. Solar panel defect images are characterized by fine textures, low contrast, and complex backgrounds. A shallow network like ConvNet4 has limited receptive fields and cannot capture high-level semantic features. AResnet, with its residual connections and attention modules, is better equipped to extract discriminative representations. The CBAM module helps the network focus on defect regions while ignoring irrelevant patterns, which is especially important when defects are small and sparse. In industrial settings, this translates to higher recall and fewer false negatives, which are crucial for maintaining product quality and safety.

5.2 The Benefit of Task-Adaptive Pretraining

Using an auxiliary dataset that shares domain characteristics with the target task (e.g., PVELAD) is a sensible approach for pretraining. However, even domain-related auxiliary data may not exactly match the distribution of the actual defect images in the target plant. By including a subset of real target images during pretraining, the model is guided to learn features that are directly relevant to the current production environment. This is analogous to domain adaptation, where the model is fine-tuned toward the target distribution. In my experiments, including task samples during pretraining provided a consistent accuracy boost of roughly 1–2 percentage points. This improvement is meaningful in industrial quality control, where even a 1% accuracy increase can save significant costs.

5.3 Squared Euclidean Distance as a Better Metric

The choice of distance metric in prototypical networks is often overlooked. Most implementations use Euclidean distance or cosine similarity. My experiments show that squared Euclidean distance offers a better balance between discriminative power and computational efficiency. The squaring operation amplifies the differences between distances, leading to sharper softmax probabilities and more confident classifications. In addition, it removes the square-root operation, which reduces the computational burden. This is particularly advantageous when the number of query samples is large, as in online inspection systems. Moreover, since the squared Euclidean distance is a monotonic transformation of the Euclidean distance, it preserves the ranking of nearest neighbors while magnifying the relative margins. This property helps the model separate visually similar defect categories such as cracks and scratches.

5.4 Limitations and Future Work

Although my improved prototypical network achieves promising results on solar panel defect classification, there are still several limitations that need to be addressed in future research.

First, the proposed method still relies on a certain amount of labeled support samples to compute class prototypes. In real industrial scenarios, labeled data are often scarce because defect annotation requires expert knowledge and is time-consuming. Future work may explore semi-supervised or self-supervised learning techniques to utilize unlabeled defect images effectively, reducing the annotation burden.

Second, the distance metric is fixed to squared Euclidean distance. While this works well, a learnable distance metric or a neural network-based similarity function may adapt better to the complex feature distributions of solar panel defects. For example, relation networks or graph neural networks could be used to learn flexible similarity measures. However, such methods increase model complexity and may require more training data.

Third, my validation is limited to still images. In practice, defects may be detected in videos captured by drones or inspection robots. Extending the method to video-based defect classification, possibly by incorporating temporal information, is a promising direction. Additionally, real-time defect localization and classification on a moving platform would be valuable for maintaining large-scale solar farms.

Finally, the current dataset is a hybrid of public and private images, which may not fully represent all possible defect types and lighting conditions. More extensive data collection from different locations, weather conditions, and solar panel types would help to evaluate the generalization capability of the model. I plan to collaborate with industry partners to collect larger and more diverse datasets for further validation.

6. Conclusion

In this article, I have presented an improved prototypical network for the classification of defects in solar panels. My method makes three key contributions. First, I introduced AResnet, which combines ResNet18 with convolutional block attention modules, as the feature embedding backbone. This architecture enables the model to extract richer and more task-relevant features from complex solar panel defect images. Second, I proposed a hybrid pretraining mode that jointly utilizes an external auxiliary dataset and a subset of task-specific defect samples. This helps the embedding function learn parameters that are better adapted to the target domain, improving classification accuracy and reducing the influence of irrelevant features. Third, I replaced the standard Euclidean distance with squared Euclidean distance in the metric module. This simple yet effective change increases the discriminative power between defect classes and reduces computational cost.

Through comprehensive experiments on two benchmark datasets and a realistic solar panel defect dataset, I demonstrated that the improved prototypical network outperforms both the original prototypical network and classical machine learning methods. On the solar panel defect classification task, my method achieved accuracies above 70% in all settings, compared to less than 40% for KNN and around 68% for the original prototypical network. The ablation study confirmed that each improvement contributes positively, and their combination yields the best performance. These results support the feasibility of applying few-shot learning techniques, especially prototypical networks, to industrial defect classification tasks where data are limited and complex.

In the future, I plan to extend this work toward semi-supervised learning to reduce the dependency on labeled data, to explore learnable distance metrics for more flexible similarity computation, and to investigate temporal modeling for video-based solar panel inspection. I firmly believe that few-shot learning methods, such as the improved prototypical network proposed in this work, will play an increasingly important role in automated visual inspection of solar panels and other industrial products, ultimately enabling more efficient and sustainable energy systems.

Scroll to Top