Tobacco spectral band analysis method, device and equipment and storage medium

By using sliding window segmentation and spectral feature evaluation model scoring, the problems of noise and redundant information interference in spectral data in tobacco quality evaluation are solved, and the automatic screening and accurate prediction of characteristic bands are realized, thereby improving the intelligence and efficiency of tobacco quality evaluation.

CN121601091APending Publication Date: 2026-03-03YUNNAN TOBACCO LEAF
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511765232.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-27
Publication Date
2026-03-03

AI Technical Summary

Technical Problem

Existing technologies struggle to effectively capture the nonlinear mapping relationship between spectra and complex sensory attributes, and lack methods for screening characteristic bands, resulting in insufficient accuracy and low computational efficiency in tobacco quality evaluation.

Method used

Near-infrared spectral data is segmented by sliding windows, and each spectral segment in the window is scored using a pre-trained spectral feature evaluation model to select the spectral bands that best reflect sensory indicators.

Benefits of technology

It achieves both improved prediction accuracy and automated screening of characteristic bands, providing a rapid and objective intelligent evaluation of tobacco leaf quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121601091A_ABST
    Figure CN121601091A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a tobacco leaf spectral band analysis method and device, equipment and a storage medium, and the method comprises the steps: obtaining near infrared spectrum data corresponding to target tobacco leaves, and carrying out the sliding window segmentation of the near infrared spectrum data, so as to obtain a plurality of window spectrum segments; inputting all the window spectrum fragments into a pre-trained target spectrum feature evaluation model to obtain a spectrum feature score corresponding to each window spectrum fragment; and determining a target spectral fragment from the window spectral fragments based on the spectral feature score, and determining a target spectral band corresponding to the target tobacco based on the target spectral fragment. According to the technical scheme of the embodiment of the invention, the spectral fragment of each part can be evaluated and screened based on the sliding window segmentation, the prediction precision is improved, the automatic screening of the characteristic wave band is realized, and a complete solution is provided for the rapid, objective and intelligent evaluation of the tobacco leaf quality.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of spectral analysis technology, and in particular to a method, apparatus, device and storage medium for spectral band analysis of tobacco leaves. Background Technology

[0002] Sensory indicators of tobacco leaves are the core basis for evaluating their quality and determining their industrial application value. Traditional sensory evaluation methods are insufficient to meet the urgent needs of the modern tobacco industry for intelligent and standardized production. Near-infrared spectroscopy, as a rapid and non-destructive detection method, has been widely used in qualitative and quantitative analysis in the tobacco industry because it can simultaneously reflect the chemical composition and physical properties of samples. This technology can simultaneously resolve the chemical composition, structure, and physical properties of organic matter by detecting the overtone and combination frequency absorption of hydrogen-containing groups such as CH, OH, and NH, providing a theoretical basis for predicting the sensory indicators of tobacco leaves. However, using near-infrared spectroscopy to predict sensory indicators still faces many challenges:

[0003] Limitations of existing models: Traditional linear models, such as principal component regression and partial least squares, although widely used, are inherently linear and struggle to capture the highly complex nonlinear mapping between spectra and complex sensory attributes, thus limiting their prediction accuracy. Conventional deep learning models, such as convolutional neural networks, while possessing some nonlinear feature extraction capabilities, have limited receptive fields and focus more on local features, making them insufficient for modeling long-range spectral dependencies.

[0004] The lack of feature band selection: Most current research focuses on improving prediction accuracy, but lacks methods to identify key spectral bands most relevant to specific sensory indicators while improving prediction accuracy. This also limits the computational efficiency of the models to some extent. Summary of the Invention

[0005] This invention provides a method, apparatus, device, and storage medium for analyzing the spectral bands of tobacco leaves. It can evaluate and screen each spectral segment based on a sliding window, thereby improving prediction accuracy and achieving automated screening of characteristic bands. This provides a complete solution for rapid, objective, and intelligent evaluation of tobacco leaf quality.

[0006] In a first aspect, embodiments of the present invention provide a method for analyzing the spectral bands of tobacco leaves, the method comprising:

[0007] Near-infrared spectral data corresponding to the target tobacco leaf is acquired, and the near-infrared spectral data is segmented into multiple window spectral segments by sliding window; all window spectral segments are input into a pre-trained target spectral feature evaluation model to obtain a spectral feature score corresponding to each window spectral segment; the target spectral segment is determined from the window spectral segments based on the spectral feature score, and the target spectral band corresponding to the target tobacco leaf is determined based on the target spectral segment.

[0008] Secondly, embodiments of the present invention provide a tobacco leaf spectral band analysis device, the device comprising:

[0009] The module includes a window segmentation module for acquiring near-infrared spectral data corresponding to the target tobacco leaf and performing sliding window segmentation on the near-infrared spectral data to obtain multiple window spectral segments; a segment feature scoring module for inputting all window spectral segments into a pre-trained target spectral feature evaluation model to obtain a spectral feature score corresponding to each window spectral segment; and a spectral band determination module for determining the target spectral segment from the window spectral segments based on the spectral feature scores and determining the target spectral band corresponding to the target tobacco leaf based on the target spectral segments.

[0010] Thirdly, embodiments of the present invention provide a computer device, the computer device comprising:

[0011] One or more processors;

[0012] Memory, used to store one or more programs;

[0013] When the one or more programs are executed by the one or more processors, the one or more processors implement the tobacco leaf spectral band analysis method described in any embodiment.

