Original Research
Frontiers in Agronomy ·
Volume 8 - 2026 | https://doi.org/10.3389/fagro.2026.1918022
A Vision Transformer-based few-shot learning approach for leaf disease classification
- Nandhini Chokkalingam1
- Lakshmi Priya G1,2
- Chanthini Baskar1*corresponding author
- L Sumalatha3
- 1School of Electronics Engineering, Vellore Institute of Technology, Chennai, India
- 2Centre for Advanced Materials and Innovative Technologies, Vellore Institute of Technology, Chennai, India
- 3Department of Computer Science and Engineering, Jawaharlal Nehru Technological University, Kakinada, Andhra Pradesh, India
Abstract
Plant disease detection is often hindered by a lack of large, annotated image datasets, a key limitation for standard deep learning. Few-shot learning (FSL) addresses this challenge by transferring a learned comparison strategy from a data-rich source domain to a new, low-data target task. This paper investigates the robustness and limitations of this knowledge transfer process. A critical “metric domain gap” is first identified, demonstrating that an FSL model’s comparison strategy can fail catastrophically when meta-trained on a visually dissimilar source domain, even when paired with a state-of-the-art feature extractor. To resolve this, a synergistic training strategy is proposed, which combines in-domain meta-learning of a relation network with simultaneous fine-tuning of a Vision Transformer (ViT) backbone. This method ensures that both the feature representation and the similarity metric are co-adapted for the target domain. The final model, ViTRelNet, demonstrates the success of this approach, achieving a robust 87.38%, 92.72%, and 91.79% accuracy on unseen Jamun, Guava, and Cassava disease benchmarks using only five examples per class, effectively resolving the data scarcity challenge for this task.
Keywords
1 Introduction
Plant diseases pose one of the greatest threats to global food security, causing up to 40% loss in crop production annually and jeopardizing the livelihoods of millions worldwide. In recognition of this urgent challenge, the United Nations declared 2020 as the International Year of Plant Health (Paroda, 2023). Effective plant health management is more important than ever as the world’s population is expected to exceed 10 billion by 2050, and food production will need to rise by approximately 60% to keep up with the demand (FAO, 2024; Ristaino et al., 2021). The leaves of plants serve as the primary sites of photosynthesis, converting sunlight into energy necessary for the growth and development of fruits and seeds. When leaf diseases are caused by fungal, bacterial, or viral pathogens, it leads to significant declines in both the quantity and quality of agricultural output.
The field of automated plant leaf disease classification has evolved through three broad paradigms, each addressing the limitations of its predecessor. Early approaches relied on handcrafted feature extraction, where leaf images were preprocessed and segmented using thresholding and clustering algorithms such as K-means to isolate diseased lesions from healthy tissue (Mukherjee et al., 2025). Color, texture, and shape descriptors were subsequently fed into classical classifiers including support vector machines, K-nearest neighbors, and artificial neural networks (Javidan et al., 2023; Jamjoom et al., 2023). While effective under controlled conditions, these pipelines were highly sensitive to variations in illumination and imaging conditions, and their performance was fundamentally constrained by the quality of hand-engineered features.
With the advent of deep learning, a paradigm shift was introduced to the field of leaf disease classification. Convolutional neural networks (CNNs) eliminated the need for manual feature engineering by learning discriminative representations directly from raw pixel data, with transfer learning enabling pretrained models to be fine-tuned for disease-specific tasks (ManNepalli et al., 2024). Architectures such as VGG, ResNet, Inception, and DenseNet established strong baselines for leaf disease classification (Ding et al., 2022), while lightweight variants including MobileNet and EfficientNet extended deployment to resource-constrained devices such as smartphones and drones, enabling real-time in-field diagnosis (Sagheer et al., 2025). Beyond classification, object detection models such as YOLO and faster R-CNN enabled spatial localization of disease regions (Mamun et al., 2025; Haritha et al., 2022), and pixel-level semantic segmentation models such as U-Net allowed quantification of disease severity. Despite these advances, all these approaches share a fundamental dependency on large, well-annotated datasets, a requirement that is difficult to satisfy for rare, emerging, or geographically specific plant diseases.
Recent research has attempted to address this data dependency through architectural innovation. Hybrid models combining Vision Transformers (ViTs) with CNN classification heads have been proposed to leverage the global attention mechanism of transformers alongside the local feature extraction strengths of CNNs (Vallabhajosyula et al., 2024). Further modifications to transformer blocks—including soft split token embedding, inception-like structures, and replacement of standard multilayer perceptron (MLP) modules with transfer learning blocks—have demonstrated improved feature representation for fine-grained disease classification (Yu et al., 2023; Srivastava et al., 2025). Complementary efforts using generative data augmentation, such as two-stage GANs that synthesize realistic disease patterns onto healthy leaf images, and neural architecture search (NAS) techniques for automated ViT optimization, have been proposed to alleviate data scarcity (Singh et al., 2024; Ghosh et al., 2025). However, these approaches introduce significant computational overhead and rely on the availability of sufficient base data for generative model training, making them impractical in truly low-data scenarios.
Few-shot learning (FSL) has emerged as a more direct and principled solution to the data scarcity problem, enabling models to classify new disease categories from only a handful of labeled examples. Parameter-efficient adaptation of large pretrained models such as PlantCaFo using adapter modules has demonstrated strong scalability by freezing most of the backbone and training only a small set of task-specific parameters (Jiang et al., 2025; Xu et al., 2024). Attention-based architectural additions designed to suppress complex field background noise—including MAFDE-DN4 (Multi-scale Attention Fusion and Discriminative Enhancement-based Deep Nearest Neighbor Neural Network) and PMF+FA (pretraining, meta-learning, fine-tuning with feature attention)—have further improved FSL robustness under challenging imaging conditions (Zhao et al., 2024; Rezaei et al., 2024). A critical baseline study established the viability of combining frozen ViT or ResNet backbones with prototypical networks and fixed Euclidean distance metrics for this domain, demonstrating that simple metric-learning frameworks can achieve competitive accuracy when the feature extractor is sufficiently powerful (Naveed et al., 2025).
However, a significant challenge emerges in cross-domain FSL scenarios, where the source and target datasets differ in visual characteristics, imaging conditions, and disease morphology. It has been observed that existing FSL methods, including the frozen backbone and similarity metric variants, demonstrate a drastic performance drop when applied to novel domains that were not seen during meta-training (Yang et al., 2024). This demonstrates a major “metric domain gap”: a highly effective feature extractor can achieve a perfectly discriminable embedding space, but a learnable similarity metric, even if trained on a semantically very different source domain, may not be able to effectively exploit it. This problem has not been given due importance in the plant disease FSL literature, where most methods are tested on the held-out classes of the source dataset itself.
This paper addresses these challenges directly by providing a deep methodological analysis of the few-shot learning process itself. The key contributions are:
- Identifying that a learnable similarity metric can be a primary point of failure in cross-domain scenarios.
- A synergistic training strategy is proposed that simultaneously fine-tunes a Vision Transformer backbone and meta-learns a relation network in domain data, proving that co-adapting both feature and metric spaces is essential for optimal performance.
2 Dataset description
This work employs the publicly available PlantVillage dataset, which contains a comprehensive set of plant leaves captured under controlled conditions for training the model. The dataset is designed to facilitate the development of an automated plant disease classification. This dataset consists of many images of a wide variety of crops—apple, blueberry, cherry, corn, grape, orange, peach, bell pepper, potato, raspberry, soybean, squash, strawberry, and tomato—and comprises 38 classes, representing 14 crop species and various diseases with approximately 54,305 images (Hughes and Salathé, 2015). The Cassava leaf dataset was collected from the Mendeley database, which has three classes comprising field images from various agricultural fields of western Tamil Nadu, India, with a size of 512 × 512, acquired using a handheld camera (Divyanth et al., 2021). The images of the Guava and Jamun datasets were collected from A Database of Leaf Images: Practice towards Plant Conservation with Plant Pathology, where images were taken using a Nikon D5300 camera with performance timing for JPEG in a single-shot mode (seconds/frame, max resolution) = 0.58 and for RAW+JPEG = 0.63 in a closed environment. The images were captured with an 18–55 mm lens with sRGB colour, 24-bit depth, 2 units of resolution, 1,000 ISO, and no flash (Chouhan et al., 2019). These target datasets were selected because they do not overlap with any classes in the training PlantVillage dataset, providing a rigorous cross-domain test, and they span both binary (Guava, Jamun) and multiclass (Cassava) scenarios, enabling evaluation across varying task difficulties. Figure 1 shows the labeled images of the PlantVillage Guava, Jamun, and Cassava datasets.

