Source-linked AI summary

Enhancing Cross-Grade Generalization in Banana Variety Classification via Hybrid CNN-Transformers and Knowledge Self-Distillation

Khush Kataruka, Mohammad Muzammila, Zahid Akhtar, Raghavendra Ramachandra, Praveen Kumar Chandaliya

arXiv:2610.29008v1cs.CVcs.AI

TL;DR

Banana variety classifiers must generalize across quality grades, where changes in fruit condition create domain shift. This work evaluates CNNs, Vision Transformers, and hybrids under Leave-One-Grade-Out testing, and reports that its KL-distilled Swin–ResNet hybrid outperforms pure CNN and Transformer baselines.

  • Problem

    Models that perform well on in-distribution data can struggle on unseen quality grades, while cross-grade generalization and hybrid approaches remain underexplored.

    Source: §4.1 · p. 7
  • Method

    The study compares CNN, Vision Transformer, and hybrid architectures using Leave-One-Grade-Out evaluation and proposes a dual-stream Swin–ResNet hybrid with KL-based self-distillation.

    Source: §1 · p. 4, §4.3.4 · p. 10
  • Results

    The authors report that the hybrid model with self-distillation outperforms pure CNN and Transformer baselines in cross-grade evaluation.

    Source: §1 · p. 4
  • Takeaways & Limitations

    The work establishes cross-grade generalizability as a distinct evaluation problem for banana variety classification.

    Source: §1 · p. 4

Abstract

from arXiv · show

In recent years, automated fruit classification systems have become a more critical component in precision agriculture for efficient yield estimation, quality control, and supply chain optimization. However, they still face significant challenges under varying quality, fruit maturity, illumination, texture degradation, morphological attributes, domain shift, and post-harvest handling conditions. In this study, we address the challenging issue of cross-grade banana variety classification. This is a real-world setting where models that have been trained on specific quality grades must generalize to unseen grades to handle significant domain shift. Under a rigorous Leave-One-Grade-Out evaluation protocol, we present a thorough comparative analysis of CNNs, ViTs, and dual-stream hybrid architectures using a large-scale dataset of 31,678 banana images with three varieties and three quality grades. Specifically, to address the drawbacks of single-paradigm frameworks, we present a dual-stream Swin ResNet hybrid framework enhanced with KL-divergence-based self-distillation to align probabilistic feature representations across the CNN and Transformer streams. Comprehensive experimental analyzes show that the presented hybrid framework with KL-divergence based self-distillation achieves better overall performance, i.e., it attains a mean accuracy of 81.25% and significantly surpasses CNN and Transformer baseline models. Qualitative analysis further confirms that the hybrid framework in this study improves discriminative feature transferability, improves attention localization, and stabilizes optimization.

1 Introduction

Automated banana classification matters for agricultural quality control, but existing methods struggle with variable fruit conditions and unseen quality grades. This work frames cross-grade generalization as a practical evaluation problem and proposes a Swin–ResNet hybrid with KL-based self-distillation.

1 Introduction

  • Variations in growing, handling, and fruit condition can reduce banana marketability, while manual grading is labor-intensive and subjective.Mechanical sorting can miss surface imperfections and may cause secondary damage through physical contact.Source: §1 · p. 2
  • Earlier hand-crafted feature methods showed limited generalization under changes in lighting, camera angle, and fruit quality grade.These methods also struggled to capture complex hierarchical representations.Source: §1 · p. 3
  • Existing models often struggle across domain shifts, while CNNs may miss global relationships and ViTs may underuse local texture cues.The effectiveness of hybrid architectures for cross-grade agricultural classification remains largely unexplored.Source: §1 · p. 3
  • The proposed Swin–ResNet hybrid with KL-based self-distillation is reported to outperform pure CNN and Transformer baselines under cross-grade evaluation.The work also establishes cross-grade generalizability as a distinct evaluation problem for banana variety classification.Source: §1 · p. 4
  • The study evaluates CNNs, Vision Transformers, and hybrid architectures using a Leave-One-Grade-Out protocol that tests on a grade held out from training.The authors describe this as one of the first large-scale studies under a rigorous cross-grade protocol.Source: §1 · p. 4

2 Related Work

Fruit-classification research has progressed from hand-crafted features to deep CNNs, Vision Transformers, and hybrid or distillation approaches. However, these approaches remain little explored for agricultural generalization under cross-domain conditions.

