A method and system for grouping flue-cured tobacco using characteristic channel weighting and dynamic loss regulation

By employing feature channel weighting and dynamic loss regulation, the problems of insufficient key feature representation and limited inter-class discrimination ability in deep learning-based flue-cured tobacco grouping were solved, thereby improving the classification efficiency and accuracy of flue-cured tobacco grouping and reducing the cost of manual grading.

CN116385734BActive Publication Date: 2026-06-30KUNMING UNIV OF SCI & TECH +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
KUNMING UNIV OF SCI & TECH
Filing Date
2023-03-24
Publication Date
2026-06-30

AI Technical Summary

Technical Problem

Existing deep learning methods for grouping flue-cured tobacco lack key feature representation in high-scale features, have limited inter-class discrimination capabilities, and tend to learn majority class samples during training.

Method used

By employing feature channel weighting and dynamic loss control, a class rebalancing strategy and dynamic margin are introduced into the TGNet flue-cured tobacco group classification network to construct FADM loss, thereby improving the classification accuracy of minority class samples and enhancing inter-class discrimination ability.

Benefits of technology

It enables real-time classification of flue-cured tobacco groups, improving classification efficiency and reducing manual grading costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116385734B_ABST
    Figure CN116385734B_ABST
Patent Text Reader

Abstract

This invention provides a method and system for grouping flue-cured tobacco using feature channel weighting and dynamic loss control, relating to the fields of deep learning and flue-cured tobacco grading. The method involves acquiring images of flue-cured tobacco from N main groups using an image acquisition device to establish a flue-cured tobacco grouping dataset, where N is a positive integer. This dataset is then preprocessed to obtain a preprocessed dataset. A flue-cured tobacco grouping classification network (TGNet) is designed and trained on the preprocessed dataset to obtain a flue-cured tobacco grouping classification model. Based on this model, the grouping results are obtained. This invention solves the technical problems of existing deep learning methods for flue-cured tobacco grouping, such as lack of key feature representation in high-scale features, limited inter-class discrimination ability, and a tendency for the model to learn from majority class samples during training. It achieves real-time classification of flue-cured tobacco groups, effectively improving the efficiency of flue-cured tobacco group classification and reducing the cost of manual grading.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of deep learning and flue-cured tobacco grading technology, specifically to a method and system for grouping flue-cured tobacco using feature channel weighting and dynamic loss control. Background Technology

[0002] In my country, the main model for tobacco production, purchasing, and allocation involves tobacco farmers initially grading their own tobacco leaves and then selling them to tobacco purchasing stations. Tobacco companies then allocate the leaves to cigarette factories, with enterprises generally not conducting secondary grading. Therefore, the initial grading by tobacco farmers is crucial. Tobacco grading distinguishes tobacco leaves of different qualities, ensuring each grade has relatively consistent quality for the cigarette industry, facilitating the rational use of national resources, and giving different qualities of tobacco leaves different use and economic values. This reflects the principle of pricing based on quality, promoting tobacco production. Accurate grading requires proper grouping. Only by clearly identifying groups can tobacco leaves be classified into several grades according to quality regulations. Currently, advanced tobacco-producing countries worldwide consider grouping an indispensable procedure in their flue-cured tobacco grading standards. Flue-cured tobacco grouping is based on the leaf part, color, and other key characteristics related to overall quality, further dividing tobacco leaves within the same type. The purpose of grouping is to differentiate tobacco leaves with different properties and characteristics, ensuring that leaves within each group share major common characteristics and have relatively similar intrinsic quality. After grouping, grading becomes relatively simple, easy to operate and master, and grouping also benefits industrial processing and cigarette formulation. However, the currently used grouping methods for flue-cured tobacco still have certain drawbacks, and there is still room for improvement in flue-cured tobacco grouping.

[0003] Existing deep learning methods for grouping flue-cured tobacco suffer from technical problems such as a lack of key feature representation in high-scale features, limited inter-class discrimination ability, and a tendency for the model to learn majority class samples during training. Summary of the Invention

[0004] This application provides a method and system for grouping flue-cured tobacco using feature channel weighting and dynamic loss control, which addresses the technical problems of existing deep learning flue-cured tobacco grouping methods, such as lack of key feature representation in high-scale features, limited inter-class discrimination ability, and the tendency of the model to learn majority class samples during training.

[0005] In view of the above problems, embodiments of this application provide a method and system for grouping flue-cured tobacco using feature channel weighting and dynamic loss control.