[0014] Fourthly, embodiments of the present invention provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the tobacco leaf spectral band analysis method described in any embodiment.

[0015] The technical solution provided by this invention involves acquiring near-infrared spectral data corresponding to a target tobacco leaf, dividing the near-infrared spectral data into multiple window spectral segments using a sliding window method, inputting all window spectral segments into a pre-trained target spectral feature evaluation model to obtain a spectral feature score for each window spectral segment, determining the target spectral segment from the window spectral segments based on the spectral feature score, and determining the target spectral band corresponding to the target tobacco leaf based on the target spectral segment. This invention solves the problem in existing technologies where noise and redundant information in high-dimensional spectral data cause severe interference, leading to insufficient accuracy in model analysis. It allows for evaluation and screening of each spectral segment after sliding window division, overcoming the noise and redundant information interference problem in high-dimensional near-infrared spectral data. This improves prediction accuracy while achieving automated screening of feature bands, providing a complete solution for rapid, objective, and intelligent evaluation of tobacco leaf quality. Attached Figure Description

[0016] Figure 1 This is a flowchart of a method for analyzing the spectral bands of tobacco leaves provided in an embodiment of the present invention;

[0017] Figure 2 This is a flowchart of another method for analyzing the spectral bands of tobacco leaves provided in an embodiment of the present invention;

[0018] Figure 3 This is a flowchart illustrating a process for performing spectral band analysis of tobacco leaves, provided by an embodiment of the present invention.

[0019] Figure 4 This is a distribution map of tobacco leaf samples from different production areas provided in an embodiment of the present invention;

[0020] Figure 5 This is an analysis diagram of the raw and pre-processed near-infrared spectrum of tobacco leaves provided in an embodiment of the present invention;

[0021] Figure 6 This is a detailed structural diagram of a linear embedding layer provided in an embodiment of the present invention;

[0022] Figure 7 This is a schematic diagram of a feature encoder provided in an embodiment of the present invention;

[0023] Figure 8 This is a schematic diagram of the main structure of an MHSA provided in an embodiment of the present invention;

[0024] Figure 9 This is a schematic diagram of an FFN provided in an embodiment of the present invention;

[0025] Figure 10 This is a schematic diagram of the structure of a tobacco leaf spectral band analysis device provided in an embodiment of the present invention;

[0026] Figure 11 This is a schematic diagram of the structure of a computer device provided in an embodiment of the present invention. Detailed Implementation

[0027] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0028] Figure 1 This is a flowchart of a method for analyzing the spectral bands of tobacco leaves provided in an embodiment of the present invention. The embodiment of the present invention can be applied to scenarios where key feature bands of sensory indicators of tobacco leaves are screened and effectively predicted by analyzing the near-infrared spectral information of tobacco leaves. The method can be executed by a tobacco leaf spectral band analysis device, which can be implemented by software and / or hardware.

[0029] like Figure 1 As shown, the method for analyzing the spectral bands of tobacco leaves includes the following steps:

[0030] S110. Obtain the near-infrared spectral data corresponding to the target tobacco leaf, and perform sliding window segmentation on the near-infrared spectral data to obtain multiple window spectral segments.

[0031] The target tobacco leaf can be a tobacco leaf that requires sensory evaluation. The technical solution of this invention requires analyzing the near-infrared spectral data of the target tobacco leaf to determine the spectral band that best reflects a certain sensory indicator of the target tobacco leaf; that is, analysis of this spectral band makes it easier to determine the quality of a certain sensory indicator of the target tobacco leaf. Specifically, a near-infrared spectrometer can be used to collect spectral data of representative target tobacco leaves, with a wavenumber range covering 4000 cm⁻¹ to 12000 cm⁻¹. Each spectrum consists of 2125 continuous data points, which correspond one-to-one with 10 sensory indicator scores obtained by professional smokers (aroma characteristics: fresh, sweet, and caramelized; smoke characteristics: concentration and strength; quality characteristics: aroma quality, aroma quantity, off-flavors, irritation, and aftertaste).

[0032] Optionally, a combination of multivariate scattering correction (MSC), Savitzky-Golay smoothing (SG), and first derivative (D1) can be used to preprocess near-infrared spectral data. MSC is used to eliminate scattering effects caused by uneven particle distribution, SG smoothing is used to suppress high-frequency random noise, and first derivative processing is used to eliminate baseline drift and enhance the characteristic peak-valley differences in the spectrum, together improving the quality and signal-to-noise ratio of near-infrared spectral data.