2 Related Work

  • Traditional systems used engineered color, texture, and shape features with classical classifiers, but had lower robustness to environmental variation and required domain expertise.Examples include banana cultivar classification using scale-invariant shape features and a Bayesian classifier Dittakan et al. (2017).Source: §2 · pp. 4–5
  • Deep learning reduced reliance on hand-crafted features, with CNNs widely used in agricultural image analysis and ViTs modeling global image dependencies.The cited applications include banana quality identification with CNNs and banana leaf nutrient-deficiency classification with a ViT.Source: §2 · p. 5
  • Hybrid CNN–Transformer methods combine local texture representation with long-range dependencies, while knowledge distillation has also been used for cross-architecture feature alignment.Prior examples include crop classification and green-plum defect classification.Source: §2 · p. 5
  • Hybrid models and distillation remain largely unexplored for agricultural classification under cross-domain conditions.The review identifies this as the gap addressed by the work.Source: §2 · pp. 5–6

3 Dataset

The dataset comprises 31,678 banana images spanning three commercial varieties and three quality grades. Its grades represent condition and marketability differences rather than variety-specific attributes.

3 Dataset

  • 31,678 high-resolution images cover three banana varieties and three commercial quality grades, with the dataset described as balanced across both dimensions.Table 1 is identified as presenting overall dataset statistics.Source: §3 · p. 6, Table 1 · p. 6
  • The three varieties have subtle morphological differences that challenge both automated classification systems and human experts.The varieties are Pachbale, Rasbale, and Elakki-bale.Source: §3 · p. 6
  • Grades represent ripeness, physical condition, and marketability rather than variety-specific attributes.Grade 1 has the highest visual noise and variability, while Grade 3 is the most visually consistent and easiest domain.Source: §3 · p. 6

4 Proposed Cross-Grade Banana Variety Classification Methodology

The method frames banana variety recognition across quality grades as generalization to a held-out grade, evaluated with Leave-One-Grade-Out testing. It compares baseline vision models with a dual-stream Swin–ResNet framework that fuses branch predictions and adds feature-level KL self-distillation.

4.1 Problem Formulation

  • Each LOGO run tests on one held-out quality grade and trains on the other two, targeting generalization across grade-dependent distribution shifts.The formulation attributes those shifts to differences in ripeness, defects, texture, and surface appearance.Source: §4.1 · p. 7

4.2 Baselines Architectures

  • The baselines are ResNet50, EfficientNet-B1, and Swin Transformer, fine-tuned on the banana dataset from pretrained weights.ResNet50 is the main CNN baseline, EfficientNet-B1 provides a parameter-efficient CNN comparison, and Swin represents the Transformer family.Source: §4.2 · pp. 7–8

4.3 Hybrid Teacher-Student Framework with KL-Divergence Distillation

  • The hybrid processes each image with a Swin Transformer teacher for global representations and a ResNet50 student for local features, with standard and KL-distillation variants.Its components include a learnable feature adaptor, dual classification heads, logit-level fusion, and joint supervision and distillation.Source: §4.3 · p. 8

4.3.1 Teacher Network: Swin-Tiny Transformer Branch

  • The Swin-Tiny teacher divides the input image into patches, processes tokens through Transformer stages, and uses the final-stage output to produce teacher features and logits.The stages apply windowed and shifted-window attention to obtain multiscale, hierarchical global context.Source: §4.3.1 · pp. 8–9

4.3.2 Student Network: ResNet50 Branch

  • The ResNet50 student extracts local texture and shape features, then uses a learnable adaptor to project its features into the teacher feature space.The projection is intended to harmonize the heterogeneous feature spaces for semantic alignment.Source: §4.3.2 · p. 9

4.3.3 Logit-Level Fusion

  • At inference, the two branches' logits are combined by logit averaging, followed by softmax to obtain the final prediction.Each branch has its own classification head.Source: §4.3.3 · p. 10

4.3.4 KL-Divergence Self-Distillation

  • The KL-distillation variant adds feature-level alignment: the Swin branch acts as a soft teacher for the ResNet50 student, while both branches receive label-based cross-entropy supervision.The teacher features are detached so the KL loss updates only the student; the compared standard hybrid uses cross-entropy on the fused output alone.Source: §4.3.4 · pp. 10–11

5 Experiments Setups

The experiments evaluate the proposed cross-grade classification scheme using a LOGO design, with independent models trained for each grade combination. Training configuration specifies early stopping and AdamW optimization.