[0006] In a first aspect, embodiments of this application provide a method for grouping flue-cured tobacco using feature channel weighting and dynamic loss control. The method includes: acquiring flue-cured tobacco images of N main groups using an image acquisition device to establish a flue-cured tobacco grouping dataset, where N is a positive integer; performing data preprocessing on the flue-cured tobacco grouping dataset to obtain a preprocessed dataset; designing a flue-cured tobacco grouping classification network TGNet; training the preprocessed dataset using the flue-cured tobacco grouping classification network TGNet to obtain a flue-cured tobacco grouping classification model; and obtaining flue-cured tobacco grouping results based on the flue-cured tobacco grouping classification model.

[0007] Secondly, embodiments of this application provide a flue-cured tobacco grouping system with feature channel weighting and dynamic loss control. The system includes: a flue-cured tobacco image acquisition module, which acquires flue-cured tobacco images of N main groups using an image acquisition device to establish a flue-cured tobacco grouping dataset, where N is a positive integer; a data preprocessing module, which preprocesses the flue-cured tobacco grouping dataset to obtain a preprocessed dataset; a classification network construction module, which designs a flue-cured tobacco grouping classification network TGNet; a classification model construction module, which trains the preprocessed dataset using the flue-cured tobacco grouping classification network TGNet to obtain a flue-cured tobacco grouping classification model; and a grouping result acquisition module, which acquires flue-cured tobacco grouping results based on the flue-cured tobacco grouping classification model.

[0008] One or more technical solutions provided in the embodiments of this application have at least the following technical effects or advantages:

[0009] This application provides a method for grouping flue-cured tobacco using feature channel weighting and dynamic loss regulation, relating to the fields of deep learning and flue-cured tobacco grading. It involves acquiring images of flue-cured tobacco from N main groups using an image acquisition device to establish a flue-cured tobacco grouping dataset, where N is a positive integer. The dataset is preprocessed to obtain a preprocessed dataset. A flue-cured tobacco grouping classification network (TGNet) is designed and trained on the preprocessed dataset to obtain a flue-cured tobacco grouping classification model. Based on this model, the grouping results are obtained. This method solves the technical problems of existing deep learning methods for flue-cured tobacco grouping, such as lack of key feature representation in high-scale features, limited inter-class discrimination ability, and a tendency for the model to learn from majority class samples during training. It achieves real-time classification of flue-cured tobacco groups, effectively improving the efficiency of flue-cured tobacco group classification and reducing the cost of manual grading.

[0010] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the following are specific embodiments of this application. Attached Figure Description

[0011] Figure 1 This application provides a schematic flowchart of a method for grouping flue-cured tobacco using feature channel weighting and dynamic loss control.

[0012] Figure 2 This application provides a schematic diagram illustrating the process of establishing a flue-cured tobacco grouping dataset in a method for grouping flue-cured tobacco using feature channel weighting and dynamic loss control.

[0013] Figure 3 This application provides a schematic diagram of the process for obtaining a preprocessed dataset in a method for grouping flue-cured tobacco using feature channel weighting and dynamic loss control.

[0014] Figure 4 This application provides a schematic diagram of a flue-cured tobacco grouping system with feature channel weighting and dynamic loss control.

[0015] Figure labeling: 10 for flue-cured tobacco image acquisition module, 20 for data preprocessing module, 30 for classification network construction module, 40 for classification model construction module, and 50 for grouping result acquisition module. Detailed Implementation

[0016] This application provides a method for grouping flue-cured tobacco using feature channel weighting and dynamic loss control. This method addresses the technical problems of existing deep learning methods for grouping flue-cured tobacco, such as the lack of key feature representation in high-scale features, limited inter-class discrimination ability, and the tendency of the model to learn majority class samples during training.

[0017] Example 1

[0018] like Figure 1 As shown, this application provides a method for grouping flue-cured tobacco using feature channel weighting and dynamic loss control. This method is applied to a flue-cured tobacco grouping system using feature channel weighting and dynamic loss control, which is communicatively connected to an image acquisition device. The method includes:

[0019] Step S100: Acquire images of flue-cured tobacco from N main harvesting groups using an image acquisition device, and establish a flue-cured tobacco group dataset, where N is a positive integer;

[0020] Specifically, the flue-cured tobacco grouping method with feature channel weighting and dynamic loss control provided in this application embodiment is applied to the flue-cured tobacco grouping system with feature channel weighting and dynamic loss control. The flue-cured tobacco grouping system with feature channel weighting and dynamic loss control is communicatively connected to an image acquisition device, which is used to acquire images of flue-cured tobacco samples. Preferably, in this application embodiment, an industrial area array camera is used to capture flue-cured tobacco images.