[0033] Furthermore, the windowed spectral segment can be a partial spectral segment from the near-infrared spectral data. Specifically, a sliding window mechanism can be used, where the window width ( ) and sliding step size ( The mechanism is defined by two parameters. The step size is... Intervals are used to sequentially cut lengths of [length]. The continuous spectral sub-intervals are used to divide the full-dimensional spectral sequence into... A local window segment, with input being near-infrared spectral data of tobacco leaves tensor of size [value missing]. ,in For batch size, Total number of spectral bands (channels) By setting different By combining parameters, window sequences with different lengths and overlap rates can be generated to adapt to the feature scales of different sensory metrics. The mathematical expression is shown below:

[0034]

[0035]

[0036] Where 𝑘 represents the sliding window index and 𝐾 represents the total number of sliding windows.

[0037] S120. Input all window spectral segments into the pre-trained target spectral feature evaluation model to obtain the spectral feature score corresponding to each window spectral segment.

[0038] The target spectral feature evaluation model can be a model that performs spectral analysis on target tobacco leaves from the perspective of a single sensory indicator. Specifically, each sensory indicator can have a corresponding spectral feature evaluation model. After determining the sensory indicator to be analyzed, the spectral feature evaluation model corresponding to that sensory indicator can be used as the target spectral feature evaluation model. Furthermore, the spectral feature score can be a score evaluating a window of spectral segments from the perspective of a single sensory indicator. Specifically, all window of spectral segments can be input into a pre-trained target spectral feature evaluation model, allowing the model to extract and analyze the global features of each window of spectral segments, thereby determining the spectral feature score corresponding to each window of spectral segments.

[0039] S130. Determine the target spectral segment from the window spectral segment based on the spectral feature score, and determine the target spectral band corresponding to the target tobacco leaf based on the target spectral segment.

[0040] The target spectral band can be the segment within the window spectral range that best reflects the quality of a single sensory indicator. Specifically, a higher spectral feature score indicates that the spectral band within that window spectral range more easily reflects the quality of a single sensory indicator of the target tobacco leaf. Therefore, the spectral band with the highest spectral feature score can be used as the target spectral band. Furthermore, the target spectral band can be the spectral band that best reflects the quality of a single sensory indicator of the target tobacco leaf. Specifically, after determining the target spectral band from the window spectral range, the corresponding window spectral range can be determined (for example, the index of the target spectral band within the window spectral range can be used as the window spectral range). The index of the target window spectral range and the starting wavenumber corresponding to the near-infrared spectral data are substituted into a preset wavenumber limit formula to obtain the left boundary wavenumber and the right boundary wavenumber. The band formed by the left boundary wavenumber and the right boundary wavenumber is then used as the target spectral band.

[0041] The formula for the preset wavenumber limit is as follows:

[0042] ;

[0043] ;

[0044] in, The sliding step size, For window width, The target window segment number, Wavenumber resolution.

[0045] The technical solution provided by this invention involves acquiring near-infrared spectral data corresponding to a target tobacco leaf, dividing the near-infrared spectral data into multiple window spectral segments using a sliding window method, inputting all window spectral segments into a pre-trained target spectral feature evaluation model to obtain a spectral feature score for each window spectral segment, determining the target spectral segment from the window spectral segments based on the spectral feature score, and determining the target spectral band corresponding to the target tobacco leaf based on the target spectral segment. This invention solves the problem in existing technologies where noise and redundant information in high-dimensional spectral data cause severe interference, leading to insufficient accuracy in model analysis. It allows for evaluation and screening of each spectral segment after sliding window division, overcoming the noise and redundant information interference problem in high-dimensional near-infrared spectral data. This improves prediction accuracy while achieving automated screening of feature bands, providing a complete solution for rapid, objective, and intelligent evaluation of tobacco leaf quality.

[0046] Figure 2 This is a flowchart of another method for analyzing the spectral bands of tobacco leaves provided by an embodiment of the present invention. This embodiment is applicable to scenarios where intelligent evaluation is performed by analyzing near-infrared spectral information of tobacco leaves to screen key feature bands and effectively predict sensory indicators. The aforementioned target spectral feature evaluation model includes: a linear projection layer, a feature analysis layer, and an indicator evaluation layer. Based on the above embodiments, this embodiment further explains how to input all window spectral segments into a pre-trained target spectral feature evaluation model to obtain a spectral feature score corresponding to each window spectral segment; and how to determine the target spectral segment from the window spectral segments based on the spectral feature score, and determine the target spectral band corresponding to the target tobacco leaf based on the target spectral segment. This device can be implemented by software and / or hardware and integrated into a computer device with application development capabilities.

[0047] like Figure 2 As shown, the method for analyzing the spectral bands of tobacco leaves includes the following steps:

[0048] S210. Obtain the near-infrared spectral data corresponding to the target tobacco leaf, and perform sliding window segmentation on the near-infrared spectral data to obtain multiple window spectral segments.

[0049] S220. Input all window spectral segments into the linear projection layer to obtain the feature vector sequence corresponding to each window spectral segment.

[0050] The target spectral feature evaluation model can be a model for spectral analysis of target tobacco leaves from the perspective of a sensory index. Specifically, each sensory index can have a corresponding spectral feature evaluation model. After determining the sensory index to be analyzed, the spectral feature evaluation model corresponding to that sensory index can be used as the target spectral feature evaluation model. Further, the feature vector sequence can be a vector sequence used to represent the spectral features of a window spectral segment. Specifically, all window spectral segments can be input into the linear projection layer, so that the linear projection layer extracts the spectral features of each window spectral segment, thereby determining the feature vector sequence corresponding to each window spectral segment.

[0051] Optionally, all window spectral segments are input to the linear projection layer to obtain a feature vector sequence corresponding to each window spectral segment. This includes: for each window spectral segment, inputting the window spectral segment to the linear projection layer so that the linear projection layer divides the window spectral segment into multiple non-overlapping segment patches; performing a tensor rearrangement operation on all segment patches; and mapping each tensor-rearranged segment patch to an embedding vector of a preset dimension to obtain the feature vector sequence. The segment patches can be used to cover multiple consecutive bands.

[0052] For example, to convert a spectral sequence into a feature sequence that can be processed by a Transformer architecture, the method sequentially performs patching and linear projection on each window segment. First, the size of the window spectral segment is... Treat it as a one-dimensional signal and divide it into Each patch consists of non-overlapping fragments, with each patch covering a consecutive segment. Each band. Through tensor rearrangement operations, it is transformed from a shape of... tensor conversion ,in This indicates the number of patches within a single window. The dimension of each patch is then determined. Subsequently, each high-dimensional patch is mapped to a single dimension through a learnable linear layer. The embedding vectors of dimension 1 yield a sequence of feature vectors. The calculation process is as follows:

[0053]

[0054] In the formula, Let be the projection weight matrix. It is a bias term. The eigenvectors corresponding to the input tensor.

[0055] Optionally, before inputting the feature vector sequence corresponding to all window spectral segments into the feature analysis layer, the method further includes: concatenating a learnable classification label at the beginning of the feature vector sequence to obtain a processed vector sequence; wherein the processed vector sequence is used as a vector that is randomly initialized and updated during model training, and its final state is used as a global representation of the entire sequence; embedding a learnable positional encoding into the processed vector sequence, and using the embedded vector sequence as the input to the feature analysis layer.

[0056] For example, after obtaining a size of After embedding the sequence, before inputting it into the feature analysis layer, the method needs to enhance the sequence to incorporate global classification and location information. First, a learnable classification label ([CLS]) is appended to the beginning of the sequence:

[0057]

[0058] in, Given a vector that is randomly initialized and updated during training, its final state will be used as a global representation of the entire sequence.

[0059] Subsequently, to preserve the order information of the spectral bands, the learnable size is set to... Location coding This is applied to the embedded sequence to form a processed vector sequence.

[0060]

[0061] S230. Input the feature vector sequence corresponding to all window spectral segments into the feature analysis layer to obtain the global feature representation corresponding to each window spectral segment.

[0062] The global feature representation can be parameters relating to the global features of the window spectral segments. Specifically, the feature vector sequence corresponding to all window spectral segments can be input into the feature analysis layer, allowing the feature analysis layer to refine and fuse the spectral sequence context information layer by layer, thereby determining the global feature representation corresponding to each window spectral segment. The feature analysis layer includes multiple attention modules, each of which includes an attention mechanism unit and a feedforward neural network, employing residual connections and layer normalization mechanisms.

[0063] For example, the feature analysis layer (also known as the feature encoder) can be composed of eight identical Transformer modules stacked together. Each layer contains a multi-head self-attention mechanism (MHSA) and a feedforward neural network (FFN), and uses residual connections and layer normalization to stabilize the deep training process. The computation process of each layer is as follows:

[0064]

[0065]

[0066] in, It is the first The output of the layer.

[0067] The MHSA mechanism calculates the correlation weights between any two feature vectors in a sequence, thereby dynamically focusing on the most important local spectral features for the current prediction task and effectively modeling long-range dependencies. FFN performs a non-linear transformation on the attention output, enhancing the model's expressive power. Finally, the encoder obtains a global feature representation rich in contextual information.

[0068] S240. Input the global feature representations corresponding to all window spectral segments into the index evaluation layer to obtain the spectral feature score corresponding to each window spectral segment.

[0069] The spectral feature score can be a score evaluating a window spectral segment from the perspective of a single sensory index. Specifically, the global feature representations corresponding to all window spectral segments can be input into the index evaluation layer, so that the index evaluation layer can analyze the global feature representation corresponding to each window spectral segment, thereby determining the spectral feature score corresponding to each window spectral segment.

[0070] For example, the global feature representation corresponding to all spectral segments of the window can be used to perform final score prediction through a lightweight multilayer perceptron (MLP) regression head (i.e., the indicator evaluation layer). This maps the high-dimensional features into a continuous scalar value, which is the model's spectral feature score for a specific sensory indicator (such as "aroma quantity"). This MLP consists of two linear layers, a GELU activation function, and layer normalization. Its calculation process is as follows:

[0071]

[0072] in, , The first layer weights and biases enable a non-linear expansion of the feature space; , The second layer of weights and biases projects the high-dimensional features onto a final single sensory input to obtain a spectral feature score. .

[0073] S250. Based on the spectral feature score, determine the target spectral segment from the window spectral segment, and based on the target spectral segment, determine the target spectral band corresponding to the target tobacco leaf.

[0074] This is one of the core innovative steps in this case. To determine the spectral band most relevant to a specific sensory indicator, multiple models need to be trained sequentially, each using only a spectral segment from a specific window as input. The performance of these models is then evaluated on independent validation sets, using mean absolute error (MAE) or mean absolute percentage error (MAPE) as evaluation metrics. Finally, the best-performing model is selected to determine the corresponding window (i.e., the target spectral segment), and the spectral interval defined by the start and end wavenumbers of that window is considered the target spectral band for that sensory indicator. For a given combination of window parameters... , its first The optimal sliding window is represented by the following formula:

[0075]

[0076]

[0077]

[0078] The initial wavenumber is 4000. , It is wavenumber resolution, which is the wavenumber difference between adjacent data points.

[0079] For example, in order to better understand the technical solution provided by the present invention, specific embodiments are described below:

[0080] 1) Obtaining and preparing raw near-infrared spectral data of tobacco leaf samples: The samples in this embodiment are re-dried tobacco leaves used in cigarette formulation module production between 2018 and 2022, provided by the tobacco leaf technology center of a tobacco company in Yunnan Province. The samples cover 98 tobacco-growing counties in 13 major tobacco-producing areas in Yunnan Province (including Kunming, Dali, Chuxiong, Yuxi, Qujing, Honghe, Baoshan, Wenshan, Pu'er, Zhaotong, Lincang, Lijiang, and Dehong), covering 9 different grades of tobacco leaves: B1F, B2F, B3F, C1F, C2F, C3F, C4F, X2F, and X3F. A total of 829 representative smoking samples were collected, each accompanied by professional scoring data for 10 core sensory indicators (fresh aroma, sweet aroma, caramel aroma, strength, power, aroma quality, aroma quantity, off-flavors, irritation, and aftertaste). The distribution of tobacco leaf sample grades by region is as follows: Figure 2 As shown, The sample size represents the origin of each product.

[0081] All samples were analyzed using a BRUKER MPA Fourier transform near-infrared spectrometer (Germany). The spectral scan range was set to... The resolution is 4 Each spectrum contains 2125 data points. Meanwhile, a sensory evaluation team composed of 5 senior evaluation specialists scored each sample on 10 sensory indicators according to the industry standard (Q / YNYC(YY).J01.005—2023), and the average value was taken as the true label of the sample.

[0082] 2) Preprocess the raw near-infrared spectral data. The preprocessed near-infrared spectral analysis plot and the raw spectral data analysis plot are shown below. Figure 3 As shown in this embodiment, the raw near-infrared spectral data is susceptible to coupling interference from instrument system errors and environmental noise, causing spectral signal distortion and reducing the signal-to-noise ratio. Baseline drift and scattering also exist between samples. To ensure the accuracy of near-infrared spectral modeling, eliminate the influence of various interference factors, and enhance the expression of spectral features, appropriate preprocessing of the spectral data is necessary before modeling. This embodiment uses Python software and the Scikit-learn library to preprocess the training set spectral data. Three commonly used preprocessing methods were employed sequentially: Savitzky-Golay (SG) filtering, multivariate scattering correction (MSC), and first-order difference (D1) to improve data quality and usability. The second derivative was not chosen because it would excessively amplify noise. SG filtering smooths the spectral data while preserving its main features through polynomial fitting, removing high-frequency noise and ensuring the stability of the spectral signal. MSC is mainly used to remove scattering effects in the spectrum, eliminating the influence of baseline shift and optical path differences between samples, thereby enhancing the comparability of the spectra. The D1 method enhances the variation trend of local bands, makes the absorption peaks more prominent, enhances high-frequency variations, and helps to highlight the target-related features in the spectrum.

