arXiv:2610.29008cs.CVOct 2026

Manuscript Offprint

arXiv:2610.29008

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

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

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 (LOGO) evaluation protocol, we present a thorough comparative analysis of convolutional neural networks (CNNs), Vision Transformers (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 confirm that the hybrid framework in this study improves discriminative feature transferability, improves attention localization, and stabilizes optimization. Overall, the experimental results demonstrate how well hybrid distillation techniques can lead to domain robust agricultural systems and can be considered a promising direction for robust agricultural vision frameworks in the real world.

Keywords: Knowledge Self-Distillation, Leave-One-Grade-Out, Banana Classification, Vision Transformer

1 Introduction

Automated fruit variety classification is becoming increasingly vital in modern farming, as it supports large-scale yield estimation, quality control, and a smooth supply chain. But variations in growing regions, inconsistent cultivation practices, improper handling during harvest and distribution, inadequate disease and pest management make bananas susceptible to quality issues like bruising, peel discoloration, premature ripening, fungal lesions, splitting, shape deformities, and uneven coloration Al-Dairi et al. (2023). These imperfections significantly diminish retail value and marketability, resulting in substantial economic losses for producers and supply chain stakeholders Fernando et al. (2019). At present, the prevailing grading approach still depends heavily on manual inspection that suffers from low throughput, high labor costs and variable assessment criteria influenced by human subjectivity. Although mechanical sorting systems can enhance grading accuracy, they remain incapable of effectively assessing surface imperfections like bruising, spotting, or peel discoloration. Also, physical contact during sorting often results in secondary damage. These challenges and bananas being one of the world's most vital staple crops (e.g., global production exceeding 114 million tonnes annually and serving as a primary food source for over 400 million people worldwide Yasin et al. (2025); Zhang et al. (2026)) have motivated extensive research into automated classification systems using machine learning and computer vision techniques Zhang et al. (2024).

Machine learning and computer vision-based automated classification systems offer substantial benefits, such as increased processing speed, consistent quality evaluation, reduced labour costs, and enhanced traceability throughout the supply chain Zhang et al. (2024). Early techniques mainly employed hand-crafted features (e.g., color histograms, texture descriptors) combined with classical machine learning algorithms such as Support Vector Machines (SVMs) and Random Forests. For example, the method in Zhuang et al. (2019); Santos Pereira et al. (2018) extracted peel color, local texture, and local shape features from different banana regions using local binary pattern (LBP) and classifying them using (Naive Bayes) NB, Linear Discriminant Analysis (LDA), and SVM algorithms Ghazal et al. (2021). While Fu et al. (2019) presented a multi-scale method that used VM and AdaBoost algorithms with fused LBP (local binary pattern) and HOG (histogram of oriented gradients) features. Nonetheless, these methods demonstrated limited generalization capability (i.e., failing to capture the complex hierarchical representations), especially when confronting variations in lighting conditions, camera angles, and fruit quality grades.

With recent advances in computer vision and deep learning, intelligent inspection and sorting systems have emerged as a critical solution to overcoming these limitations. The deep learning algorithms have catalyzed a paradigm shift in agricultural automation, including fruit quality assessment and variety classification. In particular, Convolutional Neural Networks (CNNs) have revolutionized computer vision tasks by enabling automatic feature extraction directly from raw image data Li et al. (2021). CNNs have demonstrated exceptional success across various agricultural applications, including crop disease detection, fruit ripeness assessment, and variety classification. Wallelign et al. (2018); Olisah et al. (2024); Gurjar et al. (2026); Ponce et al. (2019). For instance, the study in Sheikh et al. (2025); XU2 (2026) employed deep convolutional features learned from banana images using a transfer learning framework. Specifically, a fine-tuned deep learning classifier was used to distinguish banana varieties based on shape, color, and texture cues captured in the learned feature maps. While, the work in Shuprajhaa et al. (2023) proposed a CNN-XGBoost hybrid model for classifying banana ripening stages, where a convolutional neural network extracts deep visual features such as color, texture, and shape, and XGBoost performs the classification. Moreover, the proposed system used Linear Discriminant Analysis (LDA) for dimensionality reduction, thereby enabling effective training with smaller datasets.

Despite remarkable advances in deep learning for automated classification of fruit and banana varieties, several crucial challenges remain inadequately addressed Too et al. (2019); Mehdipour et al. (2026); Sarode and Patil (2026). Most current models (e.g., CNNs, Vision Transformers (ViTs), or hybrid architectures) perform well on in-distribution data but struggle to generalize across domain shifts commonly encountered in real-world banana production and distribution as well as other agriculture settings. These shifts arise from variations in quality grades, maturity levels, lighting conditions, and camera setups, leading to substantial degradation in model performance when confronted with unseen distributions of visual or quality-grade features. CNNs, while effective at capturing local texture and shape information, often fail to model global structural relationships critical for distinguishing visually similar varieties. Conversely, ViTs capture long-range dependencies and global context but typically require large datasets and may underutilize local texture cues that remain discriminative under quality degradation. Hybrid approaches that combine the strengths of both paradigms show promise, yet their efficacy for cross-grade and cross-domain agricultural classification remains largely unexplored. Consequently, ensuring robust, reliable performance across diverse fruit quality conditions remains an open and pressing research problem in precision banana agriculture. All in all, not only do existing methods struggle to generalize when confronted with unseen quality grades (particularly in settings where inter-class differences are subtle and intra-class variability is high), but the effectiveness of hybrid architectures that combine complementary strengths for cross-grade classification remains underexplored.

As deep learning and vision-based systems are increasingly being deployed in banana orchards, packing houses, and markets, robustness to variations in grades, lighting, maturity, and surface quality is as crucial as classification accuracy. Thus, in this work, we focus on cross-grade banana variety classification, a challenging yet practically relevant task. To address the limitations of single-paradigm models, we propose a dual-stream CNN-Transformer hybrid architecture augmented with KL-divergence-based distillation. By encouraging alignment between the predictive distributions of a Swin Transformer (teacher) and a ResNet-based CNN (student), the model learns grade-invariant representations that are more robust to domain shift. The primary novelty of this work lies not only in the proposed CNN-Transformer architecture, but also in establishing cross-grade generalisability as a distinct and practically meaningful evaluation problem for banana variety classification. This paper makes the following key contributions:

• We establish a Leave-One-Grade-Out (LOGO) cross-validation framework, in which each grade is completely held out during testing, providing a more realistic assessment of model robustness to unseen grades than conventional random splits.

• We systematically evaluate CNNs, Vision Transformers, and hybrid architectures under the LOGO protocol, thereby offering one of the first large-scale studies of banana variety classification under a rigorous cross-grade evaluation protocol.

  • We introduce a hybrid model integrating a Swin Transformer and ResNet backbone to leverage feature fusion to improve cross-grade generalization and outperform pure CNN or Transformer baselines.

• We propose a self-distillation mechanism that aligns probability distributions between architectural streams, significantly improving robustness on challenging domains and accelerating convergence.

  • Through attention-based visualizations (Grad-CAM and Score-CAM), inter-stream alignment analysis, and training dynamics studies, we offer in-depth insights into how hybrid representations and knowledge distillation jointly mitigate domain shift effects.

To the best of our knowledge, we present the first systematic investigation of banana variety classification under a rigorous cross-grade generalisation setting. The paper is organized as follows. Section 2 reviews related work, and Section 3 describes the dataset. Section 4 presents the problem formulation, our proposed hybrid architecture, and KL-divergence-based feature alignment. Section 5 details the experimental analysis, including quantitative, interpretability, and qualitative results. Section 8 presents conclusions with future research directions.

References (42)