[0021] First, the flue-cured tobacco used for image acquisition was randomly sampled from the purchased flue-cured tobacco by more than ten grading experts. Using an industrial area array sensor and a 5-megapixel camera, images of the flue-cured tobacco were captured on a moving conveyor belt, establishing a grouped dataset. Through the acquisition of these images, a preliminary understanding of the flue-cured tobacco was achieved, laying the foundation for subsequent grouping.

[0022] Step S200: Perform data preprocessing on the flue-cured tobacco group dataset to obtain a preprocessed dataset;

[0023] Specifically, the images of flue-cured tobacco output from industrial cameras are converted to a size suitable for input to the network model. A program randomly divides all images into two sets: a portion for testing (the test set) and another portion randomly divided into a training set and a validation set during model training. After each iteration, the model's accuracy is tested on the validation set. The model with the highest average classification accuracy on the validation set is then tested on the test set. The results from the test set are used to define the model's precision.

[0024] By preprocessing data, unnecessary data redundancy can be effectively reduced, storage and computing costs in the system can be lowered, thereby improving the efficiency of data use.

[0025] Step S300: Design the TGNet network for classifying flue-cured tobacco groups;

[0026] Specifically, to address the issue that the high-scale features output lack the ability to represent key information due to increased network depth, the improved module CWstage is used to replace the cascaded Bottleneck module in the baseline network Stage-S4. This enhances the ability of the network's high-scale abstract features to represent key information. The CWstage module generates weighted features for the corresponding feature channels to achieve recoding of scale features, highlighting key color and spatial region information, and avoiding the problem of key information loss caused by multiple sampling in the original baseline network.

[0027] To address the issue that the established flue-cured tobacco group dataset has a long-tail distribution and the model training is biased towards learning majority class samples, a class rebalancing strategy is introduced to reconstruct the loss function. By giving minority class samples a greater weight in the loss calculation, the influence of minority class samples on the loss calculation is increased, thereby improving the classification accuracy of minority class samples.

[0028] To address the issue of sample similarity in the constructed tobacco group classification dataset, a dynamic margin is introduced into the loss calculation to provide strong constraints for network training. The dynamic margin changes with the network output. A larger margin is generated in the early stage of network training to improve the network's ability to distinguish similar samples, while a smaller margin is generated in the early stage of network training to promote network convergence. By introducing a dynamic margin, the model achieves a better balance between class accuracy and performance.

[0029] We construct FADM loss, which adds class weight factors and dynamic margins to the multi-class cross-entropy loss to implement a class rebalancing strategy. This improves the accuracy of small sample classification while achieving a better balance between class accuracy and accuracy.

[0030] By integrating channel weighting and dynamic loss control, a tobacco group classification network (TGNet) is designed. The design of TGNet effectively improves the classification efficiency of flue-cured tobacco groups.

[0031] Step S400: Train the preprocessed dataset using the flue-cured tobacco group classification network TGNet to obtain the flue-cured tobacco group classification model;

[0032] Specifically, the preprocessed dataset includes a training set, a validation set, and a test set. The training set is used to train the model; to reduce generalization error, the model is continuously trained on the training set to better approximate real data. The validation set is used to test the model's accuracy; applying the test set to the model trained on the training set yields a score. The model is trained on the TGNet network using the training set. After each iteration, the model's accuracy and testing speed are tested using the validation set. The accuracy scores of multiple models are compared against the input data, and the model with the highest accuracy is selected as the final model.

[0033] Step S500: Obtain the grouping results of flue-cured tobacco based on the flue-cured tobacco group classification model.

[0034] Specifically, the final model and testing program are invoked to test the flue-cured tobacco sample images in the test set, obtaining the classification results for flue-cured tobacco groups. This solves the technical problems of existing deep learning methods for grouping flue-cured tobacco, such as lack of key feature representation in high-scale features, limited inter-class discrimination ability, and the tendency of the model to learn majority class samples during training. Real-time classification of flue-cured tobacco groups is achieved, effectively improving the efficiency of flue-cured tobacco group classification and reducing the cost of manual grading.

[0035] Furthermore, such as Figure 2 As shown, step S100 of this application further includes:

[0036] Step S110: Obtain flue-cured tobacco samples;

[0037] Step S120: Acquire an image of the flue-cured tobacco sample using an image acquisition device to obtain flue-cured tobacco sample image information;

[0038] Step S130: Obtain tobacco group information;

[0039] Step S140: Group the flue-cured tobacco sample image information based on the flue-cured tobacco group information to establish the flue-cured tobacco group dataset.