3 Methodology
The proposed methodology for plant disease classification leverages a fine-tuned ViT within an FSL framework. The overall architecture is designed to address the metric domain gap—the failure of a learnable similarity metric when trained on a visually dissimilar source domain by co-adapting both the feature extractor and the relation module on in-domain data (Figure 2). The following subsections describe each component in detail.

3.1 Episodic task construction
The PlantVillage source dataset is structured into episodic learning tasks following the N-way K-shot protocol. Each episode is constructed by randomly sampling N=10 disease classes from the available 38 classes, drawing K=5 support images per class, and a query set of Q=10 query images per class, yielding a 10-way 5-shot configuration per training episode. A total of 2,500 training episodes were executed (Table 1). This episodic structure trains the model to generalize from minimal samples by simulating the low data at each training episode.
Table 1. Summary of task construction parameters for meta-training and meta-testing.
| Parameter | Meta-training (PlantVillage) | Meta-testing (Guava) | Meta-testing (Jamun) | Meta-testing (Cassava) |
|---|---|---|---|---|
| N (ways) | 10 | 2 | 2 | 3 |
| K (shots) | 5 | 5 | 5 | 5 |
| Q (queries/class) | 10 | 10 | 10 | 10 |
| Episodes | 2,500 | 300 | 300 | 300 |
3.2 Feature extractor: Vision Transformer backbone
The vit_base_patch16_224 Vision Transformer (ViT-B/16) pretrained on ImageNet is used as a feature extractor. The model accepts the input image of size 224 × 224 × 3, divided into non-overlapping patches of size 16 × 16, outputs a sequence of 196 patch tokens plus a classification (CLS) token. The CLS token embedding a 768-dimensional vector is extracted as the image representation for all computations.
For fine-tuning the Vision Transformer, the last three transformer encoder blocks (blocks 10, 11, and 12 out of 12 total) are unfrozen, making 21,265,152 parameters trainable out of 85,798,656 total and leaving the remaining 9 blocks frozen. This idea is driven by the transfer learning standard principle that lower-level blocks capture low-level features (edges, textures), whereas the upper blocks encode task-specific representations. Fine-tuning of three blocks provides better cross-domain adaptability. Fine-tuning fewer blocks provides better cross-domain adaptation, while unfreezing more blocks led to degraded performance due to catastrophic forgetting of ImageNet-learned representations. The two-layer relation module contributes 393,729 trainable parameters. Both the unfrozen ViT block and relation module together contribute 21,658,881 trainable parameters out of 86,192,385 total (ViT backbone plus relation module), i.e., approximately 25.1% of all parameters are updated during meta-training.
All unfrozen parameters are updated with the Adam optimizer using a learning rate of αθ=1×10−5, while a relation module uses a higher learning rate αϕ=1×10−4 for faster metric adaptation. This differential learning rate scheme prevents the large pretrained backbone from destabilizing during meta-training (Table 2).
Table 2. Complete hyperparameter and implementation configuration.
| Hyperparameter | Value |
|---|---|
| Backbone | ViT-B/16 (vit_base_patch16_224, ImageNet-21k pre-trained) |
| Trainable parameters (ViT + relation model) | 21,658,881/86,192,385 |
| Embedding dimension | 768-d [CLS] token |
| Relation module input | 1,536-d (concat of two 768-d vectors) |
| Relation module hidden | 256 units, ReLU |
| Training episodes | 2,500 |
| N-way K-shot (training) | 10-way 5-shot, 10 queries/class |
| Optimizer | Adam (dual learning rate) |
| ViT learning rate (αθ) | 1×10−5 |
| RelNet learning rate (αϕ) | 1×10−4 |
| Loss function | Mean squared error (MSE) |
| Evaluation episodes | 300 (accuracy)/200 (confusion matrix) |
| Image size | 224 × 224 × 3 |
3.3 Prototype generation
For each episode, a class prototype P<sub>j</sub> is computed for each of the N support classes by averaging the ViT embeddings of all K support images belonging to class j:
Pj= 1K∑k=1KFθ(sj,k).
This work adapts the fine-tune ViT with a relation network architecture: the prototype averaging provides robust and low-variance class representation while the relation module replaces the Euclidean metric with a learned non-linear comparator. Simple mean averaging was selected over weighted or attentive prototype alternatives for two reasons: (i) it has no additional parameters, preserving the few-shot sample efficiency; and (ii) empirical results in the few-shot literature consistently show that averaging is competitive with more complex aggregation for K ≤ 5.
3.4 Relation module
After prototype generation, the embedding of the query image e<sub>x</sub> (768-d) is concatenated with each class prototype P<sub>j</sub> (768-d), resulting in a concatenated pair z<sub>xj</sub> = concat (e<sub>x</sub>, P<sub>j</sub>) of dimension 1,536. This is passed through the relation module, which is a two-layer MLP that acts as a learnable non-linear similarity metric (Figure 3).