[0083] Finally, all the preprocessed tobacco leaf spectral data are randomly divided into training and testing sets in a 7:3 ratio. In this embodiment, only one sensory indicator (such as "aftertaste") is selected as the label, and the operation process for other indicators is performed in the same way.

[0084] 3) Sliding Window Segmentation: The preprocessed full-spectrum data (2125 dimensions) is input into the sliding window module. In this embodiment, the window width is set. 500, sliding step size Through calculation, a total of [number] can be generated. Each window segment covers approximately ( ) local window fragments. )≈1543 The wavenumber range. To find the global optimum, this implementation uses a larger parameter space, that is, multiple sets of different window sizes. With step size Multiple sets of comparative experiments were conducted, and other different window combinations were processed one by one according to the methods described in the above embodiments.

[0085] 4) Linear projection and embedding: The structure of this part is as follows Figure 4 As shown, the local spectral fragments (of shape [batch_size, 1, 400], where batch_size is set to 32) after sliding window segmentation are first fed into a patch embedding layer. During this process, each window fragment is divided into multiple non-overlapping patches, and the length of each patch, patch_size, is set to 25 data points. Therefore, each window is divided into... One patch.

[0086] Each patch is then subjected to an embedding transformation through a learnable linear projection layer (a fully connected layer). This projection layer maps each patch from a 25-dimensional raw data space to a model embedding space with dimension dim set to 25. This process transforms the input data for each window into a sequence of feature vectors of shape [32, 20, 25], providing a normalized input for the Transformer encoder. Furthermore, embedding dropout at a scale of 0.1 is applied during training to enhance the model's generalization ability.