[0040] Specifically, the flue-cured tobacco samples are used for data collection. They are randomly sampled from the purchased flue-cured tobacco by more than ten grading experts. There is no focus on sampling any particular group of flue-cured tobacco. Therefore, the number of flue-cured tobacco samples collected from each group will match the probability of that group of flue-cured tobacco appearing in its natural state.

[0041] The color rendering properties of tobacco can deviate under different color temperatures. Therefore, images need to be acquired under a stable light source to ensure color constancy. Thus, image acquisition is performed in a darkroom to eliminate interference from ambient light. Preferably, the entire image acquisition system includes an industrial area array image sensor, an 8mm fixed-focus lens, an LED light source, a conveyor belt, a conveyor belt motor, a computer, and a PLC. It acquires images of flue-cured tobacco samples from five main groups: orange-yellow flue-cured tobacco (F), lemon-yellow flue-cured tobacco (L), mixed-color flue-cured tobacco (K), slightly bluish flue-cured tobacco (V), and bluish-yellow flue-cured tobacco (GY).

[0042] By acquiring images of flue-cured tobacco, we gained a preliminary understanding of the tobacco species, laying the foundation for subsequent grouping.

[0043] Furthermore, such as Figure 3 As shown, step S200 of this application further includes:

[0044] Step S210: Convert the flue-cured tobacco sample image information into a size suitable for the input of the network model, and obtain an adjusted set of flue-cured tobacco sample images;

[0045] Step S220: Randomly divide the set of adjusted flue-cured tobacco sample images to obtain a first test sample set, a first sample training set, and a first sample verification set;

[0046] Step S230: Use the first test sample set, the first sample training set, and the first sample validation set as the preprocessing dataset.

[0047] Specifically, the 2384×1528 flue-cured tobacco sample image information output by the industrial camera is converted into a 224×224 size suitable for the input of the network model, and the input features are converted into tensor format. Finally, the features are normalized, with the mean values ​​of the three channels used for normalization being 0.485, 0.456, and 0.406, and the standard deviations being 0.229, 0.224, and 0.225, respectively. These are used to adjust the flue-cured tobacco sample image set.

[0048] The adjusted collection of flue-cured tobacco sample images was divided into a first test set, a first training set, and a first validation set. Using a program, all images were randomly divided at a 9:1 ratio, with 10% of the images used as the test set for testing, and the remaining 90% randomly divided into the first training set and the first validation set at an 8:2 ratio during model training. After each iteration, the model's accuracy was tested on the first validation set. The model with the highest average classification accuracy on the first validation set was then tested on the first test set. The results from the first test set were used to define the model's accuracy.

[0049] Furthermore, step S300 of this application also includes:

[0050] Step S310: Generate weighted features for the corresponding feature channels through the feature channel weighting module CWstage;

[0051] Step S320: Construct the FADM loss module;

[0052] Step S330: Fuse the weighted features of the feature channels and the FADM loss module to construct the flue-cured tobacco group classification network TGNet.

[0053] Specifically, in the CWstage module, the input features are downsampled to 7×7 by convolutional layers. A branch is added to perform channel weighting on the output high-scale features to ensure that the high-scale features are encoded to generate their own channel weight factors. The input to the added branch relies on an average pooling (Avgpool) layer to capture global information, thereby compressing the high-scale features from 7×7 to 1×1. Subsequently, the feature maps are encoded by a multilayer perceptron (MLP) to generate channel weight factors that will be assigned to each feature channel. In particular, the channel weight factors are multiplied by the high-scale features of each channel, in which way the weighted large-scale features are used as the output of the CWstage module.

[0054] To address the issue of the long-tailed distribution in the constructed flue-cured tobacco grouping dataset, which leads to model training bias towards learning majority class samples, a class rebalancing strategy is introduced to reconstruct the loss function. By assigning greater weight to minority class samples in the loss calculation, the influence of minority class samples on the loss calculation is increased, thereby improving the classification accuracy of minority class samples. Hyperparameter tuning experiments were conducted to evaluate different weighting factors as hyperparameter settings to suit the flue-cured tobacco grouping task on the constructed dataset.

[0055] To address the issue of high similarity among different groups of flue-cured tobacco and low network discrimination against similar samples, a dynamic margin term is introduced into the classification loss function to reduce the probability of misclassification due to similarity. Considering that different samples in the dataset have different false positive rates due to similarity, it is inappropriate to calculate the loss for each sample using a fixed margin. Therefore, the difference in class discrimination probabilities output by the network is used as a measure of similarity between the current class and other classes, and this similarity is encoded into the margin of the current sample using a cosine function to calculate the loss. Since the class discrimination probability of each sample is different, the margin can dynamically change according to the network output for each sample. Specifically, a larger margin leads to stricter classification constraints, which is achieved by adjusting the margin to impose a stronger penalty during network training.