- Input layer: 1,536 units (concatenated query-prototype pair).
- Hidden layer: 256 units, ReLU activation.
- Output layer: 1-unit, Sigmoid activation → relation score r<sub>xj</sub> ∈ [0, 1].
A high relation score (r<sub>xj</sub> → 1) implies that the query image x belongs to class j; a score near 0 indicates dissimilarity. No batch normalization or dropout is performed in the relation module, as the small module size and episodic training naturally regularize against overfitting. The original relation network used a CNN as in the metric head to preserve spatial feature maps. In this work, the fine-tuned ViT is used as a feature extractor, which produces token embeddings rather than feature maps, and prototype averaging is used for improving robustness under K≥2. The MLP is an optimum choice for the metric head to operate on 1-D embedding vectors, as it can learn arbitrary non-linear decision boundaries without the spatial inductive bias of convolutions. The two-layer MLP is chosen because i) the ViT already encodes rich semantic representations and ii) a large-layer MLP network has overfitting risk due to a small support set size (K = 5) and limited gradient signal. The lightweight learnable comparator outperforms fixed distance metrics when paired with a powerful feature extractor.
3.5 Loss function and optimization
The mean squared error (MSE) loss function is chosen over cross-entropy loss, which does not fit with the sigmoid-activated similarity score produced by the relation network and binary cross-entropy loss, which produces sharper gradient saturation near the decision boundary and converges slowly during episodic training where relation scores fluctuate across diverse episode configurations. The training model minimizes the MSE loss between the predicted relation score and the binary ground-truth label (1 for matching class, 0 otherwise). All parameters are updated using the Adam optimizer with a learning rate of αθ=1×10−5 for ViT (last three blocks) and αϕ=1×10−4 for the relation module. No learning rate schedule, weight decay, or early stopping was applied, and training ran for a fixed 2,500 episodes. Overfitting is controlled through architecture-level mechanisms rather than regularization techniques: (i) only 3 out of 12 blocks of ViT are unfrozen, which limits the capacity available to memorize the meta-training set; (ii) the relation module is made small with no batch normalization or dropout, since a larger regularized head is unnecessary at this parameter budget and episodic training already re-samples classes every iteration; (iii) each of the 2,500 training episodes draws a fresh random 10-way 5-shot task from the 38 PlantVillage training classes with independent data augmentation (random flip, rotation, color jitter), so the model rarely encounters the same class combination or image twice, which acts as an implicit regularizer; and (iv) the training loss curve shows smooth, monotonic convergence without the divergence or re-increase that would indicate memorization. The small model capacity and a differential learning rate work together to stop the model from overfitting during episodic training.
3.6 Data augmentation and preprocessing
A data augmentation pipeline was applied to all training images to promote robustness and reduce overfitting. The specific parameters are as follows:
- Random horizontal flip: p = 0.5.
- Random rotation: up to ±20° (uniform distribution, fill mode = reflect).
- Color jitter: brightness ∈ [0.8, 1.2], contrast ∈ [0.8, 1.2], saturation ∈ [0.8, 1.2], and hue ∈ [−0.1, 0.1].
- Normalization: ImageNet mean = [0.485, 0.456, 0.406], std = [0.229, 0.224, 0.225].
- Resize: all images resized to 224 × 224 pixels before patch tokenization.
No augmentation was applied during meta-testing to ensure unbiased evaluation of the learned representations. ImageNet mean/std normalization is a fixed input preprocessing step that is applied identically to all the images at meta-training and meta-testing across all four datasets (PlantVillage, Guava, Jamun, Cassava). No additional feature-level normalization is applied, and the raw ViT embeddings are used directly for prototype averaging and relation scoring. The complete training procedure is summarized in Algorithm 1.
Algorithm 1
3.7 Meta-testing
At meta-testing time, the ViT backbone weights are fully frozen—no further gradient updates are applied (Figure 4). For each episode, (i) five support images per class are forwarded through the frozen ViT to extract embeddings, (ii) class prototypes are computed, (iii) query embeddings are concatenated with each prototype and scored by the trained relation module, and (iv) the predicted class is determined by argmax over the N relation scores.

