Tobacco leaf baking state identification method based on fine granularity classification
By combining the CNN and Transformer models and using feature fusion and filters, the problem of fine-grained features that is difficult to identify the tobacco leaf baking state with traditional methods is solved, and the accuracy and quality of tobacco leaf baking state identification are improved.
Patent Information
- Application Number
- CN202410827060.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-25
- Publication Date
- 2024-09-17
AI Technical Summary
The traditional tobacco leaf curing state recognition method is complex in a dense curing room environment, and it is difficult to effectively identify the fine-grained features of tobacco leaf curing images, resulting in low recognition accuracy.
Combining the CNN and Transformer models, local detailed information is enhanced through the feature fusion module, and the encoder layer of the Transformer is used to build a feature filter, learn fine-grained features, and realize automatic classification and identification of tobacco leaf baking status.
It improves the accuracy of tobacco leaf baking state identification, saves labor costs, improves tobacco leaf baking quality, and can effectively extract distinguishing information from tobacco leaf color, shape and texture features.
Smart Images

Figure CN118658064A
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of tobacco leaf baking, and in particular to a tobacco leaf baking state recognition method based on fine-grained classification. Background Art
[0002] With the development of computer vision, more and more image processing technologies are being applied to the field of tobacco leaf baking. The traditional method of tobacco leaf baking state recognition is to extract the color, area, texture and other features of the tobacco image as the input of the model to identify the baking state. However, due to the complex environment of the intensive baking room and the high density between tobacco leaves, the feature extraction process is complicated, and it is difficult to achieve tobacco leaf baking state recognition only by traditional methods. The baking image feature differences of tobacco leaves in adjacent baking states are small, and these distinguishing differences mostly exist in the more fine-grained features of the image, which need to be identified by fine-grained classification methods.
[0003] At present, the convolutional neural network (CNN) model based on the residual structure has made great breakthroughs in the field of tobacco leaf baking state recognition, and its performance has significantly surpassed the traditional methods. At the same time, the model based on the transformer is widely used in fields such as fine-grained image classification, but it is still in the exploratory stage in the field of tobacco leaf baking state recognition. Both the CNN model and the Transformer model have their own advantages and disadvantages. Specifically, the Transformer has a strong global feature representation ability through the self-attention mechanism, but may ignore local features, which are crucial to the recognition of tobacco leaf baking state; while the CNN model can use multi-scale feature fusion to capture the local feature relationship between different layers, but lacks the ability to model global features. The above characteristics show that the CNN model and the Transformer model are complementary in feature representation, and the advantages of the two can be combined to explore an effective fine-grained classification model to improve the recognition accuracy of tobacco leaf baking state. Based on this, the present invention discloses a tobacco leaf baking state recognition method based on fine-grained classification. Summary of the invention
[0004] In view of this, the purpose of the present invention is to propose a tobacco leaf baking state recognition method based on fine-grained classification, which makes full use of the local modeling ability of the CNN network and the global dependency modeling ability of the Transformer network, comprehensively models the local and global features of the flue-cured tobacco image, realizes automatic classification and recognition of the tobacco leaf baking state, saves labor costs, improves recognition accuracy, and thus improves the quality of tobacco leaf baking.
[0005] In order to achieve the above technical objectives, the technical solution adopted by the present invention is:
[0006] The present invention provides a tobacco leaf baking state recognition method based on fine-grained classification, comprising the following steps:
[0007] Step 1: Collect tobacco leaf baking images during the baking process and establish a tobacco leaf baking image dataset;
[0008] Step 2, preprocessing the tobacco leaf baking image dataset;
[0009] Step 3: extracting features from the preprocessed tobacco leaf baking images to generate feature maps of different scales;
[0010] Step 4: The feature maps of different scales are fused through the feature fusion module to enhance the local detail information contained in the features;
[0011] Step 5: Perform linear mapping on the fused feature map to obtain a feature sequence;
[0012] Step 6: Send the feature sequence to N encoder layers, record the attention weights of the first N-1 layers and the output of the N-1th layer, and send them to the feature filtering module to filter the feature sequence input to the Nth layer to obtain fine-grained features with high discrimination;
[0013] Step 7: Input the filtered features into the Nth encoder layer, and then input the output into the classifier, so as to classify the input tobacco leaf baking image;
[0014] Step 8: By comparing the loss function, the similarity of the classification tokens corresponding to different categories is minimized, and the similarity of the classification tokens corresponding to the same category is maximized, so as to complete the training of the tobacco leaf baking state recognition model;
[0015] Step 9: Input the tobacco leaf baking image to be classified into the trained tobacco leaf baking state recognition model to identify the baking state of the current tobacco leaf.
[0016] Furthermore, the step 1 further comprises the following steps:
[0017] Step 11: Collect tobacco leaf baking images during the complete baking process in multiple tobacco-curing rooms, take regular photos of the tobacco leaf baking images under an actual tobacco-curing environment, and annotate corresponding information;
[0018] Step 12: Classify the collected tobacco leaf baking images according to the annotation information, and divide them into 6 categories, namely, early yellowing stage, middle yellowing stage, late yellowing stage, early color fixation stage, late color fixation stage and dry tendon stage;
[0019] Step 13: Divide the classified tobacco leaf baking images into a training set, a validation set, and a test set in a ratio of 8:1:1 to obtain a tobacco leaf baking image dataset.
[0020] Furthermore, the step 2 further comprises the following steps:
[0021] Step 21, scaling the tobacco leaf baking images in the tobacco leaf baking image dataset;
[0022] Step 22, cropping the scaled tobacco leaf baking images, the tobacco leaf baking images of the training set are cropped randomly, and the tobacco leaf baking images of the validation set and the test set are cropped centrally;
[0023] Step 23: Perform horizontal random inversion on the tobacco leaf baking images in the training set to perform data enhancement.
[0024] Furthermore, the step 3 further comprises the following steps:
[0025] Step 31: Input the preprocessed tobacco leaf baking image into a 7×7 convolution layer, batch normalization and ReLU activation function for preliminary feature extraction and increase the channel dimension to 64, and then pass through a 3×3 maximum pooling layer to obtain a feature map X0, the dimension of X0 is 224×224×64;
[0026] Step 32: Pass the feature map X0 through three residual modules with the same structure to obtain three feature maps X1, X2 and X3 with dimensions of 112×112×256;
[0027] Step 33, the feature map X3 is further processed through three residual blocks to obtain feature maps X4, X5 and X6 for feature fusion, with corresponding dimensions of 56×56×512, 28×28×1024 and 14×14×2048.
[0028] Furthermore, the step 4 further comprises the following steps:
[0029] Step 41, adjust the dimensions of feature maps X4, X5 and X6;
[0030] Step 42: perform matrix dot multiplication operation between the three feature maps X4, X5 and X6 output in step 41, and perform interactive fusion of features of different scales through batch normalization, and output three enhanced interactive feature maps with a dimension of 196×768;
[0031] Step 43: Concatenate the output of step 42 in the channel dimension and pass it through the ReLU activation function to obtain the final output of the feature fusion module with a dimension of 196×2352.
[0032] Furthermore, the step 5 further comprises the following steps:
[0033] Step 51: The output of step 43 is passed through a 1×1 convolutional layer to reduce the channel dimension, and then through a flattening operation, the reduced 3D data is converted into 2D data with a dimension of 196×768;
[0034] Step 52: concatenate the two-dimensional data obtained in step 51 with a trainable parameter classification token, and then concatenate the position encoding information, perform Dropout regularization, and finally output a complete feature sequence with a dimension of 197×768.
[0035] Furthermore, the step 6 further comprises the following steps:
[0036] Step 61: Send the output of step 52 as input to N encoder layers for global information interaction; each encoder layer has the same structure, mainly composed of a multi-layer perceptron MLP and a multi-head self-attention module MSA;
[0037] Step 62: record the attention weight matrix of the first N-1 encoder layers and the feature sequence output by the N-1th layer; an encoder layer has H attention heads, and each attention head generates an attention weight matrix;
[0038] Step 63: construct a feature filtering module to screen the feature sequence input from the Nth layer and filter out background and redundant features.
[0039] Furthermore, the step 7 is specifically as follows: the features extracted in step 63 are concatenated with the classification tokens as the input sequence of the Nth layer, and the output of the Nth layer is input to a linear classifier with a fully connected layer to achieve classification of the tobacco leaf baking image.
[0040] Furthermore, the step 8 further comprises the following steps:
[0041] Step 81, the formula of the contrast loss function is as follows:
[0042]
[0043] Among them, L con represents the contrast loss function, B is the sample batch size, i and j represent the index positions of different samples in the calculation, and x i and x j represents two eigenvectors normalized by L2 norm, y i =y j Indicates that sample i and sample j are positive sample pairs, y i ≠y jIndicates that sample i and sample j are a negative sample pair. The sim function is used to calculate the cosine similarity of two feature vectors. α represents the threshold constant. In order to prevent the simple negative sample of the sample pair from affecting the loss, the threshold constant α is set.
[0044] Step 82, when calculating the loss, filter the negative sample pairs whose similarity is less than α;
[0045] Step 83: Complete the training of the tobacco leaf baking state recognition model under the joint supervision of the contrast loss function and the cross entropy loss function.
[0046] Furthermore, the step 9 specifically includes:
[0047] Step 91, sending the tobacco leaf baking images of the validation set to the trained tobacco leaf baking state recognition model, evaluating the ability of the tobacco leaf baking state recognition model and adjusting the parameters of the tobacco leaf baking state recognition model to obtain the optimal parameters;
[0048] Step 92: Send the tobacco leaf baking images of the test set to the verified tobacco leaf baking state recognition model, and obtain the probability values of each class corresponding to the tobacco leaf baking images through the classifier. The category corresponding to the maximum probability value is the baking state of the current tobacco leaf.
[0049] By adopting the above technical solution, the present invention has the following beneficial effects compared with the prior art:
[0050] (1) For the first time, tobacco leaf baking state recognition is considered as a fine-grained classification problem and analyzed and processed using a deep learning model. The method of the present invention can extract effective distinguishing information from features such as color, shape, and texture of tobacco leaves, thereby accurately identifying different baking states.
[0051] (2) The method of the present invention uses a CNN network based on a residual structure to realize the fusion of local features of different scales, and uses the encoder layer of Transformer to build a feature filter to learn an effective selection mechanism for fine-grained features.
[0052] (3) The feature filter can not only model the global information but also filter out some redundant information by filtering the input features of the last encoder module of Transformer, thereby improving the model's ability to extract discriminative features and enabling the model to more effectively distinguish adjacent continuous stages of tobacco leaf baking.
[0053] (4) For the first time, a new fine-grained classification model for tobacco leaf baking status recognition was disclosed. The CNN based on the feature fusion module and the Transformer based on the feature filtering module were fused to improve the model's ability to extract highly discriminative features. The linear fusion structure enables the model to represent features more effectively. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0055] Figure 1 It is an execution flow chart of a tobacco leaf baking state identification method based on fine-grained classification provided in an embodiment of the present invention.
[0056] Figure 2 This is an example diagram of the tobacco leaf baking state of the present invention.
[0057] Figure 3 It is the overall framework diagram of the tobacco leaf baking state recognition model proposed in the present invention.
[0058] Figure 4 is a structural diagram of the residual block in the present invention.
[0059] Figure 5 It is a structural diagram of the encoder layer in the present invention. DETAILED DESCRIPTION
[0060] The present invention will be further described in detail below in conjunction with the accompanying drawings and examples. It is particularly noted that the following examples are only used to illustrate the present invention, but are not intended to limit the scope of the present invention. Similarly, the following examples are only partial embodiments of the present invention rather than all embodiments, and all other embodiments obtained by those of ordinary skill in the art without creative work are within the scope of protection of the present invention.
[0061] See also Figure 1 The present invention provides a tobacco leaf baking state recognition method based on fine-grained classification, which specifically comprises the following steps:
[0062] Step 1: Collect tobacco leaf baking images during the baking process and establish a tobacco leaf baking image dataset;
[0063] The step 1 further comprises the following steps:
[0064] Step 11: Collect tobacco leaf baking images during the complete baking process in multiple tobacco-curing rooms, take regular photos of the tobacco leaf baking images under an actual tobacco-curing environment, and annotate corresponding information;
[0065] Step 12: Classify the collected tobacco leaf baking images according to the annotation information, and divide them into 6 categories, namely, early yellowing stage, middle yellowing stage, late yellowing stage, early color fixation stage, late color fixation stage and dry tendon stage. The example pictures of each category are as follows: Figure 2 As shown;
[0066] Step 13: Divide the classified tobacco leaf baking images into a training set, a validation set, and a test set in a ratio of 8:1:1 to obtain a tobacco leaf baking image dataset.
[0067] Step 2, preprocessing the tobacco leaf baking image dataset;
[0068] The step 2 further comprises the following steps:
[0069] Step 21, scaling the tobacco leaf baking images in the tobacco leaf baking image dataset to a size of W×H (W and H are both 600 in the example); wherein W represents width and H represents height;
[0070] Step 22, cropping the scaled tobacco leaf baking images into a size of 448×448, the tobacco leaf baking images of the training set are cropped randomly, and the tobacco leaf baking images of the validation set and the test set are cropped centrally;
[0071] Step 23: Perform horizontal random inversion on the tobacco leaf baking images in the training set to perform data enhancement.
[0072] Step 3: extracting features from the preprocessed tobacco leaf baking images to generate feature maps of different scales;
[0073] The step 3 further comprises the following steps:
[0074] Step 31: Figure 3 As shown in the figure, the preprocessed tobacco leaf baking image is input into a 7×7 convolution layer, batch normalization and ReLU (Rectified Linear Unit, ReLU) activation function for preliminary feature extraction and the channel dimension is increased to 64, and then passed through a 3×3 maximum pooling layer to obtain the feature map X0, the dimension of X0 is 224×224×64;
[0075] Step 32: pass the feature map X0 through three residual modules with the same structure (such as Figure 4 As shown, the convolution kernel size of convolution layers 1 and 3 is 1×1, and that of convolution layer 2 is 3×3), and three feature maps X1, X2, and X3 with dimensions of 112×112×256 are obtained;
[0076] Step 33, the feature map X3 is further processed through three residual blocks to obtain feature maps X4, X5 and X6 for feature fusion, with corresponding dimensions of 56×56×512, 28×28×1024 and 14×14×2048.
[0077] Step 4: The feature maps of different scales are fused through the feature fusion module to enhance the local detail information contained in the features;
[0078] The step 4 further comprises the following steps:
[0079] Step 41, adjusting the dimensions of feature maps X4, X5 and X6 to facilitate efficient feature fusion;
[0080] The step 41 further comprises:
[0081] Step 411: input the feature map X4 into a residual structure including a 4×4 maximum pooling layer and a 1×1 convolutional layer, adjust the channel dimension, perform downsampling, and output after batch normalization. The dimension size of the final output feature map X4 is 14×14×784.
[0082] Step 412: input the feature map X5 into a residual structure including a 2×2 maximum pooling layer and a 1×1 convolutional layer, adjust the channel dimension, perform downsampling, and output after batch normalization. The dimension size of the final output feature map X5 is 14×14×784.
[0083] Step 413, input the feature map X6 into a 1×1 convolutional layer to adjust the channel dimension, and output it after batch normalization to minimize the information loss caused by dimensionality reduction. The dimension size of the final output feature map X6 is 14×14×784; the method of the present invention uses a CNN network based on a residual structure to realize the fusion of local features of different scales. Before fusing the feature maps X4, X5 and X6, the dimension sizes of the feature maps X4, X5 and X6 must be kept consistent to ensure that the purpose of interactive fusion of features of different scales can be achieved.
[0084] Step 42: perform matrix dot multiplication operation between the three feature maps X4, X5 and X6 output in step 41, and perform interactive fusion of features of different scales through batch normalization, and output three enhanced interactive feature maps with a dimension of 196×768;
[0085] Step 43, concatenate the output of step 42 in the channel dimension, and activate it through the ReLU (Rectified Linear Unit, ReLU) function to obtain the final output of the feature fusion module, with a dimension of 196 × 2352. Multi-scale feature fusion can capture the morphology, texture and structure information of objects at different scales, thereby improving the classification, detection and recognition performance of the model.
[0086] Step 5: Perform linear mapping on the fused feature map to obtain a feature sequence;
[0087] The step 5 further comprises the following steps:
[0088] Step 51: The output of step 43 is passed through a 1×1 convolutional layer to reduce the channel dimension, and then through a flattening operation, the reduced 3D data is converted into 2D data with a dimension of 196×768;
[0089] Step 52: concatenate the two-dimensional data obtained in step 51 with a trainable parameter classification token, and then concatenate the position encoding information, perform Dropout regularization, and finally output a complete feature sequence with a dimension of 197×768.
[0090] Step 6: Send the feature sequence to N (set to 12 in this example) encoder layers (encoder in Transformer, Transformer is an encoder-decoder architecture), record the attention weights of the first N-1 layers and the output of the N-1th layer, and send both to the feature filtering module to filter the feature sequence input from the Nth layer to obtain fine-grained features with high discrimination;
[0091] The step 6 further comprises the following steps:
[0092] Step 61: Take the output of step 52 as input and send it to N encoder layers (such as Figure 5 As shown), global information interaction is carried out; each encoder layer has the same structure, mainly composed of a multi-layer perceptron MLP and a multi-head self-attention module MSA;
[0093] Step 62: record the attention weight matrices of the first N-1 encoder layers and the feature sequence output by the N-1th layer; an encoder layer has H (set to 12 in the example) attention heads, and each attention head generates an attention weight matrix;
[0094] Step 63, construct a feature filtering module, filter the feature sequence of the Nth layer input, and filter out background and redundant features; the present invention uses the encoder layer of Transformer to construct a feature filter to learn an effective selection mechanism for fine-grained features; the feature filter can not only model the global information but also filter out some redundant information by filtering the input features of the last encoder layer of Transformer, thereby improving the model's ability to extract discriminative features and enabling the model to more effectively distinguish adjacent continuous stages of tobacco leaf baking.
[0095] The step 63 further comprises:
[0096] Step 631: recursively perform matrix dot multiplication on the H attention weights of each layer recorded in step 62, and amplify the effective attention features by gradual accumulation;
[0097] Step 632: concatenate the N-1 attention matrices obtained in step 631 using the Concat function, compress the concatenated attention features through global average pooling, pass through two fully connected layers, and finally use the Sigmoid activation function to obtain the weight corresponding to each layer of attention weight, which represents the importance of each layer of attention weight;
[0098] Step 633: add the weight obtained in step 632 to the attention weight recorded in step 62 layer by layer through multiplication, and then gradually accumulate the weight of each layer to obtain the final attention weight;
[0099] Step 634, select the index corresponding to the maximum value from the H attention weight matrices in step 633, and extract the corresponding features from the output of the N-1th layer recorded in step 62 according to these indexes. The feature sequence composed of these features is used as the final output of the feature filtering module, that is, fine-grained features with high discrimination are obtained. For the first time, the identification of tobacco leaf baking state is regarded as a fine-grained classification problem, and a deep learning model is used for analysis and processing. The method of the present invention can extract effective discriminative information from the characteristics of tobacco leaves such as color, shape and texture, so as to accurately identify different baking states.
[0100] Step 7: Input the filtered features into the Nth encoder layer, and then input the output into the classifier, so as to classify the input tobacco leaf baking image;
[0101] The step 7 is specifically as follows: the features extracted in step 63 are concatenated with the classification tokens as the input sequence of the Nth layer, and the output of the Nth layer is input into a linear classifier with a fully connected layer to achieve classification of the tobacco leaf baking image.
[0102] Step 8: By comparing the loss function, the similarity of the classification tokens corresponding to different categories is minimized, and the similarity of the classification tokens corresponding to the same category is maximized, so as to complete the training of the tobacco leaf baking state recognition model;
[0103] The step 8 further comprises the following steps:
[0104] Step 81, the formula of the contrast loss function is as follows:
[0105]
[0106] Among them, L con represents the contrast loss function, B is the sample batch size, i and j represent the index positions of different samples in the calculation, and x i and x j represents two eigenvectors normalized by L2 norm, y i =y j Indicates that sample i and sample j are positive sample pairs, y i ≠y j Indicates that sample i and sample j are a negative sample pair. The sim function is used to calculate the cosine similarity of two feature vectors. α represents the threshold constant. In order to prevent the simple negative sample of the sample pair from affecting the loss, the threshold constant α is set.
[0107] Step 82, when calculating the loss, filter the negative sample pairs whose similarity is less than α;
[0108] Step 83, completing the training of the tobacco leaf baking state recognition model under the joint supervision of the contrast loss function and the cross entropy loss function;
[0109] Step 9: Input the tobacco leaf baking image to be classified into the trained tobacco leaf baking state recognition model to identify the baking state of the current tobacco leaf.
[0110] The step 9 specifically includes:
[0111] Step 91, sending the tobacco leaf baking images of the validation set to the trained tobacco leaf baking state recognition model, evaluating the ability of the tobacco leaf baking state recognition model and adjusting the parameters of the tobacco leaf baking state recognition model to obtain the optimal parameters;
[0112] Step 92: Send the tobacco leaf baking images of the test set to the verified tobacco leaf baking state recognition model, and obtain the probability values of each class corresponding to the tobacco leaf baking images through the classifier. The category corresponding to the maximum probability value is the baking state of the current tobacco leaf.
[0113] The present invention discloses a tobacco leaf baking state recognition method based on fine-grained classification, which is fully verified on a private tobacco leaf baking image dataset, as shown in Table 1, indicating that the disclosed method can achieve better results than the baseline method.
[0114] Table 1. Comparison of the effects of the proposed method and the benchmark method on tobacco leaf baking image dataset
[0115] Model Accuracy ResNet 91.52% ViT 91.80% Method of the present invention 92.26%
[0116] In Table 1, ResNet is an image classification method based on CNN, and ViT is an image classification method based on Transformer. The above results show the superiority of the method of the present invention and the consistency of the results.
[0117] Although the present invention is mainly aimed at the technical field of tobacco leaf baking, it is also of reference significance to other similar fields.
[0118] The above descriptions are only some embodiments of the present invention, and are not intended to limit the protection scope of the present invention. Any equivalent device or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A tobacco leaf baking state recognition method based on fine-grained classification, It is characterized in that The steps include: Step 1: Collect tobacco leaf baking images during the baking process and establish a tobacco leaf baking image dataset; Step 2, preprocessing the tobacco leaf baking image dataset; Step 3: extracting features from the preprocessed tobacco leaf baking images to generate feature maps of different scales; Step 4: The feature maps of different scales are fused through the feature fusion module to enhance the local detail information contained in the features; Step 5: Perform linear mapping on the fused feature map to obtain a feature sequence; Step 6: Send the feature sequence to N encoder layers, record the attention weights of the first N-1 layers and the output of the N-1th layer, and send them to the feature filtering module to filter the feature sequence input to the Nth layer to obtain fine-grained features with high discrimination; Step 7: Input the filtered features into the Nth encoder layer, and then input the output into the classifier, so as to classify the input tobacco leaf baking image; Step 8: By comparing the loss function, the similarity of the classification tokens corresponding to different categories is minimized, and the similarity of the classification tokens corresponding to the same category is maximized, so as to complete the training of the tobacco leaf baking state recognition model; Step 9: Input the tobacco leaf baking image to be classified into the trained tobacco leaf baking state recognition model to identify the baking state of the current tobacco leaf.
2. A tobacco leaf baking state recognition method based on fine-grained classification as claimed in claim 1, It is characterized in that The step 1 further comprises the following steps: Step 11: Collect tobacco leaf baking images during the complete baking process in multiple tobacco-curing rooms, take regular photos of the tobacco leaf baking images under an actual tobacco-curing environment, and annotate corresponding information; Step 12: Classify the collected tobacco leaf baking images according to the annotation information, and divide them into 6 categories, namely, early yellowing stage, middle yellowing stage, late yellowing stage, early color fixation stage, late color fixation stage and dry tendon stage; Step 13: Divide the classified tobacco leaf baking images into a training set, a validation set, and a test set in a ratio of 8:1:1 to obtain a tobacco leaf baking image dataset.
3. A tobacco leaf baking state recognition method based on fine-grained classification as claimed in claim 2, It is characterized in that The step 2 further comprises the following steps: Step 21, scaling the tobacco leaf baking images in the tobacco leaf baking image dataset; Step 22, cropping the scaled tobacco leaf baking images, the tobacco leaf baking images of the training set are cropped randomly, and the tobacco leaf baking images of the validation set and the test set are cropped centrally; Step 23: Perform horizontal random inversion on the tobacco leaf baking images in the training set to perform data enhancement.
4. A tobacco leaf baking state recognition method based on fine-grained classification as claimed in claim 3, It is characterized in that The step 3 further comprises the following steps: Step 31: Input the preprocessed tobacco leaf baking image into a 7×7 convolution layer, batch normalization and ReLU activation function for preliminary feature extraction and increase the channel dimension to 64, and then pass through a 3×3 maximum pooling layer to obtain the feature map X 0 , X 0 The dimensions are 224×224×64; Step 32: The feature map X 0 Through three residual modules with the same structure, three feature maps X with dimensions of 112×112×256 are obtained 1 , X 2 and X 3 ; Step 33: The feature map X 3 Then through three residual blocks, the feature map X for feature fusion is obtained 4 , X 5 and X 6 , the corresponding dimensions are 56×56×512, 28×28×1024 and 14×14×2048.
5. A tobacco leaf baking state recognition method based on fine-grained classification as claimed in claim 4, It is characterized in that The step 4 further comprises the following steps: Step 41: Adjust feature map X 4 , X 5 and X 6 The dimension size of Step 42: The three feature graphs X output in step 41 4 , X 5 and X 6 Matrix dot multiplication is performed between them, and features of different scales are interactively fused through batch normalization to output three enhanced interactive feature maps with a dimension of 196×768; Step 43: Concatenate the output of step 42 in the channel dimension and pass it through the ReLU activation function to obtain the final output of the feature fusion module with a dimension of 196×2352.
6. A tobacco leaf baking state recognition method based on fine-grained classification as claimed in claim 5, It is characterized in that The step 5 further comprises the following steps: Step 51: The output of step 43 is passed through a 1×1 convolutional layer to reduce the channel dimension, and then through a flattening operation, the reduced 3D data is converted into 2D data with a dimension of 196×768; Step 52: concatenate the two-dimensional data obtained in step 51 with a trainable parameter classification token, and then concatenate the position encoding information, perform Dropout regularization, and finally output a complete feature sequence with a dimension of 197×768.
7. A tobacco leaf baking state recognition method based on fine-grained classification as claimed in claim 5, It is characterized in that The step 6 further comprises the following steps: Step 61: Send the output of step 52 as input to N encoder layers for global information interaction; each encoder layer has the same structure, mainly composed of a multi-layer perceptron MLP and a multi-head self-attention module MSA; Step 62: record the attention weight matrix of the first N-1 encoder layers and the feature sequence output by the N-1th layer; an encoder layer has H attention heads, and each attention head generates an attention weight matrix; Step 63: construct a feature filtering module to screen the feature sequence input from the Nth layer and filter out background and redundant features.
8. A tobacco leaf baking state recognition method based on fine-grained classification as claimed in claim 7, It is characterized in that The step 7 is specifically as follows: the features extracted in step 63 are concatenated with the classification tokens as the input sequence of the Nth layer, and the output of the Nth layer is input into a linear classifier with a fully connected layer to achieve classification of the tobacco leaf baking image.
9. A tobacco leaf baking state recognition method based on fine-grained classification as claimed in claim 8, It is characterized in that The step 8 further comprises the following steps: Step 81, the formula of the contrast loss function is as follows: Among them, L con represents the contrast loss function, B is the sample batch size, i and j represent the index positions of different samples in the calculation, and x i and x j represents two eigenvectors normalized by L2 norm, y i =y j Indicates that sample i and sample j are positive sample pairs, y i ≠y j Indicates that sample i and sample j are a negative sample pair. The sim function is used to calculate the cosine similarity of two feature vectors. α represents the threshold constant. In order to prevent the simple negative sample of the sample pair from affecting the loss, the threshold constant α is set. Step 82, when calculating the loss, filter the negative sample pairs whose similarity is less than α; Step 83: Complete the training of the tobacco leaf baking state recognition model under the joint supervision of the contrast loss function and the cross entropy loss function.
10. A tobacco leaf baking state recognition method based on fine-grained classification according to claim 9, It is characterized in that The step 9 specifically includes: Step 91, sending the tobacco leaf baking images of the validation set to the trained tobacco leaf baking state recognition model, evaluating the ability of the tobacco leaf baking state recognition model and adjusting the parameters of the tobacco leaf baking state recognition model to obtain the optimal parameters; Step 92: Send the tobacco leaf baking images of the test set to the verified tobacco leaf baking state recognition model, and obtain the probability values of each class corresponding to the tobacco leaf baking images through the classifier. The category corresponding to the maximum probability value is the baking state of the current tobacco leaf.