[0056] The established flue-cured tobacco grouping dataset exhibits a long-tailed distribution. To address this issue, a class rebalancing strategy is designed, which reduces the proportion of the majority class in the total loss calculation by applying greater weights to the minority class. Furthermore, based on AM-Softmax loss, a dynamic margin is defined for each class, penalizing the loss calculation and helping to increase the inter-class distance between each class and other classes. By introducing the class rebalancing strategy and dynamic margin into the classification loss, FADM loss is constructed.

[0057] Furthermore, step S310 of this application also includes:

[0058] Step S311: Feed the features from stage-S3 into ConvBNAct to obtain the initial features;

[0059] Step S312: Obtain high-scale features based on the initial features;

[0060] Step S313: Generate channel weight factors through the Avgpool layer and MLP layer;

[0061] Step S314: Perform channel weighting on the high-scale features based on the channel weighting factors, and output the weighted features.

[0062] Specifically, the Bottleneck module in Stage_S4 is replaced by the CWstage module. This module contains only three structures: ConvBNAct, Avgpool, and MLP, and has only one layer, resulting in significant compression of the model depth. The Stage-S3 output features are processed by ConvBNAc: feature downsampling is performed using a 1×1 convolution with a stride of 2, while channel expansion is applied, resulting in a feature size of 7×7 and 368 channels. After convolution, the features are sequentially processed through BN and ReLU layers. After ConvBNAct, the features are divided into two branches. Branch one involves cross-layer concatenation followed by channel weighting, while branch two involves average pooling and multilayer perceptron processing to generate channel weighting factors. The calculation process for the sampled output is shown below:

[0063]

[0064] in, This is the output of stage-S3. This is the feature mentioned in the subsequent channel weighting.

[0065] Channel weight factors are generated through Avgpool and MLP layers, and the features are then weighted by channel to output weighted features. The calculation formula is shown below:

[0066]

[0067] in Represents the matrix dot product. It is a weighted feature of the CWstage output. Channel weight factors are generated through Avgpool and MLP layers. The Avgpool layer extracts global information from the features, which is helpful for flue-cured tobacco groups that require global information. The MLP layer consists of 1×1 convolutions with a stride of 1 and GELU. GELU is a combination of ReLU and Dropout. GELU introduces more randomness into the activation function, making the model training process more robust. MLP, on the other hand, facilitates channel information interaction between global features, increasing the non-linear expression of the features.

[0068] Furthermore, step S320 of this application includes:

[0069] Step S321: Introduce a class rebalancing strategy to reconstruct the loss function, given different weighting factors in the loss calculation for the flue-cured tobacco group dataset;

[0070] Step S322: Introduce dynamic margin;

[0071] Step S323: By reconstructing the loss function and the dynamic margin by introducing the class rebalancing strategy into the classification loss, the FADM loss module is obtained, as shown in the following formula:

[0072]

[0073] in, n is the number of samples used for loss calculation, C=5 corresponds to the number of groups in the flue-cured tobacco group dataset, a yi Corresponding to the weights of the flue-cured tobacco group dataset, λ is the focusing parameter and s is the scaling factor.

[0074] Specifically, the flue-cured tobacco used in the constructed dataset was obtained through random sampling by experts, without focusing on any particular group. Therefore, the number of flue-cured tobacco samples collected from each group corresponds to the probability of that group's occurrence in its natural state. Specifically, among the sampled flue-cured tobacco, the orange-yellow (F) and lemon-yellow (L) varieties from the positive group and the K variety from the sub-group were more numerous, while the slightly bluish (V) and bluish-yellow (GY) varieties from the sub-group were less numerous. During model training, the majority class samples dominated the loss calculation, and the model tended to learn from the majority class samples. To address this, a class rebalancing strategy was introduced. By giving different weight factors to the five groups of flue-cured tobacco in the loss calculation, the loss was reconstructed. Greater weights were given to the minority class (V) and GY samples, increasing the contribution of minority class samples to the loss and correspondingly reducing the influence of the majority class on the loss calculation, thus increasing the model's attention to minority class samples.

[0075] A hyperparameter tuning experiment was set up to evaluate different weighting factors as hyperparameter settings to make them suitable for the tobacco grouping task of the constructed dataset.

[0076] Nine sets of experiments were conducted. In the first set, weight factors for the five classes were set using inverse frequency methods. The other experiments focused on demonstrating the feasibility of improving minority class classification accuracy by increasing the weight factor of the minority class. Using the weight factor settings from the first set as a baseline, starting from the second set, the weight factor for the minority class was gradually increased from 0.25 to 0.95. The weight factor settings and test accuracy are shown in Table 1.

