MoCoProto: Enhancing few-shot pest image classification with self-supervised representation learning Authors: Dong Jin, Helin Yin, Xianghua Piao, Yeong Hyeon Gu Published: 2026 ABSTRACT Accurate pest detection is crucial for safeguarding crop productivity and quality. Few-shot image classification offers a promising solution for automated pest recognition in limited-data settings. Recent studies have demonstrated the effectiveness of meta-learning with episodic tasks, enabling rapid adaptation to new classes. However, due to the limited number of samples available for each task, pretraining an appropriate embedding network for meta-learning plays a critical role in determining the few-shot classification performance. To enhance feature extraction, recent approaches have adopted supervised whole-classification training as a preparatory step before meta-learning. Nevertheless, when the labeled data for whole-classification training is insufficient, the performance improvements become limited. To address these challenges, this study proposes a method called MoCoProto, which combines self-supervised learning with meta-learning. The proposed method first utilizes momentum contrast-based self-supervised visual representation learning to pretrain an embedding network using unlabeled images. The pretrained embedding network is then applied to a prototypical network for few-shot image classification through meta-learning. For self-supervised pretraining, a broad-domain agricultural dataset comprising 357,705 images from 65 pest species and 144 plant diseases was used, from which all label information was excluded, relying solely on the image data. Subsequently, meta-training and final evaluation were conducted using the IP102 insect pest dataset, and the experimental results demonstrated that the proposed MoCoProto achieved the best performance, recording accuracies of 49.33% in 1-shot and 70.13% in 5-shot classification. Introduction Effective pest detection is crucial for maintaining crop productivity and quality, directly influencing global food security and agricultural sustainability. According to the Food and Agriculture Organization of the United Nations (FAO), pests cause an annual loss of 20% to 40% in global crop production, with invasive insects costing the global economy approximately 70 billion dollars each year [1]. Without adequate crop protection, major food crops may experience yield losses of up to 23% [2]. Early and accurate pest identification enables timely interventions, reducing reliance on chemical treatments, preventing significant crop losses, and preserving produce quality [3]. Traditional pest detection methods primarily rely on manual inspections by farmers and expert identification, which are labor-intensive and time-consuming. Variations in expertise among inspectors can lead to inconsistent and subjective assessments, and if an inspector makes an identification error, it can result in delayed interventions, allowing pests to establish and spread, thereby increasing control costs and crop damage [4]. To address these issues, various machine learning techniques have been applied in agriculture, enabling the analysis of large datasets to identify patterns and predict pest occurrences, thereby facilitating proactive management [5]. Despite the challenges associated with accurate pest recognition, such as high intra-class variability and environmental noise, recent advancements in deep learning have significantly improved recognition accuracy [6,7]. Several studies have explored deep convolutional neural networks and transfer learning approaches [8,9], as well as hybrid models that combine CNNs with traditional classifiers such as support vector machines [10,11] to enhance pest classification performance. By leveraging large-scale datasets, deep learning models can automatically learn discriminative features, enabling high-precision pest recognition from images [12]. This automation improves monitoring efficiency and reduces reliance on manual inspection. Additionally, remote sensing technologies, such as drones and satellite imagery, enable large-scale crop health monitoring and early pest detection, contributing to proactive and effective pest management strategies [13]. Despite its advantages, deploying deep learning in real-world agricultural settings faces significant challenges, primarily due to the need for extensive labeled datasets. Training deep learning models requires a large number of annotated images to achieve high accuracy. However, obtaining such large-scale datasets is often impractical in the agricultural domain [14]. This is because some pest species are extremely rare or appear only during specific periods, and their high mobility, particularly in airborne species, makes it difficult to collect images using conventional imaging techniques. More importantly, labeling agricultural images requires domain expertise, making the annotation process labor-intensive and expensive. Few-shot learning (FSL) [15] addresses this challenge by enabling classification with limited labeled samples, making it a promising approach for pest image recognition. Few-shot learning is a machine learning paradigm that enables classification with only a few labeled training examples per class. Unlike conventional deep learning models, which require large-scale annotated datasets, few-shot learning is designed to generalize from limited supervision, making it highly suitable for tasks where collecting labeled data is challenging. Meta-learning [16] is a promising approach in few-shot learning that utilizes episodic training, a widely adopted strategy that enables models to efficiently learn from a small number of examples. It consists of a meta-training phase on seen classes and a meta-test phase on unseen classes. Each episode includes a support set and a query set, mimicking the few-shot setting. An overview of this process is illustrated in the meta-learning component of Fig. 1. This approach has gained increasing attention in pest recognition, where the scarcity of labeled data poses significant challenges. Recent studies have explored various meta-learning approaches for pest recognition tasks, including CNN-based feature extraction [17], metric-based meta-learning [18,19], and multi-layer feature fusion [20], to enhance few-shot classification performance. However, features learned solely through episodic training might lack sufficient discriminative capability for novel classes, resulting in an inability to acquire robust and generalizable feature representations, ultimately leading to poor generalization to novel classes [21].Fig. 1Overview of meta-learning with different pretraining strategies. Overview of meta-learning with different pretraining strategies. Recent studies [22,23] have shown that performing whole-classification training before meta-learning can significantly improve few-shot learning performance. Whole-classification training refers to training a model to classify among all base classes, namely the classes available during meta-training, using a standard supervised learning procedure. In this approach, the encoder, serving as the embedding network, is first pre-trained in a supervised manner and subsequently used in the meta-learning stage. This overall process is illustrated in the supervised learning and meta-learning components of Fig. 1. This pretraining step helps extract better features, leading to improved generalization in downstream tasks. Wang et al. [24] and Tian et al. [25] showed that training an embedding network with supervised learning on the meta-training set before applying meta-learning can outperform complex meta-learning algorithms in few-shot tasks. However, these methods were validated on the miniImageNet [26] and tieredImageNet [27] datasets, where each class contains a relatively large number of image samples suitable for pretraining. In real-world scenarios, however, collecting such large-scale datasets for every class is often labor-intensive and impractical. When the labeled dataset for whole-classification training is insufficient, performance improvements in few-shot learning become marginal, limiting its effectiveness in severely data-constrained environments. To address this challenge, some studies have explored leveraging external information to improve model generalization. Nuthalapati et al. [28] utilized an embedding network pretrained on the ImageNet [29] dataset to extract generalizable features for few-shot pest classification. Wang et al. [30] incorporated domain knowledge by designing an auxiliary architecture that leverages hierarchical insect taxonomy to improve few-shot pest detection. While these approaches improve generalization, they rely heavily on manually curated resources and domain expertise, limiting their practicality. Self-supervised learning (SSL) [31] has emerged as a promising alternative by enabling models to learn meaningful feature representations from unlabeled data, offering a solution to the labor-intensive process of constructing large-scale labeled pest datasets. In SSL, models are trained on pretext tasks, such as instance discrimination [32] or context auto-encoding [33], where supervisory signals are derived from the data itself. This enables the model to learn inherent data structures without manual annotations, thereby reducing dependence on labeled data. Liu et al. [34] proposed a self-supervised pretraining method based on the transformer architecture [35] using a latent semantic masking autoencoder and demonstrated its effectiveness on the IP102 [36] and Citrus Pest Benchmark (CPB) [37] datasets. Kar et al. [38] evaluated multiple SSL methods, including Nearest Neighbor Contrastive Learning of Visual Representations (NNCLR) [39], Bootstrap Your Own Latent (BYOL) [40], and Barlow Twins [41], for classifying 22 different insect pests. However, to the best of our knowledge, SSL approaches have not yet been applied to few-shot pest image classification. Owing to its low reliance on labeled data, SSL offers strong potential for integration with few-shot learning. Various studies in other domains have actively explored the use of SSL-pretrained embedding networks to improve few-shot learning performance. This framework aligns with the integration of self-supervised and meta-learning components illustrated in Fig. 1. Chen et al. [42] leveraged the Augmented Multiscale Deep InfoMax (AMDIM) [43] SSL framework to train a generalized embedding network for few-shot image classification, demonstrating strong performance on MiniImageNet and CUB [44] datasets. Similarly, Lim et al. [45] integrated SSL with prototypical networks (ProtoNet) [46] and knowledge distillation to improve sample discrimination, achieving state-of-the-art results on several benchmark datasets. However, these studies have not specifically focused on the agricultural pest domain. In this field, only relatively small datasets, such as IP102 and AgriPest [47], are available. This scarcity of data presents unique challenges for developing effective few-shot learning models in agricultural contexts. To address these limitations, this study proposes MoCoProto, a novel approach that integrates self-supervised visual representation learning with meta-learning for few-shot pest image classification. MoCoProto first learns visual representations from a large-scale unlabeled agricultural image dataset through self-supervised pretraining and then adapts the pretrained embedding network to target few-shot tasks through meta-learning. Because large-scale self-supervised pretraining can involve substantial computational cost, this study also explores unlabeled image selection strategies to examine whether efficient representation learning can be achieved with a reduced amount of pretraining data. The primary contributions of this work can be summarized as follows: (1) MoCo-based self-supervised learning is employed to pretrain the embedding network, enabling effective feature representation learning without relying on labeled data. (2) The pretrained embedding network is applied to a ProtoNet to perform few-shot pest image classification, enhancing adaptation to novel classes in data-scarce settings. (3) A large-scale agricultural image dataset comprising 357,705 images, including 65 pest species and 144 plant diseases, was utilized for self-supervised pretraining. (4) The proposed MoCoProto outperformed benchmark models on the IP102 dataset, achieving accuracies of 49.33% in 5-way 1-shot and 70.13% in 5-way 5-shot classification. Materials and methods Datasets Self-supervised learning dataset To train an embedding network using SSL, a large-scale image dataset is required. In this study, a dataset comprising 357,705 images was constructed for SSL using images collected by agricultural experts through PlantInfoCMS [14], a scalable plant disease and pest image collection and information management system. While PlantInfoCMS supports both data collection and annotation, only raw images without labeling information were utilized for pretraining. The dataset used for training includes pest images, healthy crop images, and disease-infected crop images. The rationale for incorporating a broader range of agricultural images beyond pests is that PlantInfoCMS is primarily designed for pest and disease detection dataset construction. Consequently, the collected images contain extensive background information in addition to the primary objects of interest. Such background information is considered beneficial for model pretraining, as it may contain additional information about specific crops, leaves, and environmental conditions, thereby enhancing the model's ability to extract meaningful feature representations. In this study, images were collected from 34 different crop species, covering 65 pest species and 144 plant diseases. Each class contains a different number of samples, and image resolutions also vary. Before utilizing the dataset for training, each image was validated for corruption and readability. Any files that failed to open properly due to corruption or format errors were discarded. Sample images used for SSL are presented in Fig. 2.Fig. 2Sample images from the unlabeled agricultural dataset used for self-supervised pretraining. Sample images from the unlabeled agricultural dataset used for self-supervised pretraining. Meta-learning dataset To validate the proposed approaches, the IP102 dataset was used in the meta-learning stage. IP102 is an insect pest dataset comprising 75,222 images across 102 classes. Each class contains images of insect pests at different life cycle stages, including egg, larva, pupa, and adult, with images from different stages grouped under the same pest category. The dataset follows a natural long-tailed distribution, with significant variation in the number of samples per class. The most populated class includes 5,740 images, whereas the least populated class contains only 71 images. To mitigate class imbalance and simulate a data-scarce scenario for meta-learning, a uniform sampling strategy was applied. Specifically, 71 images were randomly sampled from each class to construct a balanced dataset. Following the dataset splitting method introduced by Ravi et al. [48] for miniImageNet, the 102 classes in IP102 were divided into 16 classes for meta-validation, 20 for meta-testing, and the remaining 66 for meta-training. To clarify the relationship between the SSL pretraining dataset and the IP102 evaluation split, a class-level cross-check was conducted between the 65 pest species included in the PlantInfoCMS-based SSL dataset and the IP102 class split adopted in this study. Some overlap was identified with the meta-training and meta-validation classes, whereas no overlap was observed with the meta-test classes used for the final few-shot evaluation. MoCoProto framework To address the limitations of few-shot image classification in data-scarce scenarios, this study proposes a two-stage framework, MoCoProto, that integrates Momentum Contrast (MoCo) for self-supervised representation learning and ProtoNet for meta-learning. As shown in Fig. 3, the first stage uses MoCo to learn transferable visual representations from unlabeled images. In the second stage, the pretrained encoder is employed as the embedding network of a ProtoNet for few-shot classification in an episodic setting.Fig. 3Overview of the proposed MoCoProto framework. Overview of the proposed MoCoProto framework. Self-supervised learning stage To learn discriminative visual representations from an unlabeled dataset, this study employs MoCo, an SSL method, to pretrain the embedding network. MoCo is a contrastive learning framework based on instance discrimination, which trains models to distinguish a query image from negative samples using augmented views. By comparing similar and dissimilar pairs, contrastive learning has significantly advanced SSL, achieving performance comparable to supervised learning and establishing itself as a viable approach for large-scale applications. The objective of MoCo is to train an embedding network to increase the similarity between positive examples while maximizing separation from negative examples in the latent space. In this framework, two augmented views of the same image constitute a positive pair, whereas other images and their augmentations are treated as negative samples. MoCo can be interpreted as training an encoder for a dictionary look-up task. From this perspective, an encoded query vector q is compared against a set of encoded keys {k0,k1,k2,…}, which serve as entries in a dynamic dictionary. Among these keys, there exists a single positive key k+ that corresponds to the query q. The model is trained using the InfoNCE [49] loss, a form of contrastive loss, to distinguish the positive key from a large set of negatives, as defined in Eq. (1).(1)Lq,k+,{k−}=−logexp(q·k+/τ)exp(q·k+/τ)+∑k−exp(q·k−/τ)In Eq. (1), q denotes the query vector, k+ represents the positive key, and {k−} refers to the set of negative keys. The temperature parameter τ controls the sharpness of the softmax distribution, and (·) denotes the dot product between vectors, serving as a similarity measure. The sum is over one positive key k+ and a set of negative keys {k−}. The query q and key k are vector representations of the input samples xq and xk, respectively, encoded by the query encoder fq and the key encoder fk. The InfoNCE loss encourages the encoder to maximize the similarity between a query and its corresponding positive key while minimizing similarity to negative keys in the latent space. To ensure consistency in key representations across training steps, MoCo introduces a momentum update mechanism for the key encoder fk. Instead of updating fk directly through backpropagation, its parameters are updated using an exponential moving average of those of the query encoder fq. This update is defined as:(2)fk←m·fk+(1−m)·fq,where m∈[0,1) is the momentum coefficient, typically set close to 1. This mechanism stabilizes learning by preventing sudden changes in the key encoder, thereby maintaining consistency in the dictionary representations. Additionally, MoCo incorporates a dynamic dictionary which is implemented as a queue to store encoded keys from previous mini-batches. This queue-based mechanism decouples the number of negative samples from the batch size, enabling comparison against a large and consistent set of negative samples without significantly increasing computational or memory costs. By combining the momentum updates with queue-based dictionary, MoCo enables stable and efficient contrastive learning from unlabeled data. Following the improvements introduced by MoCo v2 [50], this study integrates a multilayer perceptron (MLP) projection head and enhanced data augmentation strategies into the MoCo framework. A ResNet-50 architecture, with the final fully connected layer removed, is used as the encoder. The resulting output vectors, which have a fixed dimensionality of 128, are normalized by their L2 norms [32] and serve as the query and key embeddings for contrastive learning. The pretrained encoder is subsequently employed as the backbone for the few-shot classification model, which is trained using ProtoNet in the meta-learning stage. Meta-learning stage Meta-learning is applied to fine-tune a pretrained encoder obtained from the SSL stage, which serves as the embedding network in an episodic setting. This study adopts ProtoNet, a metric-based meta-learning, to perform few-shot classification. In this setting, each few-shot classification task can be described as an N-way K-shot problem, where the model is provided with a support set S={(x1,y1),(x2,y2),…,(xN·K,yN·K)} consisting of K labeled examples for each of the N classes. Here, each xi∈Rd is the d-dimensional feature representation of an image, and yi∈{1,…,N} is its corresponding class label. In addition to the support set, each episode also includes a query set Q, which contains additional unlabeled samples from the same N classes, used to compute classification probabilities and optimize the training loss. The goal of meta-learning is to enable rapid adaptation and accurate classification of query samples from the same set of classes, using only the limited labeled data available in the support set. ProtoNet generalizes to novel classes with limited labeled data by learning a metric space where classification relies on distances to class prototypes. A prototype is defined as the mean vector of the embedded support samples belonging to a specific class. For each class c in the support set, the prototype pc is computed by averaging the embedded support examples that belong to class c as:(3)pc=1|Sc|∑(xi,yi)∈Scf(xi),where Sc⊂S denotes the subset of support samples belonging to class c, and f(·) denotes the embedding function initialized using the pretrained encoder from the SSL stage. To classify a query sample xq∈Q, ProtoNet computes its distance to each class prototype and applies a softmax over the negative distances scaled by a temperature parameter:(4)P(y=c∣xq)=exp(−d(f(xq),pc)/β)∑c′exp(−d(f(xq),pc′)/β),where d(·,·) denotes the Euclidean distance in the embedding space, and β is a temperature parameter that controls the sharpness of the softmax distribution. The model is trained in an episodic manner by minimizing the negative log-probability of the true class c for each query sample using gradient descent:(5)I(θ)=−logPθ(y=c∣x),where θ denotes the parameters of the embedding network. By leveraging the discriminative representations learned during self-supervised pretraining, the model can rapidly adapt to new classes using only a few labeled examples during meta-learning. Unlabeled image selection strategy In SSL, using a larger number of images generally improves performance. However, this benefit comes at the cost of increased computational time and resources. To examine how unlabeled data composition affects SSL under a fixed data budget, this study explores three image selection strategies, namely random selection, maximum diversity selection, and proportional selection. An overview of these three strategies is illustrated in Fig. 4.Fig. 4Conceptual overview of random, maximum diversity, and proportional image selection strategies. Conceptual overview of random, maximum diversity, and proportional image selection strategies. Random selection strategy The random selection strategy begins with a near-duplicate removal, where average hashing [51] is used to identify and discard visually redundant images. This process ensures that the resulting image pool contains more diverse and unique samples. From this pool, a target number of images is uniformly sampled at random. This strategy serves as a baseline for assessing the effectiveness of more sophisticated sampling methods. Maximum diversity selection strategy Instead of selecting images at random, this strategy performs feature-based clustering after duplicate removal. Image features are extracted using a ResNet-50 model pretrained on the ImageNet dataset, followed by L2 normalization. The resulting feature vectors are clustered using K-means, with the number of clusters set equal to the target number of selected images. To efficiently process high-dimensional features and reduce clustering time, GPU-accelerated K-means clustering was performed using the FAISS [52] library. One representative image is then selected from each cluster to maximize coverage of the feature space. The selection is based on an image quality score that considers both resolution and aspect ratio, defined as:(6)IQ=w×h×min(r,1r),where w and h denote the image's width and height, and r is the aspect ratio. This metric penalizes extremely small or distorted images, while assigning higher scores to those with higher resolution and more balanced aspect ratios. Proportional selection strategy Rather than selecting only one image per cluster, this strategy selects multiple images in proportion to the size of each cluster, maintaining the relative frequency of diverse visual patterns in the dataset. Unlike the maximum diversity selection strategy, this approach sets the number of clusters to the square root of the total number of target images. After clustering, images are sampled from each cluster based on its size, and within each cluster, high-quality images are prioritized using the same image quality score employed in the maximum diversity selection strategy. The impact of these selection strategies on downstream few-shot classification performance is evaluated experimentally and reported in Section 4.4. Experiments Training process Self-supervised learning stage The SSL stage involved training the embedding network using the MoCo framework. Optimization was performed using stochastic gradient descent (SGD) with a momentum of 0.9 and a weight decay of 0.0001. The initial learning rate was set to 0.015, and a cosine annealing schedule was applied. The temperature parameter τ in the contrastive loss function was set to 0.2, and the momentum coefficient for the key encoder update was set to 0.999. The queue size for storing negative keys was set to 65,536. Training was performed for 800 epochs with a batch size of 128 using four NVIDIA RTX 3090 GPUs over approximately 8.5 days. Each input image sample was independently augmented twice to generate a query and a key view for contrastive learning. The augmentation pipeline includes random resizing and cropping to 224×224 pixels, followed by color jittering with a probability of 80% and grayscale conversion with a probability of 20%. Gaussian blur and horizontal flipping were each applied with a probability of 50%. Meta-learning stage During the meta-learning stage, the MoCo-pretrained embedding network was fine-tuned using a ProtoNet under an episodic training framework. Training was performed using SGD, with a learning rate of 0.0001, momentum of 0.9, and weight decay of 0.0005. The learning rate decayed by a factor of 0.5 every 10 epochs, and the training proceeded for a total of 200 epochs. In this stage, the temperature parameter β, as defined in Eq. (4) for the softmax-based distance metric was set to 0.5. Each episode included 15 query samples, and the few-shot tasks were constructed to align with the evaluation setting described in Section 3.2. Evaluation protocols Model performance was evaluated following the standard few-shot learning protocol, using the commonly adopted 5-way 1-shot and 5-way 5-shot settings. In each episode, the model was provided with a support set consisting of N×K labeled samples, where N=5 and K=1 for 5-way 1-shot, and K=5 for 5-way 5-shot. The model was then evaluated on a query set containing 15 images per class. Classification accuracy was computed based on the model's predictions on the query set. A total of 10,000 episodes were randomly sampled from the meta-test dataset, and the average classification accuracy across all episodes was used as the evaluation metric. To assess the statistical robustness of the results, 95% confidence intervals were calculated using the standard error of the mean across episodes, as defined below:(7)CI=x¯±1.96×sn,where x¯ denotes the mean accuracy, s is the standard deviation across episodes, and n is the number of episodes. The value 1.96 is the z-score corresponding to a 95% confidence level under the standard normal distribution. Confidence intervals are reported alongside the average accuracy to account for performance variability arising from random episode sampling and to enable fairer comparisons between methods. Experimental design To comprehensively evaluate the proposed MoCoProto framework, a series of experiments was designed to examine its effectiveness from multiple perspectives. First, different combinations of supervised learning, self-supervised learning, and meta-learning were compared to clarify the contribution of each learning stage. Second, the number of self-supervised pretraining epochs was varied from 100 to 1200 to analyze the effect of pretraining duration on downstream few-shot classification performance. Third, MoCoProto was evaluated under different shot settings, ranging from 5-shot to 30-shot, to assess its scalability under less constrained few-shot scenarios and to examine the trade-off between classification performance and labeling cost. Fourth, different unlabeled image selection strategies were compared to investigate how the composition and diversity of pretraining data influence representation quality. Finally, MoCoProto was compared with representative benchmark models to evaluate its overall effectiveness relative to existing few-shot learning approaches. Results and discussions Pretraining and meta-learning stages This study proposed a two-stage learning framework that combines self-supervised pretraining with meta-learning for few-shot classification. To quantitatively assess the contribution of each learning stage to final classification performance, six experimental configurations were designed by varying the use of pretraining and meta-learning, as well as the type of pretraining method. Consistent with the framework described in Sections 2.2, 2.2.1.2, all configurations used ResNet-50 as the encoder architecture to ensure a fair comparison, and the final evaluation was conducted using the same ProtoNet-based inference procedure. Specifically, for each meta-test episode, class prototypes were computed from the embedded support samples, and query samples were classified according to their distances to these prototypes. The configurations differed only in whether supervised pretraining, self-supervised pretraining, episodic meta-training, or their combinations were applied to the encoder. To align with the prevailing two-stage framework commonly adopted in recent few-shot learning research, this study independently evaluated the effects of supervised and self-supervised pretraining when combined with meta-learning, instead of jointly utilizing both. Supervised pretraining followed the training scheme and hyperparameters adopted in the FEAT method [53]. Table 1 summarizes the 5-way 1-shot and 5-way 5-shot classification accuracies for each configuration. In Table 1, SL, SSL, and Meta denote supervised learning, self-supervised learning, and meta-training, respectively.Table 1Performance under different pretraining and meta-learning combinations.Table 1CaseSLSSLMeta5-Way 1-Shot5-Way 5-Shot(a)22.94 ± 0.1124.53 ± 0.11(b)✓34.87 ± 0.1556.52 ± 0.16(c)✓34.23 ± 0.1655.39 ± 0.17(d)✓24.16 ± 0.1131.18 ± 0.13(e)✓✓36.03 ± 0.1657.29 ± 0.16(f)✓✓49.33 ± 0.2170.13 ± 0.16 Table 1Performance under different pretraining and meta-learning combinations.Table 1CaseSLSSLMeta5-Way 1-Shot5-Way 5-Shot(a)22.94 ± 0.1124.53 ± 0.11(b)✓34.87 ± 0.1556.52 ± 0.16(c)✓34.23 ± 0.1655.39 ± 0.17(d)✓24.16 ± 0.1131.18 ± 0.13(e)✓✓36.03 ± 0.1657.29 ± 0.16(f)✓✓49.33 ± 0.2170.13 ± 0.16 Performance under different pretraining and meta-learning combinations. Case (a) serves as a lower-bound baseline in which none of the three training stages was applied. In this configuration, the ResNet-50 encoder was randomly initialized, and the model was directly evaluated on meta-test episodes using the ProtoNet-based inference procedure described above. Therefore, the near-random accuracies of 22.94% and 24.53% reflect the limited discriminative ability of a randomly initialized embedding network in 5-way classification tasks. Cases (b) and (c) applied only supervised and self-supervised pretraining, respectively, achieving comparable accuracies of 34.87% and 34.23% in the 1-shot setting, and 56.52% and 55.39% in the 5-shot setting. Despite the absence of meta-training, both approaches significantly outperformed the baseline Case (a), demonstrating the effectiveness of pretraining. Notably, the results of Case (c) suggest that self-supervised pretraining can yield representation quality comparable to supervised learning, even without labeled data. In contrast, Case (d), which applied meta-training without any form of pretraining, achieved only 24.16% and 31.18%, comparable to the baseline. These findings indicate that meta-training alone is insufficient for strong performance without effective feature representations, underscoring the importance of pretraining. While Cases (b) and (c) showed similar performance, a clear gap emerged when meta-training was incorporated. Case (f), which combined SSL with meta-training, achieved 49.33% and 70.13% accuracy in the 1-shot and 5-shot settings, significantly outperforming Case (e), which combined supervised learning with meta-learning. Case (e) showed minimal improvement over Case (b), suggesting that supervised pretraining offers limited benefit for meta-learning when only a small amount of labeled data is available. These results highlight that self-supervised pretraining on large-scale unlabeled data facilitates the learning of robust and generalizable visual representations, which not only provide strong performance on their own but also support the learning of more discriminative and transferable features when combined with meta-learning. Overall, the findings demonstrate that pretraining is essential for effective few-shot learning and that combining SSL with meta-learning offers a highly efficient strategy in label-scarce scenarios. Pretraining epochs MoCoProto employs MoCo-based SSL to pretrain the embedding network. While in general SSL benefits from longer training durations, often leading to improved performance, the extent of this improvement and the point of convergence may vary depending on the dataset and the downstream task. The effect of pretraining duration on the final few-shot classification performance was investigated by varying the number of pretraining epochs from 100 to 1200 and evaluating the resulting performance. Table 2 reports the 5-way 1-shot and 5-way 5-shot classification accuracies for each pretraining epoch.Table 2Classification accuracy across pretraining epochs.Table 2Epoch5-Way 1-Shot5-Way 5-Shot10041.26 ± 0.1865.75 ± 0.1720040.97 ± 0.1865.99 ± 0.1730042.31 ± 0.1967.50 ± 0.1640041.03 ± 0.1867.28 ± 0.1650043.86 ± 0.1967.91 ± 0.1760045.10 ± 0.1969.72 ± 0.1670046.99 ± 0.2069.91 ± 0.1780049.33 ± 0.2170.13 ± 0.1690042.55 ± 0.1967.50 ± 0.16100043.45 ± 0.1967.72 ± 0.17110043.24 ± 0.1968.40 ± 0.17120045.75 ± 0.2069.45 ± 0.16 Table 2Classification accuracy across pretraining epochs.Table 2Epoch5-Way 1-Shot5-Way 5-Shot10041.26 ± 0.1865.75 ± 0.1720040.97 ± 0.1865.99 ± 0.1730042.31 ± 0.1967.50 ± 0.1640041.03 ± 0.1867.28 ± 0.1650043.86 ± 0.1967.91 ± 0.1760045.10 ± 0.1969.72 ± 0.1670046.99 ± 0.2069.91 ± 0.1780049.33 ± 0.2170.13 ± 0.1690042.55 ± 0.1967.50 ± 0.16100043.45 ± 0.1967.72 ± 0.17110043.24 ± 0.1968.40 ± 0.17120045.75 ± 0.2069.45 ± 0.16 Classification accuracy across pretraining epochs. As shown in Table 2 and Fig. 5(a), the downstream few-shot performance generally improved as the number of pretraining epochs increased from 100 to 800. In the 1-shot setting, the accuracy increased from 41.26% at 100 epochs to 49.33% at 800 epochs, while in the 5-shot setting, the accuracy increased from 65.75% to 70.13%. Both 1-shot and 5-shot accuracies reached their highest values at 800 epochs. After 800 epochs, the performance dropped at 900 epochs and then gradually recovered, but it did not exceed the performance obtained at 800 epochs. Specifically, the 1-shot accuracy decreased to 42.55% at 900 epochs and recovered to 45.75% at 1200 epochs, while the 5-shot accuracy decreased to 67.50% at 900 epochs and recovered to 69.45% at 1200 epochs. These results indicate that extending self-supervised pretraining beyond 800 epochs did not lead to further improvement in downstream few-shot classification performance under the evaluated settings.Fig. 5(a)Performance variation with pretraining epochs. Performance variation with pretraining epochs. To further examine the convergence behavior of the self-supervised pretraining process, the contrastive loss curve was also visualized, as shown in Fig. 5(b). The loss decreased rapidly during the early stage of training and then continued to decline more gradually as training proceeded, indicating stable optimization of the MoCo pretraining objective. However, the downstream few-shot accuracy did not improve monotonically with the contrastive loss after 800 epochs. This suggests that further optimization of the instance-level contrastive objective does not necessarily translate into better downstream episodic classification performance. Therefore, 800 epochs was selected because it achieved the best downstream 1-shot and 5-shot performance among the evaluated pretraining durations.Fig. 5(b)Self-supervised learning contrastive loss curve. Self-supervised learning contrastive loss curve. Shot count Although this study adopts the standard evaluation settings of 5-way 1-shot and 5-way 5-shot classification tasks, real-world applications often involve less constrained scenarios in which more than 10 labeled support samples per class are available. To analyze how the number of shots affects classification performance, the proposed MoCoProto was evaluated with progressively increasing shot counts of 5, 10, 15, 20, 25, and 30. Table 3 presents the classification accuracy for each shot configuration, revealing a consistent improvement as the number of shots increases. This pattern is further illustrated in the visualization provided in Fig. 6.Table 35-way classification accuracy across different shot counts.Table 3Shot5-Way Accuracy570.13 ± 0.161074.60 ± 0.151576.26 ± 0.142077.29 ± 0.142577.62 ± 0.143078.73 ± 0.13Fig. 6Performance variation across different shot counts. Table 35-way classification accuracy across different shot counts.Table 3Shot5-Way Accuracy570.13 ± 0.161074.60 ± 0.151576.26 ± 0.142077.29 ± 0.142577.62 ± 0.143078.73 ± 0.13 5-way classification accuracy across different shot counts. Performance variation across different shot counts. In the 5-shot setting, MoCoProto achieved an accuracy of 70.13%, which increased significantly to 74.60% in the 10-shot setting. As the number of shots increased to 15 and 20, the accuracy further improved to 76.26% and 77.29%, respectively. At 25-shot and 30-shot, the model achieved accuracies of 77.62% and 78.73%, respectively, indicating a saturation trend with diminishing performance improvements beyond 20 shots. Additionally, as the number of shots increased, the confidence interval gradually decreased from ±0.21 to ±0.13. This indicates that having more labeled support samples not only improves classification accuracy but also enhances the stability and consistency of predictions across few-shot tasks. The 10-shot to 30-shot settings in this experiment are intended to examine support-size scalability rather than to serve as standard few-shot benchmarks. Although there is no universally fixed numerical boundary between few-shot learning and standard supervised learning, increasing the number of support samples gradually moves the task away from the most restrictive few-shot regime. Therefore, the gains observed at higher shot counts should be interpreted as the combined effect of prototype-based adaptation and the increased availability of labeled support samples. Because the support samples were used only to compute class prototypes rather than to train a conventional supervised classifier, these results should be interpreted as showing how MoCoProto scales with the number of support samples under low-data conditions, rather than as evidence of a transition to a standard supervised learning setup. These results demonstrate that MoCoProto can learn strong feature representations even with a small number of labeled support examples and that increasing the number of support samples facilitates the learning of more discriminative and fine-grained class representations. Furthermore, the diminishing performance gains observed with increasing shot counts offer a practical basis for determining an optimal number of shots by considering the trade-off between model performance and labeling cost. Image selection strategies To evaluate the impact of unlabeled image selection strategies on embedding quality during the SSL stage, pretraining datasets were constructed by selecting 100,000 images from the full unlabeled image pool using each of the three strategies described in Section 2.3. Each dataset was then used for self-supervised pretraining, followed by evaluation on downstream few-shot classification tasks. The results are presented in Table 4.Table 4Few-shot classification accuracy under different image selection strategies.Table 4Strategy5-Way 1-Shot5-Way 5-ShotRandom35.51 ± 0.1656.19 ± 0.16Maximum diversity37.49 ± 0.1758.63 ± 0.17Proportional36.55 ± 0.1757.84 ± 0.16Total49.33 ± 0.2170.13 ± 0.16 Table 4Few-shot classification accuracy under different image selection strategies.Table 4Strategy5-Way 1-Shot5-Way 5-ShotRandom35.51 ± 0.1656.19 ± 0.16Maximum diversity37.49 ± 0.1758.63 ± 0.17Proportional36.55 ± 0.1757.84 ± 0.16Total49.33 ± 0.2170.13 ± 0.16 Few-shot classification accuracy under different image selection strategies. The random selection strategy, which samples images uniformly at random after duplicate removal, yielded the lowest accuracy in both the 1-shot and 5-shot settings, achieving 35.51% and 56.19%, respectively. These results suggest that naive random sampling increases the likelihood of including visually redundant or less informative samples, thereby failing to provide sufficient visual diversity for effective representation learning. The proportional selection strategy, which samples images in proportion to cluster sizes to reflect the overall data distribution, achieved improved performance compared to random selection. While this approach helps preserve the distributional structure of the original dataset, it may fail to capture sufficient visual diversity in smaller clusters, which can limit its ability to improve performance. In contrast, the maximum diversity selection strategy, designed to broadly cover the feature space by selecting diverse representative images, achieved the highest accuracy among the three. These findings indicate that promoting visual diversity during self-supervised pretraining is more effective for enhancing representation quality and downstream performance than preserving the original data distribution. For comparison, pretraining with the entire unlabeled dataset outperformed all three selection strategies, achieving 49.33% and 70.13% accuracy in the 1-shot and 5-shot settings, respectively. These results suggest that leveraging a sufficiently large volume of unlabeled data remains the most effective approach for improving downstream performance. Nevertheless, in resource-constrained environments where computational cost or training time is limited, the maximum diversity selection strategy offers a practical balance between representation quality and computational efficiency. Comparison with benchmark models To evaluate the effectiveness of the proposed method, a comparative experiment was conducted using several representative meta-learning algorithms as benchmark models. These baseline methods can be broadly categorized into three distinct approaches based on their training paradigms. The first approach includes classical meta-learning methods such as MatchNet [26], MAML [54], and ProtoNet, which rely solely on episodic training without any form of supervised or self-supervised pretraining. The second approach comprises Meta-Baseline [55], FEAT, and QSFormer [56], which first perform supervised pretraining on base classes using standard classification objectives and then apply meta-learning to few-shot tasks. The third approach, which includes the method proposed by Chen et al. [42] and that proposed in this study, leverages SSL to pretrain the embedding network prior to meta-learning. For supervised pretraining in the second approach, the entire meta-training dataset was used, whereas in the third approach, an unlabeled dataset constructed in this study was utilized for SSL. All benchmark methods were implemented with hyperparameter settings consistent with those reported in their original publications. Evaluation was conducted on the IP102 dataset using the 5-way 1-shot and 5-way 5-shot classification tasks, following the evaluation protocol described in Section 3.2. Table 5 summarizes the classification accuracy and backbone architecture used for each method.Table 5Few-shot classification accuracy of the proposed model and benchmark methods.Table 5ModelBackbone5-Way 1-Shot5-Way 5-ShotMatchNet [26]4 Conv27.13 ± 0.1532.04 ± 0.14MAML [54]4 Conv31.17 ± 1.6744.01 ± 0.90ProtoNet [46]4 Conv32.43 ± 0.1643.52 ± 0.17Meta-Baseline [55]ResNet1242.54 ± 0.2159.26 ± 0.19FEAT [53]ResNet5045.70 ± 0.1961.63 ± 0.17QSFormer [56]ResNet12+Transformer40.26 ± 0.2655.15 ± 0.24Chen et al. [42]AmdimNet41.51 ± 0.1763.34 ± 0.16MoCoProto (Ours)ResNet5049.33 ± 0.2170.13 ± 0.16 Table 5Few-shot classification accuracy of the proposed model and benchmark methods.Table 5ModelBackbone5-Way 1-Shot5-Way 5-ShotMatchNet [26]4 Conv27.13 ± 0.1532.04 ± 0.14MAML [54]4 Conv31.17 ± 1.6744.01 ± 0.90ProtoNet [46]4 Conv32.43 ± 0.1643.52 ± 0.17Meta-Baseline [55]ResNet1242.54 ± 0.2159.26 ± 0.19FEAT [53]ResNet5045.70 ± 0.1961.63 ± 0.17QSFormer [56]ResNet12+Transformer40.26 ± 0.2655.15 ± 0.24Chen et al. [42]AmdimNet41.51 ± 0.1763.34 ± 0.16MoCoProto (Ours)ResNet5049.33 ± 0.2170.13 ± 0.16 Few-shot classification accuracy of the proposed model and benchmark methods. As shown in Table 5, MoCoProto achieved the highest accuracy, recording 49.33% in the 5-way 1-shot and 70.13% in the 5-way 5-shot settings. These represent performance improvements of approximately 3.63 and 6.79, respectively, over the strongest existing baselines. Classical meta-learning approaches such as MatchNet, MAML, and ProtoNet achieved significantly lower classification accuracy than other approaches, due to the limited representational capacity learned through episodic training. In contrast, approaches such as Meta-Baseline, FEAT, and QSFormer, which employed supervised pretraining, achieved significantly higher accuracy than the first approach by learning more robust feature representations. This observation aligns with recent findings suggesting that supervised pretraining prior to meta-learning can enhance overall performance. Among the supervised pretraining-based methods, FEAT achieved the highest 1-shot accuracy, whereas QSFormer underperformed Meta-Baseline despite incorporating Transformer-based components. This result suggests that the benefit of Transformer-based components depends not only on architectural complexity, but also on how they are integrated into the few-shot learning process. In FEAT, the Transformer is used for task-specific set-to-set embedding adaptation, which directly refines support and query embeddings within each episode. This mechanism may be particularly beneficial in the 1-shot setting, where the support information is extremely limited and task-specific adaptation can improve the discriminability of embeddings. In contrast, QSFormer uses Transformer-based modules to jointly model query-support representations and metric learning. However, this higher architectural complexity did not lead to better performance on IP102. Given the fine-grained nature of pest classification and the limited support samples available in each episode, this result suggests that stable feature representations and appropriate task-level adaptation may be more important than architectural complexity alone. MoCoProto, which integrates SSL with meta-learning, outperformed all benchmark models. The method proposed by Chen et al. [42] also demonstrated competitive performance, surpassing all benchmark models except FEAT in the 1-shot setting. These results suggest that self-supervised pretraining on unlabeled data is effective for learning discriminative representations, thereby improving meta-learning performance when labeled data for base classes is limited. Furthermore, MoCoProto outperformed the method proposed by Chen et al. [42], despite using a smaller ResNet-50 backbone with fewer parameters than the AmdimNet employed in their approach. To further examine whether the performance gain of MoCoProto could be attributed simply to the use of ResNet50, additional control experiments were conducted by replacing the original backbones of MatchNet and Meta-Baseline with ResNet50. In both cases, the backbone replacement did not improve few-shot performance, indicating that the gain of MoCoProto cannot be explained solely by increased backbone capacity. These findings indicate that MoCo-based self-supervised visual representation learning is not only more effective than the AMDIM approach but also enables more effective use of the backbone for few-shot classification. The results demonstrate that MoCoProto outperforms conventional meta-learning approaches in terms of labeling efficiency, representational quality, and model effectiveness. These advantages highlight the potential of MoCoProto for deployment in real-world scenarios where labeled data is scarce and computational resources are limited, such as in embedded systems or mobile applications. Moreover, the findings provide empirical support for the broader applicability of self-supervised pretraining as a practical and scalable solution to enhance few-shot learning across diverse domains. Limitations and future directions While the proposed framework demonstrates strong performance, certain aspects remain open for future work. First, all experiments were conducted using the IP102 dataset, focusing exclusively on the agricultural pest domain. Although the proposed framework is designed to be domain-agnostic, further validation is required to confirm its generalizability across other domains. Additionally, while MoCoProto adopts a more compact backbone than previous methods, the model size remains relatively large for real-world deployment, and the self-supervised training process is computationally intensive. In practical applications, improving efficiency may require not only lightweight backbone architectures but also more efficient self-supervised learning strategies and reduced-epoch pretraining settings. Another limitation is that, although no overlap was found between the SSL dataset and the meta-test classes of IP102, some overlap remained with the meta-training and meta-validation classes. A stricter evaluation protocol that entirely excludes pest classes overlapping with the meta-learning stage from the SSL dataset would provide a more rigorous assessment. However, such a setting would also reduce the size and taxonomic coverage of the current SSL dataset. In addition, although IP102 contains images of insect pests at different life stages, such as egg, larva, pupa, and adult, it does not provide explicit life-stage labels for each image. Therefore, stage-wise performance analysis could not be conducted in the present study and should be investigated in future work using datasets with additional life-stage annotations. Future work will address these challenges through architectural simplification and improved training efficiency to enable faster pretraining and practical deployment in resource-constrained environments. In addition, to evaluate the framework's scalability and generalizability, MoCoProto will be evaluated across a broader range of domains. In particular, domains involving relatively stationary objects are expected to facilitate the collection of diverse, high-quality unlabeled data, thereby enabling more effective self-supervised pretraining. Future work should also investigate stricter class-level separation between the SSL dataset and the meta-learning stage as more non-overlapping unlabeled agricultural images become available. Finally, future research will extend the framework to domain-adaptive few-shot learning tasks and further explore lightweight models suitable for real-time and on-device applications. Conclusions This study proposed MoCoProto, a two-stage learning framework that integrates MoCo-based self-supervised pretraining with meta-learning for few-shot pest image classification. Evaluation of each learning stage confirmed that combining self-supervised pretraining with meta-learning significantly enhances classification performance. In addition, the use of a large-scale unlabeled agricultural dataset and comparative analysis of various image selection strategies underscored the importance of dataset scale and diversity in effective self-supervised training. Finally, MoCoProto outperformed several benchmark meta-learning models on the IP102 dataset, achieving 49.33% accuracy in the 5-way 1-shot and 70.13% in the 5-way 5-shot settings, demonstrating strong performance and practical potential in label-scarce scenarios. Author contributions Dong Jin: Conceptualization, Methodology, Software, Investigation, Writing- Original draft preparation. Helin Yin: Methodology, Investigation, Validation, Writing - Reviewing and Editing. Xianghua Piao: Investigation, Validation. Yeong Hyeon Gu: Writing - Reviewing and Editing, Supervision, Project administration, Funding acquisition. Data availability The IP102 dataset used for meta-learning is an existing publicly available dataset. The dataset used for self-supervised learning is available from the corresponding author upon reasonable request. Funding This work was carried out with the support of "Research Program for Agriculture Science and Technology Development (Project No. RS-2026-25505437)", Rural Development Administration, Republic of Korea. Declaration of competing interest The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.