5 Experiments Setups

  • The section evaluates the proposed cross-grade banana variety classification scheme.Source: §5 · p. 11

5.1 Experimental Design

  • Three independent models per architecture were trained from scratch for each LOGO grade combination.The experimental configuration is for Leave-One-Grade-Out cross-validation.Source: §5.1 · p. 12, Table 3 · p. 12

5.2 Training Configuration

  • Training ran for up to 50 epochs with validation-loss early stopping, AdamW at 1×10−4, and batches of 32.Early stopping used patience 7 and min delta 0.001; training used a CUDA-enabled H100-NVL GPU.Source: §5.2 · p. 12

6 Quantitative Results

Across the evaluated models, the KL-regularized Swin-ResNet has the strongest overall results, while grade-specific and single-source tests show how performance varies with domain difficulty. The analyses also report training stability, efficiency, and component-level evaluation.

6.1 Overall Model Comparison

  • 0.8125 mean accuracy and 0.8035 mean F1-score make Swin-ResNet (KL) the best overall model, ahead of the evaluated baselines and hybrid variants.Against Swin-Tiny, mean accuracy improves by 0.0831; against standard Swin-ResNet (NoAug), it rises from 0.7746 to 0.8125.Source: §6.1 · p. 13, Table 4 · p. 13

6.2 Grade-Specific Performance Comparison

  • 0.9209 accuracy and 0.9203 F1-score on Grade 3 are the KL hybrid's best grade-specific results; Grade 1 accuracy is 0.7386, while Swin-Tiny leads Grade 2 accuracy at 0.7980.The KL hybrid attains the highest Grade 1 accuracy and F1-score; on Grade 2 it records 0.7781 accuracy and the highest precision, 0.8451. CNN-only baselines fluctuate more across grades.Source: Table 5 · p. 14, §6.2 · pp. 15–16

6.3 Cross-Grade Generalization: Train-on-One-Grade Protocol

  • 0.7242 mean accuracy across six T1G transfer settings is reported for Swin-ResNet (KL), versus 0.7187 for Dual CE; Grade 3 training transfers best, reaching 0.9148 accuracy on Grade 2.Both T1G variants have lower mean accuracy than under LOGO, reflecting the greater difficulty of single-source transfer.Source: §6.3 · pp. 16–17, Table 6 · p. 16

6.4 Ablation Study

  • The ablation evaluates Dual CE supervision, adaptor-based feature alignment, and KL-divergence distillation individually and in the full model.Dual CE supervises the Swin Transformer and ResNet50 branches separately; the full configuration combines the adaptor, Dual CE, and KL distillation.Source: §6.4 · pp. 17–18, Table 7 · p. 17

6.5 Confusion Matrix Analysis

  • Grade 2 has the highest class separability, while Rasbale remains the most challenging class across grades.The confusion matrices show strong diagonal dominance overall, but Grade 1 has more inter-class confusion, particularly between Elakki-bale and Rasbale.Source: §6.5 · pp. 18–19, Figure 2 · p. 18

6.6 Training Dynamics

  • Small training–validation loss gaps and near-zero late loss-change fluctuations indicate stable convergence without signs of divergence or instability.These dynamics are reported across all three LOGO folds.Source: §6.6 · p. 19, Figure 3 · p. 20

6.7 Training Efficiency Analysis

  • 8, 8, and 10 epochs to early stopping make Swin-ResNet (KL) the quickest-converging hybrid across the three grades.The reported comparison describes KL-based hybrids as more efficient than independent and non-distilled models.Source: §6.7 · p. 19, Table 8 · p. 19

7 Qualitative Analysis: Success vs. Failure Modes

The qualitative analysis examines successful predictions, errors, and attention maps across grades. It reports localized defect attention alongside remaining class-confusion and inconsistent agreement between attention methods.

7 Qualitative Analysis: Success vs. Failure Modes

  • The analysis compares successful predictions with misclassifications and examines alignment between Student ResNet and Teacher Swin attention maps.Source: §7 · p. 21

7.1 Grade 1 Analysis (Hardest Domain)

  • Grade 1 is the most challenging domain, and its success-versus-failure case study focuses on that difficult setting.The figure is identified as a Grade 1 success-versus-failure case study.Source: §7.1 · p. 21, Figure 4 · p. 21

7.1.2 Grade 3 Analysis (Easiest Domain)