[0077] Table 1 Weighting factor adjustment experiment 1

[0078]

[0079] Setting a uniform weighting factor based on the inverse class frequency reduces performance. Furthermore, the classification accuracy of flue-cured tobacco is affected by the weighting factor setting. When the weighting factor is the same for each group of flue-cured tobacco, the classification accuracy of the majority class F is significantly higher than that of other groups. In contrast, when the weighting factor of the minority class increases, the classification accuracy of group F decreases, while the classification accuracy of the minority class V increases significantly. According to Table 1, it is feasible to improve the classification accuracy of the minority class by increasing the weighting factor corresponding to the minority class. Therefore, the weighting factors of groups L and K were appropriately increased to 0.40 and 0.30, respectively, and the weighting factor of the minority class was increased to 0.35. Based on the new baseline settings, ten experiments were conducted. The experimental results are shown in Table 2.

[0080] Table 2 Weighting Factor Adjustment Experiment 2

[0081]

[0082] The difference in class discrimination probabilities from the network output is used as a measure of similarity between the current class and other classes, and this similarity is encoded into the margin of the current sample using a cosine function to calculate the loss. Since the class discrimination probability is different for each sample, the proposed dynamic margin can dynamically change according to the network output for each sample.

[0083] We construct FADM loss, which adds class weight factors and dynamic margins to the multi-class cross-entropy loss to implement a class rebalancing strategy. This improves the accuracy of small sample classification while achieving a better balance between class accuracy and accuracy.

[0084] To address the issues of imbalanced samples and high similarity in the constructed dataset, a class rebalancing strategy was designed. This strategy reduces the proportion of head classes in the total loss calculation by applying greater weight to tail classes. Simultaneously, a dynamic margin is defined for each class, penalizing the loss calculation and helping to increase the inter-class distance between each class and other classes. By introducing the class rebalancing strategy and dynamic margin into the classification loss, the FADM loss is obtained as follows:

[0085]

[0086] in, n is the number of samples used for loss calculation, C=5 corresponds to the number of groups in the flue-cured tobacco group dataset, a yi Corresponding to the weights of flue-cured tobacco categories F, L, K, V, and GY, λ is the focusing parameter, and s is the scaling factor used to improve the loss convergence speed. The prediction score of the i-th sample in the TGNet Head module is represented as cosθ. i ∈R 1×5 cosθ iThe output features of the final linear layer of the Head module are obtained by feature normalization and weight normalization encoding. The target logit cosθ is generated. i When the confidence score is ∈R, an additional margin m is added to the target logit. yi ∈R + To impose stricter constraints on cosθ during the training of the TGNet. i -m yi >cosθ j Instead of cosθ yi >cosθ j Table 3 compares three loss methods: Softmax, AM-Softmax, and Focal loss. Each loss method uses RegNet as the training network, and all losses employ the same hyperparameter settings. The experimental results comparing different losses on the flue-cured tobacco group dataset are shown in Table 3.

[0087] Table 3 Comparison of different losses on the flue-cured tobacco group dataset

[0088]

[0089] Based on the above experiments, it can be concluded that using FADM to train the baseline network RegNet can significantly improve the classification accuracy of minority class samples and achieve a better balance between class accuracy and accuracy.

[0090] Furthermore, step S322 of this application also includes:

[0091] Step S3221: The formula for generating the dynamic margin is as follows:

[0092]

[0093] Among them, similarity measurement The absolute value of the difference between the target confidence score and other confidence scores will be used to predict the score cosθ. i The input is fed into the Softmax function to obtain the confidence vector P of the i-th sample. i ∈R 1×5 By applying the cosine function to the minimum P j SM Encoding obtains dynamic

[0094] Specifically, the difference in class discrimination probabilities from the network output is used as a similarity measure between the current class and other classes, and a cosine function is used to encode this similarity into the margin of the current sample to calculate the loss. Since the class discrimination probability is different for each sample, the proposed dynamic margin can dynamically change according to the network output for each sample. The formula for generating the dynamic margin is as follows:

[0095]

[0096] Among them, similarity measurement The absolute value of the difference between the target confidence score and other confidence scores will be used to predict the score cosθ. i The input is fed into the Softmax function to obtain the confidence vector P of the i-th sample. i ∈R 1×5 By applying the cosine function to the minimum P j SM Encoding obtains dynamic

[0097] By introducing dynamic margins into the loss calculation, strong constraints are provided for network training. The dynamic margins change with the network output. Larger margins are generated in the early stages of network training to improve the network's ability to distinguish similar samples, while smaller margins are generated in the early stages of network training to promote network convergence. By introducing dynamic margins, the model achieves a better balance between class accuracy and network performance.