[0087] 5) Transformer Encoder Feature Extraction: The projected feature sequence is fed into a stack consisting of 8 layers (depth=8) of Transformer encoder modules for deep nonlinear feature extraction and fusion. The feature encoder is as follows: Figure 5 As shown.

[0088] Each encoder layer contains two core sub-modules and employs residual connections and layer normalization to ensure training stability. Multi-Head Self-Attention (MHSA) mechanism: The number of attention heads is set to 8. The main structure of MHSA is as follows: Figure 6 As shown, this mechanism enables the model to dynamically focus on the local spectral features most relevant to the current prediction task and effectively model long-range dependencies.

[0089] Feed-Forward Network (FFN): FFN as... Figure 7As shown, it consists of a dimensionality expansion layer (from dim=25 dimensions to mlp_dim=2048 dimensions), an activation function, a dropout layer (dropout rate=dropout=0.1), and a dimensionality compression layer (from 2048 dimensions back to 25 dimensions). This module provides a non-linear transformation for the features at each location, greatly enhancing the model's expressive power.

[0090] By stacking eight encoder layers, the model can refine and fuse the contextual information of the spectral sequence layer by layer, and finally output a feature representation containing rich global information, while maintaining its shape ([32, 20, 25]).

[0091] 6) Sensory index prediction: To convert the encoded high-level feature representation into specific sensory index prediction values, a classification head design is adopted.