7.2 Interpretability Analysis: Student vs. Teacher Attention

  • The Student ResNet50 attention maps localize defects such as bruises, fungal lesions, and discoloration with reduced background activation compared with the baseline Swin Teacher maps.The comparison shows input images, Student Grad-CAM/Score-CAM maps, and Teacher maps in stacked rows.Source: §7.2 · p. 22, Figure 7 · p. 23

7.2.1 Quantitative Analysis: IoU Scores

  • Grad-CAM and Score-CAM show moderate, inconsistent IoU agreement; Grad-CAM is generally higher, though Score-CAM is higher for Grade 3 Rasbale.For Grade 2 Rasbale, IoU is 0.362 versus 0.221; for Grade 3 Rasbale, Score-CAM is 0.337 versus Grad-CAM at 0.176.Source: Table 9 · p. 22, §7.2.1 · pp. 23–24

8 Conclusion

The study compares CNN, Vision Transformer, and hybrid models for banana-variety classification across unseen quality grades, and reports that a distillation-guided dual-stream Swin–ResNet hybrid performs best overall. The authors identify broader generalization and deployment settings for future investigation.

8 Conclusion

  • The dual-stream Swin–ResNet hybrid with KL-divergence-based self-distillation achieved the best overall performance and fastest convergence over baseline models.Grade-wise analysis and attention visualizations further validated its stability and discriminative power under difficult low-quality conditions.Source: §8 · p. 24
  • The study compared CNN, Vision Transformer, and hybrid architectures using a strict Leave-One-Grade-Out protocol across three commercial quality grades and three varieties.Models were trained on specific quality grades and tested on unseen grades.Source: §8 · p. 24
  • The dual-stream hybrid aligns predictive distributions while combining global context and local texture cues to learn more robust, grade-invariant representations.Source: §8 · p. 24
  • Future work includes testing domain generalization and augmentation, lightweight variants for real-time deployment, and datasets spanning multiple fruits or regions.Source: §8 · p. 24

9 Statement and Declarations

The authors state that the work was conducted independently, acknowledge their sources, and report no conflicts of interest. They also state that the study involved no human participants or animals.

9 Statement and Declarations

  • The authors state that the work was original and independently conducted, and that its sources were properly acknowledged.Source: §9 · p. 24
  • The authors report that the results had not been submitted to or published in another journal or conference.Source: §9 · p. 24
  • The authors declare no conflicts of interest and no studies involving human participants or animals.Source: §9 · p. 24

10 Funding

The authors report that the research received no specific grant from funding agencies in the public, commercial, or not-for-profit sectors.

10 Funding

  • The research received no specific grant from any funding agency.Source: §10 · p. 25
  • The funding statement covers agencies in the public, commercial, and not-for-profit sectors.Source: §10 · p. 25
  • The funding statement does not identify a specific grant or funding agency.Source: §10 · p. 25

12 Author Contributions

The author-contribution statement assigns roles across conceptualization, methodology, analysis, investigation, resources, data curation, drafting, visualization, and supervision.

12 Author Contributions

  • Praveen Kumar Chandaliya and Khush Kataruka conceptualized the study; methodology was developed by Raghavendra Ramachandra, Khush Kataruka, and Praveen Kumar Chandaliya.Source: §12 · p. 25
  • Mohammad Muzammil and Praveen Kumar Chandaliya conducted formal analysis, while Zahid Akhtar and Praveen Kumar Chandaliya performed the investigation.Source: §12 · p. 25
  • Praveen Kumar Chandaliya and Raghavendra Ramachandra provided resources; Khush Kataruka and Mohammad Muzammil curated the data.Source: §12 · p. 25
  • Praveen Kumar Chandaliya and Zahid Akhtar prepared the original draft; Mohammad Muzammil contributed visualization, and Praveen Kumar Chandaliya and Zahid Akhtar supervised.Source: §12 · p. 25

14 Availability of data and material

The complete dataset is publicly available through Mendeley Data. Its files are organized by banana variety, grade, and imaging scale, with labels intended to support reproducibility and further research.

14 Availability of data and material

  • The complete dataset is publicly available through Mendeley Data.Users can download it from the repository.Source: §14 · p. 25
  • Dataset folders are organized by banana variety, grade, and imaging scale.Source: §14 · p. 25
  • Images and videos are labeled to facilitate reproducibility and further research.Source: §14 · p. 25
Loading 2610.29008v1…