[0098] Example 2

[0099] Based on the same inventive concept as the tobacco grouping method with feature channel weighting and dynamic loss control in the aforementioned embodiments, such as Figure 4 As shown, this application provides a flue-cured tobacco grouping system with feature channel weighting and dynamic loss control. The system includes:

[0100] The flue-cured tobacco image acquisition module 10 is used to acquire flue-cured tobacco images of N main collection groups through an image acquisition device and establish a flue-cured tobacco group dataset, where N is a positive integer;

[0101] Data preprocessing module 20, the data preprocessing module 20 is used to preprocess the flue-cured tobacco group dataset to obtain a preprocessed dataset;

[0102] Classification network construction module 30, which is used to design the flue-cured tobacco group classification network TGNet;

[0103] The classification model building module 40 is used to train the preprocessed dataset with the flue-cured tobacco group classification network TGNet to obtain a flue-cured tobacco group classification model.

[0104] Grouping result acquisition module 50 is used to acquire grouping results of flue-cured tobacco based on the flue-cured tobacco group classification model.

[0105] Furthermore, the system also includes:

[0106] The flue-cured tobacco sample acquisition module is used to acquire flue-cured tobacco samples;

[0107] The image acquisition module is used to acquire images of the flue-cured tobacco samples through an image acquisition device and obtain image information of the flue-cured tobacco samples;

[0108] The group information acquisition module is used to acquire information about the group of flue-cured tobacco.

[0109] The grouping module is used to group the flue-cured tobacco sample image information based on the flue-cured tobacco group information and establish the flue-cured tobacco group dataset.

[0110] Furthermore, the system also includes:

[0111] The image information conversion module is used to convert the flue-cured tobacco sample image information into a size suitable for the input of the network model, and to obtain an adjusted set of flue-cured tobacco sample images;

[0112] The image set partitioning module is used to randomly partition the adjusted flue-cured tobacco sample image set to obtain a first test sample set, a first sample training set, and a first sample validation set.

[0113] The dataset acquisition module is used to use the first test sample set, the first sample training set, and the first sample validation set as the preprocessed dataset.

[0114] Furthermore, the system also includes:

[0115] The weighted feature generation module is used to generate weighted features for the corresponding feature channels through the feature channel weighting module CWstage;

[0116] The module building module is used to build the FADM loss module;

[0117] The group classification network construction module is used to fuse the weighted features of the feature channels and the FADM loss module to construct the flue-cured tobacco group classification network TGNet.

[0118] Furthermore, the system also includes:

[0119] The initial feature acquisition module is used to feed the features from stage-S3 into ConvBNAct to obtain the initial features;

[0120] A high-scale feature acquisition module is used to obtain high-scale features based on the initial features;

[0121] The channel weight factor generation module is used to generate channel weight factors through the Avgpool layer and the MLP layer;

[0122] The channel weighting module is used to perform channel weighting on the high-scale features based on the channel weighting factors and output the weighted features.

[0123] Furthermore, the system also includes:

[0124] The loss function introduction module is used to introduce a class rebalancing strategy to reconstruct the loss function, given different weighting factors in the loss calculation for the flue-cured tobacco group dataset;

[0125] The dynamic margin import module is used to import dynamic margins;

[0126] The FADM loss module acquisition module is used to reconstruct the loss function and the dynamic margin by introducing the class rebalancing strategy into the classification loss, and obtains the FADM loss module as shown in the following formula:

[0127]

[0128] in, n is the number of samples used for loss calculation, C=5 corresponds to the number of groups in the flue-cured tobacco group dataset, a yi Corresponding to the weights of the flue-cured tobacco group dataset, λ is the focusing parameter and s is the scaling factor.

[0129] Furthermore, the system also includes:

[0130] The dynamic margin generation module uses the following formula to generate the dynamic margin:

[0131]

[0132] Among them, similarity measurement The absolute value of the difference between the target confidence score and other confidence scores will be used to predict the score cosθ. i The input is fed into the Softmax function to obtain the confidence vector P of the i-th sample. i ∈R 1×5 By applying the cosine function to the minimum P j SM Encoding obtains dynamic

[0133] Through the foregoing detailed description of a method for grouping flue-cured tobacco using feature channel weighting and dynamic loss control, those skilled in the art can clearly understand the method and system for grouping flue-cured tobacco using feature channel weighting and dynamic loss control in this embodiment. As for the apparatus disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and relevant parts can be referred to in the method section.