[0092] First, the feature sequence output by the Transformer encoder is usually given an output state with a learnable classification token at the beginning of the sequence, or the entire feature sequence is subjected to global average pooling to obtain a global feature vector of size [32, 25], which gathers the global information of the entire sequence.

[0093] Subsequently, this global feature vector is passed through a final fully connected linear classification layer, mapping it from dim=25 dimensions to num_classes=1 dimension. This value represents the model's predicted score for the specific sensory index corresponding to the input spectral window. The entire network uses mean squared error loss (MSE Loss) as the optimization objective.

[0094] Finally, following the steps above, we processed the data of the ten sensory indicators in different window sizes. With step size Multiple sets of experiments were conducted, using mean absolute error (MAE) and mean absolute percentage error (MAPE) as evaluation indicators. The best window parameters for different sensory indicators are shown in Table 1. Different sensory indicators correspond to different optimal window combinations, reflecting the differences in the attributes of feature perception. Finally, we used the spectral range corresponding to the best sliding window of the optimal window parameter configuration for each sensory indicator as the basis for selecting the feature bands of each sensory indicator.

[0095] Table 1

[0096] Sensory indicators Window properties (w,s) MAE MAPE (%) Fragrant (400,50) 0.42 13.12 sweet aroma (500,50) 0.46 27.68 Caramelized (400,50) 0.21 14.86 concentration (300,50) 0.39 5.38 energy (600,100) 0.29 5.83 Fragrance (600,50) 0.72 3.56 Aroma (400,50) 0.72 3.68 Mixed gases (400,50) 0.49 5.35 Stimulate (500,50) 0.47 4.55 Aftertaste (400,100) 0.57 4.01

[0097] 7) Key band selection:

[0098] To determine the optimal band for predicting the "stimulus" index, we first selected the window parameter (500, 50) with the best stimulus and fixed all other hyperparameters. We then trained and evaluated 34 independent WinSpecFormer models using data from 34 different window segments generated in step 3). On the test set, we calculated the mean absolute error (MAE) and mean absolute percentage error (MAPE) of each model's predictions. Through comparison, we found that the [missing information - likely a specific model name or parameter]... The model MAE and MAPE values ​​corresponding to window number [number] are the lowest at 0.47 and 4.55, respectively. Therefore, the wavenumber range for this window is [missing information]. , ], that is, band The key characteristic bands affecting the "stimulus" sensory index were officially identified. The key bands for the other nine sensory indicators were determined by analogy, and the results of the optimal band intervals for all sensory indicators are shown in Table 2.

[0099] Table 2

[0100] Sensory indicators Window properties (w,s) Main spectral feature points Main band region ( ) Fragrant (400,50) 150~550 5724.0~4185.0 sweet aroma (500,50) 750~1250 8616.8~6692.1 Caramelized (400,50) 150~550 5724.0~4185.0 concentration (300,50) 50~350 5145.4~3992.1 energy (600,100) 0~600 6109.7~3799.3 Fragrance (600,50) 0~600 6109.7~3799.3 Aroma (400,50) 50~450 5531.1~3992.1 Mixed gases (400,50) 800~1200 8424.0~6885.0 Stimulate (500,50) 150~650 6109.7~4185.0 Aftertaste (400,100) 150~550 6109.7~4570.7

[0101] The technical solution provided in this invention involves acquiring near-infrared spectral data corresponding to a target tobacco leaf, dividing the near-infrared spectral data into multiple window spectral segments using a sliding window method, inputting all window spectral segments into a linear projection layer to obtain a feature vector sequence corresponding to each window spectral segment, inputting the feature vector sequence corresponding to all window spectral segments into a feature analysis layer to obtain a global feature representation corresponding to each window spectral segment, and inputting the global feature representation corresponding to all window spectral segments into an index evaluation layer to obtain a spectral feature score corresponding to each window spectral segment. Based on the spectral feature score, a target spectral segment is determined from the window spectral segments, and the target spectral band corresponding to the target tobacco leaf is determined based on the target spectral segment.

[0102] Figure 10 This is a schematic diagram of a tobacco leaf spectral band analysis device provided in an embodiment of the present invention. The present invention can be applied to scenarios where key feature bands of tobacco leaf sensory indicators are screened and effectively predicted by analyzing near-infrared spectral information of tobacco leaves. The device can be implemented by software and / or hardware and integrated into a computer device with application development capabilities.

[0103] like Figure 10 As shown, the tobacco leaf spectral band analysis device includes: a window segmentation module 310, a segment feature scoring module 320, and a spectral band determination module 330.

[0104] The window segmentation module 310 is used to acquire near-infrared spectral data corresponding to the target tobacco leaf, and to perform sliding window segmentation on the near-infrared spectral data to obtain multiple window spectral segments; the segment feature scoring module 320 is used to input all window spectral segments into a pre-trained target spectral feature evaluation model to obtain a spectral feature score corresponding to each window spectral segment; the spectral band determination module 330 is used to determine the target spectral segment from the window spectral segments based on the spectral feature score, and to determine the target spectral band corresponding to the target tobacco leaf based on the target spectral segment.