4 Results and discussion
This section represents a comprehensive evaluation of the proposed ViTRelNet model, a synergistic combination of fine-tuned Vision Transformer as the backbone and a meta-learned relation module. To assess the model’s generalization, the model was evaluated on three completely unseen target datasets: Guava (two-way, binary), Jamun (two-way, binary), and Cassava (three-way, multiclass). Performance is analyzed through the model’s overall episodic accuracy, training loss, confusion matrix, t-SNE feature space visualization, per-class metrics, and K-shot robustness. This analysis substantiates that the co-adaptation of both feature extractor and similarity metric is essential for cross-domain few-shot classification.
4.1 Training accuracy
The fine-tuned ViTRelNet (Vision Transformer + Relation Network) model was evaluated across 300 episodic trials on three unseen cross-domain target datasets (Figure 5). On the Guava dataset, it achieved an average accuracy of 92.72% (± 0.63%) with consistent performance in the 80%–100% range and lower episodic variance of 5.54%. On the Cassava dataset, the model attained 91.79% (± 0.54%), the tightest confidence interval with a 33.33% random baseline, ensuring that the fine-tuned embedding space effectively separates all three disease categories despite the increased classification complexity. On the Jamun dataset, the model achieved an accuracy of 87.38% (± 0.84%) with a higher episodic variance (7.45%) attributable to the fine-grained morphological similarity between diseased and healthy Jamun leaves rather than any systematic failure, as the running average remained stable across all 300 episodes. Across all three datasets, the absence of any warm-up period or performance drift from the first episode onward confirms that the synergistic co-adaptation of the ViT backbone and Relation Network produces immediately transferable, domain-robust representations even when evaluated on entirely unseen crop species with only five labeled examples per class.

4.2 Training loss
The loss curve shows the meta-training of the fine-tuned ViT + Relation Module over 2,500 episodes (Figure 6). The loss exhibits a rapid initial descent from 0.10 to approximately 0.02 within the first 500 episodes, followed by gradual refinement and full convergence to near-zero loss by episode 2,000, confirming stable joint optimization of the feature extractor and the learnable similarity metric without overfitting.

4.3 Confusion matrix
The confusion matrices for all three datasets confirm balanced and reliable classification performance (Figure 7). The model achieves 93.3% recall for the diseased class and 91.9% for the healthy class on the Guava dataset, with the misclassification errors evenly distributed between the two classes. For the Cassava three-way task, the recall values for each class are packed tightly between 93.3%, 91.5%, and 94.8% for the Cassava Blight, Cassava Mosaic, and Healthy classes, respectively, with errors distributed between 2.4% and 4.7% on the off-diagonal, reflecting the visual similarity between the two disease classes. For the Jamun dataset, the model correctly classifies 88.2% of diseased and 86.6% of healthy leaves, with a slightly larger false-negative rate for the healthy class (13.5%) due to the fine-grained morphological similarity between diseased and healthy Jamun leaves in the early stages. These misclassification patterns identify two failure modes—fine-grained morphological similarity in Jamun and visual overlap between disease patterns in Cassava—so the region-aware feature learning and higher shot training are promising directions for future improvement. In all cases, the high values on the diagonals of the normalized confusion matrices demonstrate that misclassification errors are limited and stochastic.

4.4 t-SNE feature space visualization
The t-distributed stochastic neighbor embedding (t-SNE) visualizations confirm that the fine-tuned ViTRelNet produces well-structured, discriminative embeddings across all three unseen datasets (Figure 8). On Guava, the diseased and healthy clusters occupy largely distinct regions with minor overlap. On Cassava, the Healthy class forms a tight, well-isolated cluster, while a significant overlap is found between the “Blight” and “Mosaic” disease clusters for the Cassava dataset corresponds directly to misclassifications present in its confusion matrix. On Jamun, a greater interclass overlap in the central region reflects the fine-grained morphological similarity between disease states, consistent with the higher episodic variance observed for this dataset.