[0134] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for grouping flue-cured tobacco using characteristic channel weighting and dynamic loss regulation, characterized in that, The method includes: Images of flue-cured tobacco from N main harvesting groups are acquired using an image acquisition device to establish a flue-cured tobacco group dataset, where N is a positive integer; The flue-cured tobacco group dataset is preprocessed to obtain a preprocessed dataset; Design a tobacco group classification network TGNet; The flue-cured tobacco group classification network TGNet is trained using the preprocessed dataset to obtain the flue-cured tobacco group classification model; The grouping results of flue-cured tobacco are obtained based on the flue-cured tobacco grouping model. The designed flue-cured tobacco group classification network TGNet includes: The CWstage module replaced the cascaded Bottleneck module in the baseline network Stage_S4. The CWstage feature channel weighting module generates weighted features for the corresponding feature channels. The CWstage module comprises three structures: ConvBNAct, Avgpool, and MLP. The Stage-S3 output features are processed by ConvBNAct: a 1×1 convolution with a stride of 2 is used for feature downsampling, while simultaneously expanding the channels, resulting in a feature size of 7×7 and a channel expansion of 368. After convolution, the features are sequentially passed through BN and ReLU layers. After ConvBNAct, the features are divided into two branches. Branch one involves cross-layer connections followed by channel weighting, while branch two involves average pooling and multilayer perceptron processing to generate channel weighting factors. The calculation process for the sampled output is shown below: ; in, This is the output of the baseline network stage-S3. This is a feature of subsequent channel weighting; Channel weight factors are generated through Avgpool and MLP layers, and the features are then weighted by channel to output weighted features. The calculation formula is shown below: ; in Represents the matrix dot product. It is a weighted feature of the CWstage output. Channel weight factors are generated through the Avgpool layer and the MLP layer; Constructing the FADM loss module includes: introducing a rebalancing strategy to reconstruct the loss function, given different weighting factors in the loss calculation for the flue-cured tobacco group dataset; Introduce dynamic margins; By incorporating the class rebalancing strategy into the classification loss to reconstruct the loss function and the dynamic margin, the FADMloss module is obtained, as shown in the following formula: ; in, n is the number of samples used for loss calculation, and C=5 corresponds to the number of groups in the flue-cured tobacco group dataset. Corresponding to the weights of the flue-cured tobacco group dataset, is the focusing parameter, and s is the scaling factor; The formula for generating the dynamic margin is as follows: ; Among them, similarity measurement , It is the absolute value of the difference between the target confidence score and other confidence scores, representing the predicted score of the i-th sample. The input is fed into the Softmax function to obtain the confidence vector of the i-th sample. By applying the cosine function to the smallest Encoding to obtain dynamic margin ; The weighted features of the feature channels and the FADM loss module are combined to construct the flue-cured tobacco group classification network TGNet.

2. The method as described in claim 1, characterized in that, The process of acquiring images of flue-cured tobacco from N main harvesting groups using an image acquisition device and establishing a flue-cured tobacco group dataset includes: Obtain flue-cured tobacco samples; Images of the flue-cured tobacco samples are acquired using an image acquisition device to obtain image information of the flue-cured tobacco samples; Obtain information on the tobacco group classification; Based on the tobacco group information, the tobacco sample image information is grouped to establish the tobacco group dataset.

3. The method as described in claim 2, characterized in that, The step of preprocessing the flue-cured tobacco group dataset to obtain a preprocessed dataset includes: The flue-cured tobacco sample image information is converted into a size suitable for the input of the network model to obtain an adjusted set of flue-cured tobacco sample images; The adjusted flue-cured tobacco sample image set is randomly divided to obtain a first test sample set, a first sample training set, and a first sample validation set. The first test sample set, the first sample training set, and the first sample validation set are used as the preprocessed dataset.

4. A flue-cured tobacco grouping system with characteristic channel weighting and dynamic loss control, characterized in that, The system is used to execute the flue-cured tobacco grouping method according to any one of claims 1 to 3, including: The flue-cured tobacco image acquisition module is used to acquire flue-cured tobacco images of N main groups through an image acquisition device and establish a flue-cured tobacco group dataset, where N is a positive integer; The data preprocessing module is used to preprocess the flue-cured tobacco group dataset to obtain a preprocessed dataset. A classification network construction module is provided, which is used to design the TGNet classification network for flue-cured tobacco groups. A classification model building module is used to train the flue-cured tobacco group classification network TGNet using the preprocessed dataset to obtain a flue-cured tobacco group classification model. The grouping result acquisition module is used to acquire the grouping results of flue-cured tobacco based on the flue-cured tobacco group classification model.