[0105] The technical solution provided by this invention involves acquiring near-infrared spectral data corresponding to a target tobacco leaf, dividing the near-infrared spectral data into multiple window spectral segments using a sliding window method, inputting all window spectral segments into a pre-trained target spectral feature evaluation model to obtain a spectral feature score for each window spectral segment, determining the target spectral segment from the window spectral segments based on the spectral feature score, and determining the target spectral band corresponding to the target tobacco leaf based on the target spectral segment. This invention solves the problem in existing technologies where noise and redundant information in high-dimensional spectral data cause severe interference, leading to insufficient accuracy in model analysis. It allows for evaluation and screening of each spectral segment after sliding window division, overcoming the noise and redundant information interference problem in high-dimensional near-infrared spectral data. This improves prediction accuracy while achieving automated screening of feature bands, providing a complete solution for rapid, objective, and intelligent evaluation of tobacco leaf quality.

[0106] In one optional implementation, the target spectral feature evaluation model includes a linear projection layer, a feature analysis layer, and an index evaluation layer. The segment feature scoring module 320 is specifically used to: input all window spectral segments into the linear projection layer to obtain a feature vector sequence corresponding to each window spectral segment; input the feature vector sequence corresponding to all window spectral segments into the feature analysis layer to obtain a global feature representation corresponding to each window spectral segment; and input the global feature representation corresponding to all window spectral segments into the index evaluation layer to obtain a spectral feature score corresponding to each window spectral segment.

[0107] In an optional implementation, the fragment feature scoring module 320 includes a feature vector sequence determination unit, configured to: input the window spectral fragment to the linear projection layer for each window spectral fragment, so that the linear projection layer divides the window spectral fragment into multiple non-overlapping fragment patches, perform tensor rearrangement operation on all fragment patches, and map each tensor-rearranged fragment patch to an embedding vector of a preset dimension to obtain the feature vector sequence.

[0108] In an optional implementation, the fragment feature scoring module 320 further includes a feature vector sequence processing unit, configured to: concatenate a learnable classification label at the beginning of the feature vector sequence to obtain a processed vector sequence; wherein the processed vector sequence is used as a vector that is randomly initialized and updated during model training, and its final state is used as a global representation of the entire sequence; embed a learnable positional encoding into the processed vector sequence, and use the embedded vector sequence as the input of the feature analysis layer.

[0109] In one alternative implementation, the feature analysis layer includes multiple attention modules, each attention module including an attention mechanism unit and a feedforward neural network, and employs residual connections and layer normalization.

[0110] In an optional implementation, the segment feature scoring module 330 is specifically used to: determine the target window segment number corresponding to the target spectral segment, substitute the target window segment number and the starting wavenumber corresponding to the near-infrared spectral data into a preset wavenumber limit formula to obtain the left boundary wavenumber and the right boundary wavenumber, and take the band formed by the left boundary wavenumber and the right boundary wavenumber as the target spectral band.

[0111] In one optional implementation, the preset wavenumber limit formula is:

[0112] ;

[0113] ;

[0114] in, The sliding step size, For window width, The target window segment number, Wavenumber resolution.

[0115] The tobacco leaf spectral band analysis device provided in the embodiments of the present invention can execute the tobacco leaf spectral band analysis method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the method.

[0116] Figure 11 This is a schematic diagram of the structure of a computer device provided in an embodiment of the present invention. Figure 11 A block diagram of an exemplary computer device 12 suitable for implementing embodiments of the present invention is shown. Figure 11 The computer device 12 shown is merely an example and should not be construed as limiting the functionality or scope of the embodiments of the present invention. The computer device 12 can be any terminal device with computing capabilities and can be configured within a tobacco leaf spectral band analysis device.

[0117] like Figure 11 As shown, the computer device 12 is represented in the form of a general-purpose computing device. The components of the computer device 12 may include, but are not limited to: one or more processors or processing units 16, system memory 28, and bus 18 connecting different system components (including system memory 28 and processing unit 16).

[0118] Bus 18 can be one or more of several bus architectures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus architectures. For example, these architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MAC) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnect (PCI) bus.

[0119] Computer device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by computer device 12, including volatile and non-volatile media, removable and non-removable media.

[0120] System memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache 32. Computer device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 34 may be used to read and write non-removable, non-volatile magnetic media (… Figure 11 Not shown; usually referred to as a "hard drive"). Although Figure 11 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk") and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 via one or more data media interfaces. System memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments of the present invention.

[0121] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in system memory 28. Such program modules 42 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Program modules 42 typically perform the functions and / or methods described in the embodiments of the present invention.

[0122] Computer device 12 can also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), and with one or more devices that enable a user to interact with the computer device 12, and / or with any device that enables the computer device 12 to communicate with one or more other computing devices (e.g., network card, modem, etc.). This communication can be performed through input / output (I / O) interface 22. Furthermore, computer device 12 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 20. Figure 11 As shown, network adapter 20 communicates with other modules of computer device 12 via bus 18. It should be understood that, although... Figure 11 As not shown, it can be used in conjunction with computer device 12 with other hardware and / or software modules, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0123] Processing unit 16 executes various functional applications and data processing by running programs stored in system memory 28, such as implementing the tobacco leaf spectral band analysis method provided in this embodiment of the invention, which includes:

