Adaptive classification and grading model of cigar wrapper leaf based on improved ResNet algorithm Authors: Chaofan Du, Ruiqi Wang, Tianyi Wu, Yang Song, Runying Lin, Fulong Shen, Rijun Lai, Xiaolu Lin, Xiaofang Xie, Nannan Liu Published: 2026 ABSTRACT AbstractThe grading of cigar wrapper leaves is critical for ensuring product quality, yet lacks a mature intelligent grading system, relying predominantly on manual sorting with inherent limitations such as low efficiency and inconsistent standards. This study proposed a deep learning-driven framework for automated classification of cigar wrapper leaves, using the dataset comprising 8,637 leaf images across nine conventional purchasing grades of the popular cultivar FX-01 grown in Longyan, Fujian Province, China. The proposed model integrated a Mask4Ch (Mask-augmented Fourth Channel) module into the ResNet-50 backbone, incorporating leaf segmentation masks to enhance feature extraction. A dual-head training strategy combining Cross-Entropy (CE) for multi-class classification and Cumulative Ordinal Regression (CORAL) for ordinal constraint modeling was employed, with inference results fused using a 0.7:0.3 probability weighting consistent with training. Training optimizations included weighted random sampling (WRS) for class balancing and exponential moving average (EMA) with delayed activation for improved generalization. The model achieved 94.39% accuracy, 0.950 macro-averaged F1-score, 0.964 weighted Kappa (QWK), and 0.985 mean Average Precision (mAP) on the test set, validating the power of image-based deep learning for cigar wrapper grading. This research provided technical foundations for optimizing grading systems and mobile deployment, and advanced automation and standardization in cigar production.Supplementary InformationThe online version contains supplementary material available at 10.1038/s41598-026-56083-7.Keywords: Cigar grading, Image classification, Deep learning, Model constructionSubject terms: Engineering, Mathematics and computing, Plant sciences Introduction Cigar is a kind of handmade products composed of cigar leaves, including wrapper, binder, and filler leaves1. Among these, the wrapper is the core component of the cigar, not only to protect and enhance its appearance but also to directly influence the cigar’s flavor2. High-quality wrappers possess excellent moisture absorption and release properties, maintaining humidity balance within the cigar and effectively preventing external damages such as mold and pests. Therefore, accurate grading of the wrapper is crucial for cigar production. The primary basis for grading cigar wrapper leaves includes many features such as color, position, structure, oil content, discoloration, damage, and maturity. Among these, color is one of the most important visual indicators. Studies have shown that during the drying and fermentation processes of cigar wrappers, color characteristics are significantly correlated with moisture content3,4. Additionally, differences in oil content are also considered a critical basis for grading5. The reliance on manual assessment for grading leads to strong subjectivity in grading outcomes and inconsistent standards, making it difficult to meet the modern agricultural requirements for standardized and efficient grading. Consequently, it’s urgent to develop a scientific, convenient, and intuitive method to identify wrapper grades for production. In recent years, image recognition has advanced rapidly, benefiting both from the effectiveness of traditional handcrafted features (e.g., color, texture, shape) in controlled settings and from the superior high-level semantic representations provided by large-scale pretrained deep models. Classical pipelines perform recognition by extracting color histograms, texture descriptors (e.g., LBP/GLCM), and shape contours and feeding them into shallow classifiers. Such methods are parameter-efficient, interpretable, and friendly to small datasets, but they have limited robustness to illumination or background changes, scale or deformation, and fine-grained differences, and they generalize poorly across domains compared with deep representations. Related surveys and studies in agricultural vision likewise note that a single handcrafted feature often hits performance ceilings in complex scenarios. By contrast, large-scale pretrained deep networks have become mainstream. By extracting image color6, texture7, shape8,9, and other features10,11 within a learnable framework, and combining them with deep learning, image classification can be accomplished efficiently. Deep models pretrained at scale—such as ConvNeXt12, ResNet13, and Transformer-based BEiT14, Swin15, and ViT16—have seen broad adoption in plant image classification. In tobacco leaf grading, DenseNet-based models leverage feature reuse mechanisms to capture fine-grained leaf characteristics, achieving high-accuracy recognition in automated flue-cured tobacco grading17, and in tea quality assessment, deep models augmented with attention mechanisms effectively capture subtle differences in bud/leaf morphology and color for grading and defect detection18. Overall, classification models based on deep image recognition offer efficient inference and mature engineering toolchains, making them suitable for real-time or near-real-time industrial applications. They deliver robust performance even with moderate-scale datasets, and thus serve as the baseline of choice for most quality-grading tasks, demonstrating both feasibility and superiority in appearance-based grading of agricultural products. However, researches on automatic grading for cigar wrapper leaves remain in the nascent stage, as existing methods for agricultural product classification struggle to directly accommodate their unique requirements. First, wrapper leaf images are susceptible to environmental interferences during acquisition, such as background noise from drying racks, fluctuations in lighting intensity, and shadows induced by leaf curling, making it challenging for traditional models to precisely focus on the primary leaf features19. Second, the grade distribution of wrapper leaves often exhibits significant imbalance, with high-grade samples comprising less than 10% of the dataset20, leading conventional sampling strategies to inadequately learn features from rare grades, thereby limiting generalization performance. Third, wrapper leaf grades possess a clear ordinal relationship (e.g., light brown to dark brown corresponding to increasing grades), which simple classification loss functions like cross-entropy fail to effectively model, resulting in reduced accuracy for distinguishing adjacent grades21. Furthermore, weight fluctuations during training can exacerbate misclassifications of boundary samples, while the variations in oil content and subtle color mottling in cigar wrapper leaves impose higher demands on model stability22. To address these challenges, this study proposes a deep learning framework integrated with multi-module optimizations for the automatic grading of cigar wrapper leaves. The core innovations include: incorporating a binary leaf mask to construct a four-channel input, thereby enhancing foreground feature attention; designing a dynamic weighted sampling strategy to balance class distributions; employing an exponential moving average (EMA) mechanism to stabilize model weight updates; and constructing a hybrid loss function combining cross-entropy (CE) and correlation alignment (CORAL) to synergistically optimize category discrimination and ordinal relationship modeling. The effectiveness of each module is validated through systematic ablation experiments, and the model’s performance is evaluated on a dataset of collected wrapper leaves. This approach aims to provide standardized and efficient grading solutions for cigar production, thereby advancing technological upgrades for the cigar industry. Materials and methods Data collection Image data of cigar tobacco leaves of the main variety FX-01 from the Liancheng and Yongding tobacco regions of Fujian Province, China were collected in 2023 and 2024. The images were uniformly captured in professional mode using multiple smartphone models, on a standard gray-white table background, with a resolution of 3024×4032 and ISO sensitivity set to 50. Different grades of cigar wrapper leaves were denoted as following: upper leaves as JYB1 (Grade 1), JYB2 (Grade 2), and JYB3 (Grade 3); middle leaves as JYC1 (Grade 1), JYC2 (Grade 2), and JYC3 (Grade 3); lower leaves as JYX1 (Grade 1), JYX2 (Grade 2), and JYX3 (Grade 3); and the lowest grade N for mixed color leaves, a total of 8637 images were collected (Table 1). Table 1Datasets for recognition model construction of cigar wrapper.Leaf positionLabelTrainingValidationTestingTotalUpper leavesJYB1505200254954JYB2507207178892JYB3510210224944Middle leavesJYC18002002001200JYC26002842071091JYC3562200126888Lower leavesJYX1485167195892JYX2538161174873JYX3537170196903 Datasets for recognition model construction of cigar wrapper. Wrapper leaf grading To ensure the objectivity and consistency of the grading standards, five experts familiar with cigar wrapper grading annotated the leaves under shadowless lighting conditions, and the final grade for each leaf was determined by calculating the mean value of all five experts’ scores. After unfolding the leaves, the key external characteristics such as maturity, oil content, integrity, and luster were observed. The integrity of the wrapper leaf is the highest priority, with the grading standard being no cracks or holes in the middle part of the leaf, and minor damage in the top and bottom 1/5 areas not affecting the grading. Leaf uniformity reflects the overall appearance of the cigar, with even leaf color being the best grade, followed by leaves with color spots or climate spots. By integrating expert experience, a comprehensive scoring system comprising eight indicators was constructed, with the weights as shown in Table 2. The comprehensive scoring formula is: The comprehensive scoring of cigar tobacco leaf quality is calculated using the formula: Where represents the assigned weight of the i- th indicator (as listed in Table 2),and represents the expert’s evaluation score for that indicator on a 100-point scale. Based on the comprehensive score, the leaves are classified into four grades: ≥85 points for Grade 1, 70-84 points for Grade 2, 60-69 points for Grade 3. Table 2Comprehensive scoring for the appearance quality of the wrapper.IndexMaturityOilIdentityCompletenessUniformityGlossVenationBlade structureWeight0.060.080.080.30.20.080.150.05 Comprehensive scoring for the appearance quality of the wrapper. Network architecture design Mask enhanced four channel input Considering that the imaging environment involves a light-colored paper background, where texture variations and illumination changes may interfere with classification accuracy, this study introduces a binary leaf mask obtained through simple thresholding and morphological operations. the image is first converted to the LAB color space. Otsu’s adaptive thresholding is applied to the A channel, followed by morphological closing operations, to generate a binary leaf mask. This mask is then concatenated with the original RGB channels to create a four-channel input (denoted as Mask4Ch). Based on this enhanced input, three completely separate and independent intelligent grading models were trained specifically for the upper, middle, and lower sections of the leaves, rather than simply partitioning the dataset for a single model. (Figure 1). To accommodate the four-channel input, the weights of the network’s initial convolutional layer are extended using a strategy where the first three channels inherit ImageNet pretrained weights, and the additional channel is initialized with the mean of the three-channel weights. This approach preserves the pretrained weight distribution while enabling the model to explicitly leverage foreground priors. The design facilitates end-to-end training while guiding the network to focus more on the leaf’s primary features in higher-level representations. Visualization of blade image processing flow. Backbone network and feature extraction This study used ResNet-50 pre-trained on ImageNet as the backbone network. Given an input image: , where C=3 represents standard RGB; In the configuration with added masks, C=4, and the fourth channel is a normalized blade binary mask.The input image is processed through the convolutional stem and the four residual stages (layer1, layer2, layer3, layer4) of ResNet-50 to extract the final semantic feature map:. To mitigate the over-parameterization issues arising from direct classification of high-dimensional representations and to provide a shared intermediate embedding for subsequent dual-head branches, this study introduces a lightweight projector() after Global Average Pooling (GAP), comprising a single linear transformation followed by LeakyReLU: Where is the weight matrix, is the bias term, f is the feature map from the backbone, and denotes the leakyReLU activation function. The resulting embedding serves as the shared input for the two classification heads during both training and inference phases. Parallel double headed: categorical classification and order relationship modeling To simultaneously capture both discrete categorical information and ordinal ranking, two lightweight classification heads are connected in parallel after the projector. One is the cross-entropy (CE) head, which employs a single fully connected layer to map the input to K-dimensional logits: The standard category probabilities are derived through being processed by the Softmax function during the inference stage: The other is the CORAL header (order relation header). Using CORAL (Consistent Rank Logits) thresholding, output K-1 independent binary logits: During training, independent Sigmoid and binary cross entropy are applied to each threshold to encode sequential information with a level greater than the threshold. When reasoning, according to CORAL’s cumulative rule, restore K-1 threshold probabilities to K-class probabilities: During training, the two branches independently minimize their respective losses (the polynomial cross-entropy and K-1 binary cross-entropy). The weights λCE and λOR are applied accordingly, and the total loss is then formed by a weighted sum: In the inference stage, we fuse the class distributions of the two branches by weighted average: Among them, is the fusion coefficient. The final category was obtained by . This design explicitly injects a level order prior while maintaining discrete discriminative ability, which can effectively alleviate confusion between adjacent levels. Figure 2 shows the visualization process of training a dual head model for network design.The detailed experimental operating environment is shown in Table 3. The core algorithmic pipeline was implemented using the open-source PyTorch framework running on a Linux environment. Image processing operations, including color space conversion and Otsu’s threshold segmentation, were orchestrated via the OpenCV library (https://opencv.org/), while advanced model architectures utilized for cross-backbone comparisons were fetched from the pretrained open-source timm repository (https://github.com/huggingface/pytorch-image-models). Visualization flowchart for model training. Table 3Experimental operating environment.CategoryEntriesVersionHardwareSystemUbuntu 18.04.1GPUNVIDIA GeForce RTX 3090SoftwarePython3.8Deep learning frameworkPyTorch 2.1.2CUDA11.2 Experimental operating environment. Training strategy To address class imbalance, a dynamic sampling strategy is applied. In the first 10 epochs, Weighted Random Sampling (WRS) is used, where sampling probabilities are inversely proportional to class frequencies, mitigating underrepresentation of minority classes. From epoch 11 onwards, Natural Sampling is employed to match the original data distribution, preventing over-reliance on weighted sampling and improving generalization. The model is optimized with the Adam optimizer, setting an exact initial learning rate of , batch size of 32, and 50 epochs. Learning rate scheduling uses ReduceLROnPlateau, reducing the learning rate by a factor of 0.5 if no improvement occurs for 3 consecutive epochs, down to a strict minimum learning rate of . Early stopping is applied with a patience of 10 epochs if the validation metric shows no significant improvement to prevent overfitting. Gradient clipping is used with a norm limit of 1.0 to alleviate gradient explosion. Code availability The custom code and the associated training and evaluation pipelines developed for this study are openly available in the GitHub repository at https://github.com/Ison-20/Cigar_classification.git. To ensure a permanently preserved version of the code at the time of publication, a snapshot of this repository has been deposited in the Zenodo archive and is publicly available under 10.5281/zenodo.20405266. There are no restrictions on access to or usage of the code. Results Characteristics of different grades of cigar tobacco leaves Based on the appearance features of cigar tobacco leaves, and the consistent annotation by grading experts, we obtained a total of 8637 images across 3 grades for three kinds of leaf positions, including upper leaves (JYB1, JYB2, JYB3), middle leaves (JYC1, JYC2, JYC3), lower leaves (JYX1, JYX2, JYX3). The image features of different grades are significantly distinct. For example, in the upper leaves (Figure 3). The leaves of JYB1 are generally intact, with moderate thickness, high glossiness, sufficient oil content, and uniform color. The main veins are straight and firm, and the lateral veins and intersecting subveins are clear and well-defined in terms of angle. The leaves of JYB2 are mostly intact, but they have slightly insufficient oil content and lower glossiness. Occasionally, there are small holes, and some areas of the leaf surface have spots. The main and lateral vein structures are less clear. The leaves of JYB3 show significant differences in harvesting maturity, characterized by narrow and small leaves, lack of glossiness, and the presence of weather spots and mildew. The main and subveins exhibit varying degrees of curling. These clear grading characteristics provide important reference data for the construction of the intelligent grading model. The character of the three level diagrams of the upper leaf. JYB1 exhibits high quality with integrity, oil gloss, and clear venation. JYB2 shows moderate quality with reduced gloss and minor flaws. JYB3 presents low quality, characterized by immaturity, narrow size, and visible mildew/spots. Systematic ablation results Validity verification of Mask4Ch (four channel input) Incorporating the automatically generated leaf binary mask as the fourth channel into the input leads to a stable performance improvement in the model. The test accuracy (Acc) increases from 0.9065 in A0 to 0.9128 in A2 (Experiment number shown in Table 4), with an absolute increase of 0.63 percentage points. The Macro-F1 score improves from 0.9157 to 0.9232, validating the positive effect of the explicit foreground prior (Fig. 1). This result suggests that the leaf mask helps the model effectively suppress background noise and lighting fluctuations, enhancing its ability to focus on the key features of the leaf area. Furthermore, the Grad-CAM visualization results further confirm that, after introducing the mask, the model’s higher-level feature responses are more concentrated on the critical textures and morphological regions of the leaf, reducing redundant learning of irrelevant background information (Fig. 4). Table 4A comparison of image classification performance on Cigar datasetIDMask4ChWRSEMAHead (infer)AccF1QWKmAPA0---CE (train=infer)0.90650.91570.95430.9669A1---CE+CORAL (equal)0.89410.90040.93720.9693A2√--CE+CORAL (equal)0.91280.92320.94850.9633A3√√-CE+CORAL (equal)0.89720.91050.94050.9632A4√√√CE+CORAL (0.7/0.3)0.94390.950.96380.9845 A comparison of image classification performance on Cigar dataset Qualitative results of attention maps generated by Grad-CAM Negative transfer effects and mitigation strategies of WRS Enabling Weighted Random Sampling (WRS) throughout the entire training cycle (A3) leads to significant negative transfer. Compared to A2, where WRS is not used, the test accuracy (Acc) drops from 0.9128 to 0.8972, showing a noticeable performance decline. A detailed analysis reveals that this phenomenon arises from a mismatch between the training and testing distributions—over-sampling of rare classes causes the model to fit "pseudo-correlation" to background textures and noise of minority class samples, weakening its ability to learn the true leaf-level features. To mitigate this issue, A4 adopts a "two-stage sampling strategy": WRS is used in the first half of training to accelerate the learning of rare class features, and from epoch 11 onward, the model switches to natural sampling to align with the real data distribution. This strategy effectively avoids the generalization drawbacks of pure WRS, laying a solid foundation for subsequent performance improvement. The stabilizing gain effect of EMA By incorporating the Exponential Moving Average (EMA) mechanism into the two-stage sampling strategy, the model achieves a significant performance boost. The test accuracy (Acc) increases by 4.67 percentage points (from 0.8972 to 0.9439), while Macro-F1 and mean Average Precision (mAP) improve by 3.95 and 2.13 percentage points, respectively (from 0.9105 to 0.9500 and from 0.9632 to 0.9845). EMA smooths the updates of weights during training, generating “teacher weights” with enhanced generalization capability. This is particularly evident in the model’s stability in distinguishing leaf-level boundaries, effectively reducing the impact of training fluctuations on model inference performance. Weight dependency analysis of order relation modeling The performance of sequence relationship modeling with CORAL loss is highly dependent on the weight ratio between CORAL loss and cross-entropy (CE) loss (Table.4). When equal weights are applied (λ_CE:λ_CORAL = 0.5:0.5), both the accuracy (Acc) of A1 (0.8941) and Macro-F1 (0.9004) are lower than the pure CE baseline (A0), indicating that excessive incorporation of sequential information can interfere with class discrimination. However, when the weight ratio is adjusted to λ_CE:λ_CORAL = 0.7:0.3, and combined with Mask4Ch, EMA, and the two-stage sampling strategy (A4), the model’s performance surpasses the baseline across all metrics: Acc increases by 3.74 percentage points compared to A0, with QWK and mAP reaching 0.9638 and 0.9845, respectively. These results confirm that sequence relationship information has auxiliary value for leaf-level classification, but it should be integrated with a smaller weight to complement the dominant role of CE loss. Optimal performance is achieved through the collaborative effect of multiple modules. Misclassification analysis and confusion matrix To further evaluate the model’s reliability in industrial applications, a normalized confusion matrix was generated (Fig. 5). The matrix illustrates that the model effectively minimizes severe misgrading (e.g., predicting Grade 1 as Grade 3, which occurs in less than 1% of cases). The majority of errors are restricted to adjacent-grade confusion (e.g., confusing Grade 2 with Grade 3), which aligns with the subtle boundary differences inherent in manual expert grading. Normalized confusion matrices illustrating misclassification patterns across different model configurations. Panels (A-E) correspond to experiments A0 to A4 from the ablation study. Performance comparison across different backbones To evaluate the generalizability of our proposed framework, we conducted comparative experiments across a diverse set of backbone architectures, including CNN-based models (ResNet-50, DenseNet-121, SE-ResNet-50) and Transformer-based models (ViT, Swin-Transformer). For each architecture, we compared the performance of a standard baseline (trained with CE loss) against our fully-equipped framework (integrating Mask4Ch, WRS, EMA, and the CE/CORAL hybrid loss).As shown in Table 5, the proposed framework consistently improved the performance of the tested CNN-based models. Notably, DenseNet-121 and ResNet-50 both achieved the highest accuracy of 94.39%. However, the framework did not yield similar gains for the Transformer-based models (ViT and Swin-T). Table 5Performance comparison of different backbone architectures with and without the proposed optimization framework.Architecture paradigmIDMask4ChWRSEMAHead (infer)AccF1QWKmAPConventional CNNsResNet50 baseline---CE (train=infer)0.90650.91570.95430.9669ResNet50 (Ours)√√√CE+CORAL (0.7/0.3)0.94390.950.96380.9845DenseNet-121 baseline---CE (train=infer)0.92210.93320.94870.9663DenseNet-121 (Ours)√√√CE+CORAL (0.7/0.3)0.94390.95180.95000.9788SE-ResNet-50 baseline---CE (train=infer)0.88160.89120.90780.9439SE-ResNet-50 (Ours)√√√CE+CORAL (0.7/0.3)0.90650.91950.94140.9575Patch-based modelsViT baseline---CE (train=infer)0.91590.92250.94950.9629ViT (Ours)√√√CE+CORAL (0.7/0.3)0.90340.90880.93520.9626Swin baseline---CE (train=infer)0.92830.93640.95080.9589Swin (Ours)√√√CE+CORAL (0.7/0.3)0.92520.93420.94950.9404 Performance comparison of different backbone architectures with and without the proposed optimization framework. Discussion This study proposes a deep learning method that integrates multi-module optimization for the tobacco leaf grading task and systematically evaluates the impact of each component on model performance through ablation experiments. The experimental results demonstrate that the effective integration of foreground prior information, sampling strategies, weight smoothing mechanisms, and hybrid loss functions significantly enhances both the accuracy and robustness of tobacco leaf grade classification. Furthermore, it is worth noting that this study fundamentally focuses on designing an efficient feature extraction and fusion strategy tailored specifically to the unique morphology of fermented cigar leaves. Multimodal feature fusion proves effective for improving model performance. By concatenating a binary leaf mask as a fourth channel to RGB (Mask4Ch), we inject an interpretable prior into the network without altering the backbone: the attention is “pulled back” to the leaf body, while interference from paper texture and illumination is attenuated. This observation is consistent with Grad-CAM visualizations23 (Fig. 4): at layer3/layer4, the RGB-only model is more easily attracted by background highlights and wrinkles, whereas the 4-channel model responds more strongly to the midrib and overall leaf shape. As shown by the A0→A2 ablation (Table 4), this yields stable gains (Acc +0.6 pp; F1 +0.75 pp). The finding echoes the “segment/explicitly guide then classify” paradigm reported by Chen and Yuan et al.24,25, where a foreground prior typically mitigates erroneous attention caused by background distribution shift and thus enhances stability for small-sample or fine-grained grading tasks. The dynamic adaptation of the sampling strategy reveals the double-edged nature of Weighted Random Sampling (WRS) under class imbalance. Using WRS throughout training (A2→A3) leads to degraded performance, primarily because aggressive over-sampling of rare classes induces a distribution shift and encourages overfitting to edge-case textures, which then harms generalization at test time. Consistent with prior findings by Cui and Kang et al.26,27, full-course WRS reduces accuracy from 0.9128 to 0.8972. In contrast, the two-stage regime adopted in A4—WRS in the early phase to accelerate minority-class learning, followed by natural sampling to realign with the true distribution—both mitigates class imbalance and preserves distributional consistency between training and deployment. This two-stage WRS strategy offers an effective solution to the commonly observed grade-imbalance problem in cigar-leaf datasets. EMA plays a pivotal role in stabilizing the model. In the A3→A4 ablation, introducing EMA yields a clear performance jump—Acc improves by 4.67 percentage points (Table 4)—underscoring the importance of weight smoothing for cigar‐leaf grading. Theoretically, Polyak averaging reduces the variance of stochastic optimization and converges to more robust solutions28; in deep learning, Mean Teacher extends EMA to a teacher–student paradigm29, showing strong gains under noise and limited supervision. Because the decision boundaries between adjacent grades are intrinsically fuzzy (subtle differences in color, oiliness, and wrinkling), late‐stage weight oscillations can flip borderline samples. By providing a smoothed teacher, EMA stabilizes such cases, thereby improving QWK and Macro-F1. In A4, we additionally synchronize BN statistics for the EMA weights, further enhancing robustness to illumination shifts and geometric deformations—capabilities that are particularly important for the morphological variability encountered in real production settings. The CORAL loss is well aligned with the dual requirement of cigar-leaf grading—clear categorical assignment while respecting ordinal structure. Our mixed-loss ablations (A0/A1 vs. A4) show that relation modeling must be properly weighted against categorical discrimination. With equal weights (A1), CORAL underperforms, indicating that over-emphasizing ordinal constraints can weaken discrete class separability. In contrast, setting the ratio to 0.7:0.3 (CE:CORAL) yields complementary behavior: CE dominates category discrimination, while CORAL regularizes the decision with ordinal priors, producing stronger performance especially on highly similar adjacent grades (e.g., Grade-2 vs. Grade-3). This matches the positioning of CORAL in the literature30: ordinal information works best as a regularizer and auxiliary signal for the primary classifier, rather than a replacement. Mis-tuned weights, however, can suppress discrete discrimination and degrade overall accuracy. To further justify the architectural design and validate the generalization of our proposed framework, we conducted extensive comparative experiments across diverse backbone paradigms. Specifically, we evaluated orthodox dense convolutional networks (DenseNet-121, SE-ResNet-50) alongside modern architecture families utilizing “Patchify” stems or strict depthwise isolation (Swin-T, ViT).The empirical results revealed a profound architectural synergy. Our proposed framework consistently and significantly improved the performance of the tested orthodox CNNs over their respective baselines. Notably, through our multi-module framework, both ResNet-50 and DenseNet-121 achieved the peak dataset accuracy of 94.39%. Conversely, the framework induced performance degradation when applied to Swin-T and ViT. This divergence fundamentally stems from differing inductive biases: our Mask4Ch module explicitly relies on precise, pixel-level spatial boundaries to guide foreground focus. Orthodox CNNs, utilizing overlapping sliding-window convolutions in their initial layers, preserve and exploit these crisp spatial priors perfectly. In contrast, the non-overlapping “Patchify” mechanisms in modern ViTs and Swin mechanically fracture the continuous boundaries of the binary mask, injecting conflicting spatial signals. These findings demonstrate the framework’s compatibility with standard convolutional paradigms, showing consistent performance gains across several widely-used backbones. Given that ResNet-50 achieves the global maximum accuracy while maintaining superior hardware acceleration compatibility (e.g., lower Memory Access Cost) compared to DenseNet, it scientifically justifies ResNet-50 as the optimal backbone for real-time industrial cigar grading deployment. The images in our dataset consists of a single cultivar (FX-01) collected solely from Fujian Province within a limited two-year span (2023-2024). This constrained varietal and geographic diversity may limit the model’s immediate generalization to other cigar strains. Furthermore, while the current evaluation relies on a single dataset split, we incorporated advanced regularization mechanisms to rigorously ensure model robustness and prevent overfitting to a specific data subset. Most notably, these include the Exponential Moving Average (EMA) for weight stabilization, extensive data augmentation, and validation-based early stopping. Future work will expand the dataset across multiple collection years to refresh the corpus and increase the image library size, thereby improving robustness to temporal and environmental drift31. In parallel, we will optimize the imaging protocol—for example, enhancing bottom illumination to capture richer cues related to leaf compactness, oil content, and impurities, and fixing the camera–leaf distance to reduce scale variance due to leaf size32. Continuous enrichment of the image data, together with iterative model upgrades, will lay the groundwork for the intelligent and industrialized production of cigars and support the sustainable development of the domestic cigar industry. Conclusion This study develops a deep learning framework with multi-module optimization, significantly improving the accuracy and robustness of tobacco leaf grading. The introduction of the binary leaf mask as the fourth channel notably enhances the model’s ability to focus on foreground features, suppressing background noise and providing an effective prior for the grading task. The dynamic sampling strategy (early WRS + later natural sampling) effectively balances the issues of class imbalance and distribution alignment, avoiding the generalization performance degradation associated with pure weighted sampling. The Exponential Moving Average mechanism, by smoothing weight updates and stabilizing batch normalization statistics, significantly enhances decision stability on boundary samples, serving as a key factor in the performance boost. The hybrid loss function combining CE and CORAL (with a weight ratio of 0.7:0.3) facilitates the collaborative optimization of class discrimination and sequence relationship modeling, better aligning with the grade characteristics of tobacco leaves. The optimized model (A4) achieves a test accuracy of 94.39% and a QWK score of 96.38%, validating the effectiveness of the proposed method. Notably, architectural evaluations demonstrate that our method yields significant performance gains on some CNN architectures. This research provides a reusable technical framework for agricultural product quality grading tasks, with future improvements possible through the incorporation of attention mechanisms and data augmentation strategies to further enhance the model’s ability to discern subtle features. Supplementary Information Supplementary Information. Author contributions Conceptualization, X.X.; methodology, C.D. and R.W.; investigation, T.W., F.S., R.L. and X.L.; writing—review and editing, R.W., N.L., Y.S.; supervision, X.X., N.L.; project administration, C.D. All authors have read and agreed to the published version of the manuscript. Funding This research was funded by Longyan Tobacco Company (LK-2022Y06; LK-2022Y02). Data availability Both the data and the pre-trained odel weights/code that support the findings of this study are available from the corresponding author upon reasonable request. Declarations Competing interests The authors declare no competing interests. Consent interests All experts who participated in this study were fully informed about the aims and procedures of the research and provided their voluntary informed consent prior to participation. Copies of their signed Informed Consent Statements have been provided in the attached file. Footnotes Publisher’s note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations. Contributor Information Xiaofang Xie, Email: xxf317@fafu.edu.cn. Nannan Liu, Email: nannanliu@fafu.edu.cn. References Associated Data Supplementary Materials Supplementary Information. Data Availability Statement Both the data and the pre-trained odel weights/code that support the findings of this study are available from the corresponding author upon reasonable request.