4.5 Per-class metrics
The per-class metrics show the same consistency across all three datasets (Figure 9). On the Guava dataset, the diseased class has a precision of 92.0%, a recall of 93.3%, and an F1 of 92.7%, whereas the Healthy class has a precision of 93.2%, a recall of 91.9%, and an F1 of 92.5%, with the average accuracy being 92.6%—showing almost equal discrimination potential for both classes. On the Cassava dataset, the three classes of Blight, Mosaic, and Healthy have tightly clustered metrics ranging from 91% to 92% F1 (91.7%, 91.6%, 91.7%) with an average accuracy of 91.7%—showing the model has no preferred class, despite the complexity of the three-class problem. On the Jamun dataset, the diseased class has a precision of 86.8%, a recall of 88.2%, and an F1 of 87.5%, whereas the Healthy class has a precision of 88.0%, a recall of 86.6%, and an F1 of 87.3%, with an average accuracy of 87.4%—the slightly lower accuracy than the other two datasets makes sense, as the difference between healthy and diseased states of the Jamun leaves is more subtle.

4.6 K-shot robustness
The K-shot robustness analysis shows that the fine-tuned ViTRelNet model performs well even in the one-shot case for all three datasets, with Guava reaching 84.5%, Cassava reaching 86.0%, and Jamun reaching 77.6%, all of which are substantially higher than the respective random baselines of 50%, 33.33%, and 50% (Figure 10). In all three cases, accuracy improves as K increases from 1 to 5, with Guava reaching as high as 94.8% (15-shot), Cassava reaching as high as 93.3% (5-shot), and Jamun reaching as high as 88.5% (15-shot). For all three, accuracy improves marginally after the 5-shot case, validating our claim that 5 support examples per class is indeed the optimal value for this framework, while the decreasing variance with increasing K further validates the stability and reliability of our model with this episodic evaluation approach.