[0124] Near-infrared spectral data corresponding to the target tobacco leaf is acquired, and the near-infrared spectral data is segmented into multiple window spectral segments by sliding window; all window spectral segments are input into a pre-trained target spectral feature evaluation model to obtain a spectral feature score corresponding to each window spectral segment; the target spectral segment is determined from the window spectral segments based on the spectral feature score, and the target spectral band corresponding to the target tobacco leaf is determined based on the target spectral segment.

[0125] This embodiment provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the tobacco leaf spectral band analysis method as provided in any embodiment of the present invention, including:

[0126] Near-infrared spectral data corresponding to the target tobacco leaf is acquired, and the near-infrared spectral data is segmented into multiple window spectral segments by sliding window; all window spectral segments are input into a pre-trained target spectral feature evaluation model to obtain a spectral feature score corresponding to each window spectral segment; the target spectral segment is determined from the window spectral segments based on the spectral feature score, and the target spectral band corresponding to the target tobacco leaf is determined based on the target spectral segment.

[0127] The computer storage medium of this invention can be any combination of one or more computer-readable media. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0128] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of sending, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device.

[0129] Program code contained on a computer-readable medium may be transmitted using any suitable medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.

[0130] Computer program code for performing the operations of this invention can be written in one or more programming languages ​​or a combination thereof. Programming languages ​​include object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as C or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0131] Those skilled in the art will understand that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby allowing them to be stored in a storage device for execution by a computing device, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.

[0132] Note that the above description is merely a preferred embodiment of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of the present invention, the scope of which is determined by the scope of the appended claims.

Claims

1. A method for spectral band analysis of tobacco leaves, characterized in that, include: Obtain the near-infrared spectral data corresponding to the target tobacco leaf, and perform sliding window segmentation on the near-infrared spectral data to obtain multiple window spectral segments; All window spectral segments are input into a pre-trained target spectral feature evaluation model to obtain the spectral feature score corresponding to each window spectral segment; The target spectral segment is determined from the window spectral segment based on the spectral feature score, and the target spectral band corresponding to the target tobacco leaf is determined based on the target spectral segment.

2. The method according to claim 1, characterized in that, The target spectral feature evaluation model includes: a linear projection layer, a feature analysis layer, and an index evaluation layer. The step of inputting the feature vector sequence corresponding to all window spectral segments into the pre-trained target spectral feature evaluation model to obtain the spectral feature score corresponding to each window spectral segment includes: All window spectral segments are input into the linear projection layer to obtain the feature vector sequence corresponding to each window spectral segment; The feature vector sequence corresponding to all window spectral segments is input into the feature analysis layer to obtain the global feature representation corresponding to each window spectral segment; The global feature representations corresponding to all window spectral segments are input into the index evaluation layer to obtain the spectral feature score corresponding to each window spectral segment.

3. The method according to claim 2, characterized in that, The step of inputting all window spectral segments into the linear projection layer to obtain the feature vector sequence corresponding to each window spectral segment includes: For each window spectral segment, the window spectral segment is input to the linear projection layer, so that the linear projection layer divides the window spectral segment into multiple non-overlapping segment patches. Tensor rearrangement is performed on all segment patches, and each tensor-rearranged segment patch is mapped to an embedding vector of a preset dimension to obtain the feature vector sequence.

4. The method according to claim 2, characterized in that, Before inputting the feature vector sequence corresponding to all window spectral segments into the feature analysis layer, the method further includes: A learnable classification label is concatenated at the beginning of the feature vector sequence to obtain a processed vector sequence; wherein, the processed vector sequence is a vector that is randomly initialized and updated during model training, and its final state is used as a global representation of the entire sequence; The learnable positional encoding is embedded into the processed vector sequence, and the embedded vector sequence is used as the input to the feature analysis layer.

5. The method according to claim 2, characterized in that, The feature analysis layer includes multiple attention modules, each of which includes an attention mechanism unit and a feedforward neural network, and employs residual connections and layer normalization.

6. The method according to claim 1, characterized in that, The step of determining the target spectral segment from the window spectral segment based on the spectral feature score, and determining the target spectral band corresponding to the target tobacco leaf based on the target spectral segment, includes: Determine the target window segment number corresponding to the target spectral segment, substitute the target window segment number and the starting wavenumber corresponding to the near-infrared spectral data into the preset wavenumber limit formula to obtain the left boundary wavenumber and the right boundary wavenumber, and take the band formed by the left boundary wavenumber and the right boundary wavenumber as the target spectral band.

7. The method according to claim 6, characterized in that, The preset wavenumber limit formula is: ; ; in, The sliding step size, For window width, The target window segment number, Wavenumber resolution.

8. A device for analyzing the spectral bands of tobacco leaves, characterized in that, The device includes: The window segmentation module is used to acquire the near-infrared spectral data corresponding to the target tobacco leaf, and to perform sliding window segmentation on the near-infrared spectral data to obtain multiple window spectral segments. The segment feature scoring module is used to input all window spectral segments into the pre-trained target spectral feature evaluation model to obtain the spectral feature score corresponding to each window spectral segment; The spectral band determination module is used to determine the target spectral segment from the window spectral segment based on the spectral feature score, and to determine the target spectral band corresponding to the target tobacco leaf based on the target spectral segment.

9. A computer device, characterized in that, The computer device includes: One or more processors; Memory, used to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the tobacco leaf spectral band analysis method as described in any one of claims 1-7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by the processor, the program implements the tobacco leaf spectral band analysis method as described in any one of claims 1-7.