4.7 Computational complexity
Meta-training of the fine-tuned ViTRelNet was completed in 92.4 min across 2,500 episodes on a single NVIDIA Quadro RTX 4000 GPU, approximately 2.22 s per training episode. At meta-testing, inference requires only a single forward pass through the frozen fine-tuned ViT backbone and the lightweight two-layer relation module per query image, making the framework computationally feasible for deployment on mid-range GPU hardware.
4.8 Ablation study
To evaluate the effectiveness of the proposed method of synergistic training, an ablation study was carried out on two configurations that were identical in every aspect except for one key difference: the pre-training of the ViT backbone (i.e., frozen weights and no adaptation to the target domain) versus the fine-tuning of the ViT backbone (i.e., the final three transformer blocks were jointly fine-tuned with the relation network on the Plant Village dataset during the meta-training process). Both configurations use the same two-layer MLP relation network as the learnable similarity metric, ensuring that any performance difference is attributable solely to the backbone training strategy.
4.8.1 Effect of backbone fine-tuning
The most direct ablation compares the frozen ViT + RelNet against the fine-tuned ViT + RelNet, identical in architecture, differing only in whether the final three ViT transformer blocks are updated during meta-training. Table 3 summarizes the results across all three datasets at the primary 5-shot evaluation setting.
Table 3. Effect of backbone fine-tuning.
| Dataset | Task | Frozen ViT + RelNet | Fine-tuned ViT + RelNet | Gain (pp) | Std dev reduction |
|---|---|---|---|---|---|
| Guava | 2-way 5-shot | 87.52% (± 0.87%) | 92.72% (± 0.63%) | +5.20 | 7.69% → 5.54% |
| Cassava | 3-way 5-shot | 83.87% (± 0.85%) | 91.79% (± 0.54%) | +7.92 | 7.47% → 4.77% |
| Jamun | 2-way 5-shot | 83.13% (± 1.00%) | 87.38% (± 0.84%) | +4.25 | 8.82% → 7.45% |
Table 3 results demonstrate that feature adaptation and metric adaptation are mutually reinforcing: fine-tuning the ViT backbone produces domain-adapted embeddings that the relation module can compare more effectively and provides task-specific gradient signal that guides the direction of backbone adaptation. The improvement is most significant on Cassava, the most visually complex 3-way problem, supporting the idea that backbone adaptation is most important when the target domain has multiple fine-grained disease categories. Most importantly, fine-tuning consistently reduces episodic variance on all datasets, suggesting that the adapted backbone is better at generating consistent prototype embeddings across diverse episode configurations.
4.8.2 Per-class metrics
The ablation effect is further examined through per-class precision, recall, and F1 scores. Table 4 compares both configurations at the macro-average level across all datasets.
Table 4. Per-class metrics: frozen ViT + RelNet vs. fine-tuned ViT + RelNet.
| Dataset | Model | Macro precision | Macro recall | Macro F1 | Std dev |
|---|---|---|---|---|---|
| Guava | Frozen ViT + RelNet | 87.44% | 87.42% | 87.42% | 7.69% |
| Guava | Fine-tuned ViT + RelNet | 92.61% | 92.60% | 92.60% | 5.54% |
| Cassava | Frozen ViT + RelNet | 83.49% | 83.48% | 83.48% | 7.47% |
| Cassava | Fine-tuned ViT + RelNet | 91.69% | 91.68% | 91.68% | 4.77% |
| Jamun | Frozen ViT + RelNet | 83.03% | 83.02% | 83.02% | 8.82% |
| Jamun | Fine-tuned ViT + RelNet | 87.41% | 87.40% | 87.40% | 7.45% |
The fine-tuned model’s macro precision, recall, and F1 scores all show improvements over the baseline model, with increases ranging from 5% to 8% on all three metrics. The similarity in precision and recall values for each configuration indicates that the two models were class-balanced, and the difference in performance was not due to a class prediction bias introduced by fine-tuning. The decrease in standard deviation for all fine-tuned models’ datasets also indicates that domain-adapted features yield more consistent prototype representations.
4.8.3 Comparative analysis with existing methods
Table 5 includes both same-domain and cross-domain methods, and we compare against both to demonstrate that ViTRelNet (Vision Transformer + relation network) achieves strong performance even under harder cross-domain conditions where the target crop species are completely absent from training data. An important methodological distinction applies throughout all same-domain methods evaluated on held-out classes from the same source dataset used for meta-training (typically PlantVillage), whereas the proposed model and the three cross-domain baselines are evaluated on datasets that are entirely unseen during training, representing a strictly harder generalization scenario.
Table 5. Comparative analysis with existing algorithms.
| Method | Backbone | Domain setting | N-way | K-shot | Accuracy |
|---|---|---|---|---|---|
| FSL metric learning (Wu, 2023) | CNN | Same-domain | 5-way | 1-shot | 69.10% |
| Transfer learning-FSL (Uskaner Hepsağ, 2023) | CNN | Same-domain | 5-way | 5-shot | 75.50% |
| Prune-FSL (Yan et al., 2024) | CNN | Same-domain | 5-way | 1-shot | 77.97% |
| FSL metric learning (Wu, 2023) | CNN | Same-domain | 5-way | 5-shot | 81.20% |
| FSL metric learning (Wu, 2023) | CNN | Same-domain | 5-way | 10-shot | 84.80% |
| PMF+FA (ViT) (Rezaei et al., 2024) | ViT | Same-domain | 5-way | 1-shot | 86.79% |
| PMF+FA (ViT) (Rezaei et al., 2024) | ViT | Same-domain | 5-way | 5-shot | 90.12% |
| Prune-FSL (Yan et al., 2024) | CNN | Same-domain | 5-way | 5-shot | 90.70% |
| SC-FSL (Mu et al., 2024) | ResNet50 | Cross-domain (PV → Potato) | 5-way | 1-shot | 49.12% |
| SC-FSL (Mu et al., 2024) | ResNet50 | Cross-domain (PV → Potato) | 5-way | 5-shot | 68.29% |
| SC-FSL (Mu et al., 2024) | ResNet50 | Cross-domain (PV → Potato) | 5-way | 30-shot | 79.51% |
| Proposed ViTRelNet (Jamun) | ViT (FT) | Cross-domain (PV → Jamun) | 2-way | 5-shot | 87.38% |
| Proposed ViTRelNet (Guava) | ViT (FT) | Cross-domain (PV → Guava) | 2-way | 5-shot | 92.72% |
| Proposed ViTRelNet (Cassava) | ViT (FT) | Cross-domain (PV → Cassava) | 3-way | 5-shot | 91.79% |
Among the same-domain 5-way 5-shot methods, the highest accuracy reported is 90.70% for Prune-FSL (Yan et al., 2024) and 90.12% for PMF+FA (Rezaei et al., 2024). The proposed ViTRelNet achieves 92.72% on Guava and 91.79% on Cassava, surpassing both despite the harder cross-domain evaluation setting. The SC-FSL is the most relevant cross-domain baseline, as it utilizes the same source domain as ours, i.e., PlantVillage, and evaluates on an unseen target dataset collected from the field, i.e., the Potato disease dataset. On the strict 5-shot setting, SC-FSL only achieves 68.29%, and on the 1-shot setting, SC-FSL only achieves 49.12%, which is just above the random baseline of 33.33% for a 5-way setting. The proposed ViTRelNet achieves 87.38%–92.72% on the 5-shot setting, significantly outperforming SC-FSL by +19.09%–24.43%. On the 1-shot setting, the proposed ViTRelNet achieves 77.60%–84.50%, significantly outperforming SC-FSL’s 1-shot setting result of 49.12% by +28.48–35.38 percentage points. The comparison between existing 5-way same-domain methods and our 2/3-way cross-domain approach is justified by the inverse relationship between class count and domain shift. In same-domain tasks, the model benefits from “domain-specific” features learned during meta-training. In contrast, our cross-domain tasks force the model to bridge the metric domain gap across entirely unseen plant species. We argue that achieving >90 accuracy in a 3-way cross-domain scenario is a more significant indicator of real-world robustness than high performance in a 5-way same-domain scenario, where the environment remains static. Critically, the domain gap faced by each method substantially differs in nature. SC-FSL trains on the PlantVillage dataset, which has three potato disease classes (Early Blight, Late Blight, and Healthy) and evaluates on a five-class field potato dataset, meaning the crop species is identical throughout and at least three of five target classes directly overlap with the training classes; the primary gap is imaging condition, i.e., laboratory to field rather than species or disease novelty. By contrast, ViTRelNet is evaluated on entirely different target species (Guava, Jamun, and cassava), which do not appear in training classes, meaning the model faces a domain gap comprising a complete crop species shift, entirely unseen disease categories, and an imaging condition shift simultaneously. These results confirm that the synergistic co-adaptation of a fine-tuned ViT backbone and a meta-learned relation network provides a robust, practically deployable solution to the dual challenge of domain shift and data scarcity in real-world plant disease diagnosis.
5 Conclusion
The classification of plant diseases in real-world agricultural scenarios is primarily limited by the availability of labeled data, as well as the inability of existing FSL models to generalize across visually distinct domains. This work identified a critical metric domain gap emphasizing the need to co-adapt the similarity metric as well as the feature extractor with the target domain, rather than merely relying on the existing FSL models. The proposed ViTRelNet achieved 87.38%–92.72% accuracy at 5-shot across three morphologically diverse unseen datasets, outperforming both the frozen ViT baseline and the cross-domain baseline SC-FSL at equivalent shot conditions. The ablation study confirmed that backbone fine-tuning was the main contributor to this gain in performance, which also reduced episodic variance. These experiments verify that ViTRelNet is directly deployable for diagnosing new plant diseases from minimal labeled examples without any need for retraining and is therefore practical for resource-constrained agricultural settings. In practice, ViTRelNet can be adopted by field agronomists to classify novel crop diseases from as few as five labeled images per class without requiring access to large annotated datasets, making it directly applicable to low-resource agricultural settings. Current limitations include reduced performance under N >3 classification tasks as confirmed by robustness analysis, sensitivity to severe imaging conditions like overexposure, and the absence of evaluation on more diverse real-world field conditions, all of which are identified as directions for future investigation. While a performance trade-off was observed when scaling to 5-way tasks—further validating the complexity of the identified domain gap—the model’s high reliability in N≤3 configurations align with the practical requirements of in situ agricultural diagnostics. Future work involves extending this framework to more N-way cross-domain benchmarks, domain-adversarial meta-learning methods, and quantification of disease severity using segmentation.
Generative AI statement
The author(s) declared that generative AI was not used in the creation of this manuscript.
Any alternative text (alt text) provided alongside figures in this article has been generated by Frontiers with the support of artificial intelligence and reasonable efforts have been made to ensure accuracy, including review by the authors wherever possible. If you identify any issues, please contact us.
Publisher’s note
All claims expressed in this article are solely those of the authors and do not necessarily represent those of their affiliated organizations, or those of the publisher, the editors and the reviewers. Any product that may be evaluated in this article, or claim that may be made by its manufacturer, is not guaranteed or endorsed by the publisher.
Footnotes
Edited by: Changcai Yang, Fujian Agriculture and Forestry University, China
Reviewed by: Huinian Li, Macau University of Science and Technology, Macao SAR, China
Abdullah Al Noman, Westcliff University, United States
Statements
- Conflict of interest
The author(s) declared that this work was conducted in the absence of any commercial or financial relationships that could be construed as a potential conflict of interest.
- Funding
The author(s) declared that financial support was received for this work and/or its publication. This research work was supported by the Anusandhan National Research Foundation (ANRF) under the Partnerships for Accelerated Innovation and Research (PAIR) project, Government of India, sanction order ANRF/PAIR/2025/000011/PAIR-B.
- Data availability
Publicly available datasets were analyzed in this study. The PlantVillage dataset can be found at: https://www.kaggle.com/datasets/mohitsingh1804/plantvillage. The Guava and Jamun datasets are available at: https://doi.org/10.17632/hb74ynkjcn.1 (Chouhan et al., 2019). The Cassava dataset is available at: https://doi.org/10.17632/3832tx2cb2.1 (Divyanth et al., 2021).
- Author contributions
NC: Investigation, Writing – original draft. LG: Conceptualization, Supervision, Writing – review & editing. CB: Methodology, Supervision, Writing – review & editing. LS: Validation, Writing – review & editing.
References
- Chouhan S. S., Kaul A., Singh U. P., Jain S. (2019). A database of leaf images: Practice towards plant conservation with plant pathology. Mendeley Data V1. doi: doi:10.17632/hb74ynkjcn.1
- Ding R., Qiao Y., Yang X., Jiang H., Zhang Y., Huang Z.. (2022). Improved ResNet based apple leaf diseases identification. IFAC-PapersOnLine 55, 78 – 82. doi: doi:10.1016/j.ifacol.2022.11.118
- Divyanth L. G., Soni P., Machavaram R. (2021). Cassava leaf disease dataset. Mendeley Data V1. doi: doi:10.17632/3832tx2cb2.1
- FAO (2024). Plant Production and Protection. Available online at: https://www.fao.org/plant-production-protection/about/en (Accessed December 16, 2025).
- Ghosh D., Ghosh S., Jana N. D., Biswas S., Mallipeddi R. (2025). Designing optimal Vision Transformer architecture using differential evolution for tomato leaf disease classification. Comput. Electron. Agric. 238, 110824. doi: doi:10.1016/j.compag.2025.110824
- Haritha I. V. S. L., Harshini M., Patil S., Philip J. (2022). “ Real time object detection using YOLO algorithm ”, 2022 6th International Conference on Electronics, Communication and Aerospace Technology (Coimbatore, India), 1465 – 1468. doi: doi:10.1109/ICECA55336.2022.10009184
- Hughes D. P., Salathé M. (2015). An open access repository of images on plant health to enable the development of mobile disease diagnostics. arXiv 1511.08060. doi: doi:10.48550/arXiv.1511.08060
- Jamjoom M., Elhadad A., Abulkasim H., Abbas S. (2023). Plant leaf diseases classification using improved K-means clustering and SVM algorithm for segmentation. Computers Materials Continua 76, 367 – 382. doi: doi:10.32604/cmc.2023.037310
- Javidan S. M., Banakar A., Vakilian K. A., Ampatzidis Y. (2023). Diagnosis of grape leaf diseases using automatic K-means clustering and machine learning. Smart Agric. Technol. 3, 100081. doi: doi:10.1016/j.atech.2022.100081
- Jiang X., Wang J., Xie K., Cui C., Du A., Shi X.. (2025). PlantCaFo: An efficient few-shot plant disease recognition method based on foundation models. Plant Phenomics 7, 100024. doi: doi:10.1016/j.plaphe.2025.100024
- Mamun S. B., Payel I. J., Ahad M. T., Atkins A. S., Song B., Li Y. (2025). Grape Guard: A YOLO-based mobile application for detecting grape leaf diseases. J. Electron. Sci. Technol. 23, 100300. doi: doi:10.1016/j.jnlest.2025.100300
- ManNepalli P. K., Pathre A., Chhabra G., Ujjainkar P. A., Wanjari S. (2024). Diagnosis of bacterial leaf blight, leaf smut, and brown spot in rice leafs using VGG16. Proc. Comput. Sci. 235, 193 – 200. doi: doi:10.1016/j.procs.2024.04.022
- Mu J., Feng Q., Yang J., Zhang J., Yang S. (2024). Few-shot disease recognition algorithm based on supervised contrastive learning. Front. Plant Sci. 15, 1341831. doi: doi:10.3389/fpls.2024.1341831
- Mukherjee R., Ghosh A., Chakraborty C., De J. N., Mishra D. P. (2025). Rice leaf disease identification and classification using machine learning techniques: A comprehensive review. Eng. Appl. Artif. Intell. 139, 109639. doi: doi:10.1016/j.engappai.2024.109639
- Naveed F., Masih A., Mahmood J., Ahmed M., Ali A., Saddiqa A.. (2025). Sustainable AI for plant disease classification using ResNet18 in few-shot learning. Array 26, 100395. doi: doi:10.1016/j.array.2025.100395
- Paroda R. (2023). Plant health and global food security (ATSE Focus). Available online at: https://www.atse.org.au/news/plant-health-and-global-food-security/ (Accessed December 15, 2025).
- Rezaei M., Diepeveen D., Laga H., Jones M. G. K., Sohel F. (2024). Plant disease recognition in a low data scenario using few-shot learning. Comput. Electron. Agric. 219, 108812. doi: doi:10.1016/j.compag.2024.108812
- Ristaino J. B., Anderson P. K., Bebber D. P., Brauman K. A., Cunniffe N. J., Fedoroff N. V.. (2021). The persistent threat of emerging plant disease pandemics to global food security. Proc. Natl. Acad. Sci. 118, e2022239118. doi: doi:10.1073/pnas.2022239118
- Sagheer S. V. M., P V O., Ameer P. M., BaQais A., Kalathil S. (2025). A deep learning approach to classification of diseases in date palm leaves. Computers Materials Continua 84, 1329 – 1349. doi: doi:10.32604/cmc.2025.063961
- Singh A. K., Rao A., Chattopadhyay P., Maurya R., Singh L. (2024). Effective plant disease diagnosis using Vision Transformer trained with leafy-generative adversarial network-generated images. Expert Syst. Appl. 254, 124387. doi: doi:10.1016/j.eswa.2024.124387
- Srivastava M., Sisaudia V., Meena J. (2025). AgriTL-ViT: A Vision Transformer model with attention techniques for classification of plant leaf disease. Expert Syst. Appl. 294, 128793. doi: doi:10.1016/j.eswa.2025.128793
- Uskaner Hepsağ P. (2023). Efficient plant disease identification using few-shot learning: A transfer learning approach. Multimed. Tools Appl. 83, 58293 – 58308. doi: doi:10.1007/s11042-023-17824-2
- Vallabhajosyula S., Sistla V., Kolli V. K. K. (2024). A novel hierarchical framework for plant leaf disease detection using residual vision transformer. Heliyon 10, e29912. doi: doi:10.1016/j.heliyon.2024.e29912
- Wu W. (2023). Plant leaf diseases classification based on few-shot learning. Acad. J. Sci. Technol. 5, 82 – 84. doi: doi:10.54097/ajst.v5i2.6287
- Xu X., Yang G., Wang Y., Shang Y., Hua Z., Wang Z.. (2024). Plant leaf disease identification by parameter-efficient transformer with adapter. Eng. Appl. Artif. Intell. 138, 109466. doi: doi:10.1016/j.engappai.2024.109466
- Yan W., Feng Q., Yang S., Zhang J., Yang W. (2024). Prune-FSL: Pruning-based lightweight few-shot learning for plant disease identification. Agronomy 14, 1878. doi: doi:10.3390/agronomy14091878
- Yang S., Feng Q., Zhang J., Yang W., Zhou W., Yan W. (2024). From laboratory to field: Cross-domain few-shot learning for crop disease identification in the field. Front. Plant Sci. 15, 1434222. doi: doi:10.3389/fpls.2024.1434222
- Yu S., Xie L., Huang Q. (2023). Inception convolutional vision transformers for plant disease identification. Internet Things 21, 100650. doi: doi:10.1016/j.iot.2022.100650
- Zhao Y., Zhang Z., Wu N., Zhang Z., Xu X. (2024). MAFDE-DN4: Improved few-shot plant disease classification method based on deep nearest neighbor neural network. Comput. Electron. Agric. 226, 109373. doi: doi:10.1016/j.compag.2024.109373
Citation
Chokkalingam, N., et al. (2026). A Vision Transformer-based few-shot learning approach for leaf disease classification. Frontiers in Agronomy, Volume 8. https://doi.org/
- Received
- Accepted
- Published
- Volume
- 8 - 2026
Copyright
Copyright © 2026 Chokkalingam, G, Baskar and Sumalatha.
License: https://creativecommons.org/licenses/by/4.0/
*Correspondence: Chanthini Baskar
Article metrics
- Views
- 0
- Downloads
- 0
- Citations
- 0
- Shares
- 0
