A multi-parameter spectral inversion method based on ranking contrastive learning
Patent Information
- Application Number
- CN202611197727.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-07
- Publication Date
- 2026-10-13
AI Technical Summary
[0005]针对现有技术的不足,本发明提供了一种基于排序对比学习的多参数光谱反演方法,解决了上述背景技术中提出的反演结果的精度与病虫害等级分类的可靠性受到制约,无法满足精准农业中快速、无损、高精度检测的实际需求的问题
[0052]1.本发明中,通过构建包含波段注意力机制的共享特征提取网络,基于标准化光谱特征数据提取深层光谱特征生成带注意力权重的光谱特征向量,并利用多个并行的回归头分别预测不同的植物生理参数含量,使得模型能够自适应聚焦关键光谱波段,提高多参数同步预测的准确性。
Smart Images

Figure CN122906557A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of agricultural detection technology, specifically a multi-parameter spectral inversion method based on ranking and comparison learning. Background Technology
[0002] Multi-parameter spectral inversion is a key technology that uses remote sensing to establish a quantitative relationship model between spectral data and surface physical parameters, thereby acquiring multiple environmental or geological parameters simultaneously. In precision agriculture, rapid and non-destructive detection of plant physiological parameters and pest and disease levels is of great significance for guiding field management.
[0003] Currently, existing multi-parameter spectral inversion methods lack effective utilization of the inherent ranking relationship between spectral features and multiple physiological parameters in the process of plant physiological parameter detection and pest and disease level discrimination. This limits the accuracy of the inversion results and the reliability of pest and disease level classification, and fails to meet the actual needs of rapid, non-destructive, and high-precision detection in precision agriculture.
[0004] Therefore, a multi-parameter spectral inversion method based on ranking and comparison learning is proposed to solve the above problems. Summary of the Invention
[0005] To address the shortcomings of existing technologies, this invention provides a multi-parameter spectral inversion method based on ranking and comparison learning. This method solves the problem mentioned in the background that the accuracy of the inversion results and the reliability of pest and disease classification are limited, failing to meet the actual needs of rapid, non-destructive, and high-precision detection in precision agriculture.
[0006] To achieve the above objectives, the present invention provides the following technical solution: a multi-parameter spectral inversion method based on ranking and contrastive learning, the method comprising the following steps:
[0007] S1. Collect multispectral reflectance data of the sample to be tested, and preprocess the multispectral reflectance data to generate standardized spectral feature data;
[0008] S2. Construct a shared feature extraction network that includes a band attention mechanism, extract deep spectral features based on the standardized spectral feature data, and generate a spectral feature vector with attention weights.
[0009] S3. Based on the attention-weighted spectral feature vector, different plant physiological parameter contents are predicted by multiple parallel regression heads to generate preliminary physiological parameter prediction data.
[0010] S4. Construct a ranking and contrast learning branch, map the attention-weighted spectral feature vector to the contrast space, and generate a projected feature vector;
[0011] S5. Use the ranking comparison loss function to constrain the similarity of the projected feature vectors to be consistent with the similarity of the true values of the plant physiological parameters, and generate ranking consistency constraint data.
[0012] S6. Integrate the preliminary physiological parameter prediction data with the sorting consistency constraint data, optimize the model parameters through a joint loss function, and generate an optimized multi-parameter spectral inversion model.
[0013] S7. Input the standardized spectral feature data into the optimized multi-parameter spectral inversion model to obtain the prediction result, and then perform cross-attention fusion and classification on the prediction result and the standardized spectral feature data to output the state evaluation result of the sample to be tested.
[0014] Preferably, the generation of standardized spectral feature data in S1 includes:
[0015] S11. Using a handheld analyzer with integrated multispectral sensors, the blades are illuminated by an active light source in a closed darkroom environment to collect raw data of reflected light intensity covering discrete spectral channels in the range of 410nm-940nm.
[0016] S12. Perform dark current subtraction and standard reflectivity plate correction on the original reflected light intensity data to generate corrected reflectivity spectral data.
[0017] S13. Perform standard normal variable transformation on the corrected reflectance spectral data to generate standardized spectral feature data;
[0018] S14. Perform repeated measurements on the same sample, remove outliers, and take the average value as the final standardized spectral characteristic data.
[0019] Preferably, the standard normal variable transformation in S13 includes:
[0020] S131. For each sample in the unstandardized spectral feature data, iterate through all spectral band reflectance values for that sample.
[0021] S132. Calculate the average and standard deviation of the reflectance values for all spectral bands in the current sample.
[0022] S133. Using the mean and standard deviation, the reflectance values of each spectral band in the sample are standardized to generate standardized intermediate variables.
[0023] S134. Reorganize the standardized intermediate variables of all spectral bands according to the original spectral dimension order to generate the final standardized spectral feature data.
[0024] Preferably, the generation of the attention-weighted spectral feature vector in S2 includes:
[0025] S21. Construct a multilayer perceptron consisting of multiple linear layers, batch normalization layers, nonlinear activation function layers, and dropout layers as the basic feature extractor.
[0026] S22. Embed a band attention module in the basic feature extractor. The band attention module generates adaptive Sigmoid gate weights for each spectral feature channel through a fully connected network with a reduction rate.
[0027] S23. Multiply the Sigmoid gate weights element-wise with the input basic spectral features to generate a spectral feature vector with attention weights.
[0028] Preferably, the generation of preliminary physiological parameter prediction data in step S3 includes:
[0029] S31. Set up three parallel regression head networks, each consisting of a fully connected layer, to predict chlorophyll content, nitrogen content, and carotenoid content, respectively.
[0030] S32. The input to each regression head is the attention-weighted spectral feature vector, and the output is a scalar value representing the predicted content of the corresponding physiological parameter.
[0031] Preferably, generating the projection feature vector in S4 includes:
[0032] S41. Set up three parallel projection head networks, each projection head consisting of a fully connected layer, corresponding one-to-one with the three regression heads;
[0033] S42. Each projection head maps the attention-weighted spectral feature vector to a low-dimensional contrast space to generate an L2-normalized projection feature vector.
[0034] Preferably, the generation of sorting consistency constraint data in step S5 includes:
[0035] S51. Within a batch, calculate the cosine similarity between the projected feature vectors of all samples and generate a projected feature similarity matrix.
[0036] S52. Based on the true values of plant physiological parameters of all samples in the same batch, calculate the label similarity between any two samples using the exponential decay function, and generate a label similarity matrix.
[0037] S53. Remove the self-similar terms from the projection feature similarity matrix and the label similarity matrix, and calculate the mean square error between them as the ranking comparison loss value;
[0038] S54. Minimize the ranking comparison loss value through the backpropagation algorithm to ensure that the similarity between the projected feature vectors is consistent with the label similarity matrix.
[0039] Preferably, in step S6, optimizing the model parameters through a joint loss function includes:
[0040] S61. Calculate the mean square error between the predicted value and the true value for each physiological parameter regression head, and generate multiple mean square error loss values.
[0041] S62. Weighted summation of all mean squared error loss values and sorting comparison loss values to generate joint loss value;
[0042] S63. Based on the joint loss value, an optimizer is used to jointly optimize the network parameters of the shared feature extraction network, the band attention module, the regression head, and the projection head until the model converges.
[0043] Preferably, the state assessment result of the sample to be tested output in S7 includes:
[0044] S71. The standardized spectral feature data and the predicted content of plant physiological parameters are used as dual-modal inputs and input into the cross-attention fusion network;
[0045] S72. Through the bidirectional cross-attention mechanism of the cross-attention fusion network, calculate the interaction attention weight between spectral features and physiological parameter features, and generate a fused feature vector;
[0046] S73. Input the fused feature vector into the classifier and output the state evaluation result of the sample to be tested.
[0047] Preferably, the method further includes model calibration and periodic calibration steps:
[0048] S81. Before the model is put into use, the optimized multi-parameter spectral inversion model is calibrated by preparing a series of standard samples with different physiological parameter contents and measuring their true values.
[0049] S82. During periodic calibration, the raw reflection data of each spectral channel is collected using a standard reflection reference as a new reference value.
[0050] S83. Replace the pre-stored factory reference value with the new reference value to complete the calibration.
[0051] Compared with existing technologies, this invention provides a multi-parameter spectral inversion method based on ranking and contrastive learning, which has the following advantages:
[0052] 1. In this invention, a shared feature extraction network incorporating a band attention mechanism is constructed. Based on standardized spectral feature data, deep spectral features are extracted to generate spectral feature vectors with attention weights. Multiple parallel regression heads are used to predict the content of different plant physiological parameters, enabling the model to adaptively focus on key spectral bands and improve the accuracy of multi-parameter synchronous prediction.
[0053] 2. In this invention, a ranking-contrast learning branch is constructed to map the spectral feature vector with attention weights to the contrast space to generate a projected feature vector. The ranking-contrast loss function is used to constrain the similarity of the projected feature vector to be consistent with the similarity of the true values of plant physiological parameters. This enables the model to utilize the relative ranking relationship between samples during training to enhance the consistency and discriminative ability of parameter inversion.
[0054] 3. In this invention, the prediction results are obtained by inputting standardized spectral feature data into the optimized multi-parameter spectral inversion model. Then, the prediction results and standardized spectral feature data are cross-attention fusion and classification to output the pest and disease level classification results of the test sample. This realizes the dual-modal deep fusion of spectral features and physiological parameter prediction results, and improves the reliability and generalization ability of pest and disease level discrimination.
[0055] 4. This invention uses a joint loss function to weightedly fuse the mean squared error loss and the ranking comparison loss, ensuring that the model retains a continuous relative position constraint even when the MSE gradient approaches zero in the later stages of training. This effectively solves the problem of disordered prediction order in traditional regression methods. Experiments show that on the LOPEX93 dataset, the method of this invention achieves inversion determination coefficients R² of chlorophyll, nitrogen, and carotenoids of 0.7147, 0.7019, and 0.7016, respectively, representing improvements of 27.7%, 39.3%, and 49.8% compared to the optimal baselines (R²=0.5597 for chlorophyll MLP, R²=0.5037 for nitrogen RF, and R²=0.4685 for carotenoid MLP). Even with the addition of Gaussian noise of σ=0.01, the performance degradation is less than 12%. Attached Figure Description
[0056] Figure 1 This is a flowchart of the sub-step S1 in this invention;
[0057] Figure 2 This is a flowchart of the sub-step S2 in this invention;
[0058] Figure 3 This is a flowchart of the sub-step S3 in this invention;
[0059] Figure 4 This is a flowchart of the sub-step S4 in this invention;
[0060] Figure 5 This is a flowchart of the sub-step S5 in this invention;
[0061] Figure 6 This is a flowchart of the sub-step S6 in this invention;
[0062] Figure 7 This is a flowchart of the sub-step S7 in this invention;
[0063] Figure 8 This is a flowchart of the overall process of a multi-parameter spectral inversion method based on ranking and contrastive learning according to the present invention.
[0064] Figure 9 The graph shows the performance of different methods in retrieving plant physiological parameters under noise-free conditions.
[0065] Figure 10 A comparison table of the coefficients of determination (R²) for the inversion of plant physiological parameters under noise-free conditions is presented.
[0066] Figure 11 A comparison of the performance of different methods in retrieving plant physiological parameters under noise-free and noise-free conditions;
[0067] Figure 12 This is a histogram showing the robustness of the spectral inversion method proposed in this invention under different noise conditions;
[0068] Figure 13 This is a comparison table of R² indices for plant physiological parameter inversion under noise-free and noise-prone conditions using the method of this invention;
[0069] Figure 14 A bar chart comparing the accuracy of different methods for classifying pest and disease severity levels under noise-free conditions;
[0070] Figure 15 The table and chart show the average and standard deviation of the accuracy rates of different methods for classifying pest and disease levels under noise-free conditions.
[0071] Figure 16 A comparison chart showing the accuracy of different methods in classifying pest and disease levels under noise-free conditions;
[0072] Figure 17 This is a statistical table showing the accuracy of pest and disease classification under noise-free and noise-free conditions using the integrated solution of this invention. Detailed Implementation
[0073] 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, and 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.
[0074] For specific implementation examples, please refer to: Figures 1-8 A multi-parameter spectral inversion method based on ranking and contrastive learning, comprising the following steps:
[0075] S1. Collect multispectral reflectance data of the sample to be tested, and preprocess the multispectral reflectance data to generate standardized spectral feature data;
[0076] S2. Construct a shared feature extraction network that includes a band attention mechanism, extract deep spectral features based on standardized spectral feature data, and generate spectral feature vectors with attention weights.
[0077] S3. Based on the spectral feature vector with attention weights, multiple parallel regression heads are used to predict the content of different plant physiological parameters, generating preliminary physiological parameter prediction data.
[0078] S4. Construct a ranking and contrast learning branch, map the spectral feature vector with attention weights to the contrast space, and generate a projected feature vector;
[0079] S5. Use the ranking comparison loss function to constrain the similarity of the projected feature vectors to be consistent with the similarity of the true values of plant physiological parameters, and generate ranking consistency constraint data.
[0080] S6. Integrate the preliminary physiological parameter prediction data with the ranking consistency constraint data, optimize the model parameters through the joint loss function, and generate an optimized multi-parameter spectral inversion model;
[0081] S7. Input the standardized spectral feature data into the optimized multi-parameter spectral inversion model to obtain the prediction results. Then, perform cross-attention fusion and classification on the prediction results and standardized spectral feature data to output the state assessment results of the sample to be tested. The state assessment results include the pest and disease level classification results.
[0082] S1 generates standardized spectral feature data, including:
[0083] S11. Using a handheld analyzer with integrated multispectral sensors, the blades are illuminated by an active light source in a closed darkroom environment to collect raw data of reflected light intensity covering discrete spectral channels in the range of 410nm-940nm.
[0084] S12. Perform dark current subtraction and standard reflectivity plate correction on the raw reflected light intensity data to generate corrected reflectivity spectral data.
[0085] This step introduces a dark current subtraction and standard reflectivity plate calibration process. First, a dark-field image is acquired under no-light conditions, and the reference offset of each pixel of the sensor is recorded, denoted as the dark current matrix. Then, a reference spectrum is acquired under uniform irradiation of a standard diffuse reflector to obtain the standard reflectivity matrix. For the original spectrum of the actual sample to be tested, its calibrated spectrum is calculated using a linear normalization model, as shown in the following formula:
[0086] ;
[0087] in, To be located in spatial position after correction ,wavelength Spectral radiance value at that location, These are the original, uncorrected spectral radiance values. This represents the dark current offset at the corresponding position and wavelength. The reflectivity of a standard reflectivity plate at the current wavelength. The preset standard reflectance reference value;
[0088] S13. Perform standard normal variable transformation on the corrected reflectance spectral data to generate standardized spectral feature data;
[0089] S14. Perform repeated measurements on the same sample, remove outliers, and take the average value as the final standardized spectral characteristic data.
[0090] The standard normal variable transformation in S13 includes:
[0091] S131. For each sample in the unstandardized spectral feature data, iterate through all spectral band reflectance values for that sample.
[0092] S132. Calculate the average and standard deviation of the reflectance values for all spectral bands in the current sample.
[0093] S133. Using the mean and standard deviation, standardize the reflectance values of each spectral band in the sample to generate standardized intermediate variables.
[0094] The formula for calculating the standardized transformation is:
[0095] ;
[0096] in, This represents the standardized spectral feature data. This represents the raw spectral reflectance data. This represents the average reflectance values across all spectral bands for the current sample. This represents the standard deviation of the reflectance values across all spectral bands for the current sample.
[0097] S134. Reorganize the standardized intermediate variables of all spectral bands according to the original spectral dimension order to generate the final standardized spectral feature data.
[0098] S2 generates spectral feature vectors with attention weights, including:
[0099] S21. Construct a multilayer perceptron consisting of multiple linear layers, batch normalization layers, nonlinear activation function layers, and dropout layers as the basic feature extractor.
[0100] S22. Embed a band attention module in the basic feature extractor. The band attention module generates adaptive Sigmoid gate weights for each spectral feature channel through a fully connected network with a reduction rate.
[0101] The formula for calculating the Sigmoid gate weight is:
[0102] ;
[0103] in, This represents the generated Sigmoid gate weight vector. This represents the input feature vector. and These are the weight matrices for the first and second fully connected layers, respectively. and For bias vectors, This represents the Sigmoid activation function. Represents the linear rectification activation function;
[0104] S23. Multiply the Sigmoid gate weights element-wise with the input basic spectral features to generate a spectral feature vector with attention weights.
[0105] Preliminary physiological parameter prediction data are generated in S3, including:
[0106] S31. Set up three parallel regression head networks, each consisting of a fully connected layer, to predict chlorophyll content, nitrogen content, and carotenoid content, respectively.
[0107] S32. The input to each regression head is a spectral feature vector with attention weights, and the output is a scalar value representing the predicted content of the corresponding physiological parameter.
[0108] S4 generates projected feature vectors, including:
[0109] S41. Set up three parallel projection head networks, each projection head consisting of a fully connected layer, corresponding one-to-one with the three regression heads;
[0110] S42. Each projection head maps the attention-weighted spectral feature vector to a low-dimensional contrast space to generate an L2-normalized projection feature vector.
[0111] The formula for calculating L2 normalization is:
[0112] ;
[0113] in, Indicates the first The L2-normalized projected feature vectors of each sample Indicates the first The attention-weighted spectral feature vector of each sample. The mapping function represents the projection head network. This represents the L2 norm.
[0114] S5 generates sorted consistency constraint data, including:
[0115] S51. Within a batch, calculate the cosine similarity between the projected feature vectors of all samples and generate a projected feature similarity matrix.
[0116] The formula for calculating cosine similarity is:
[0117] ;
[0118] in, Indicates the first The sample and the first Cosine similarity of the projected features of each sample and The first The first sample and the first L2-normalized projected feature vectors of each sample;
[0119] S52. Based on the true values of plant physiological parameters of all samples in the same batch, calculate the label similarity between any two samples using the exponential decay function, and generate a label similarity matrix.
[0120] The formula for calculating the tag similarity matrix is:
[0121] ;
[0122] in, Indicates the first The sample and the first Label similarity between samples and They represent the first The first sample and the first The true values of plant physiological parameters for each sample;
[0123] The temperature coefficient controls the sensitivity of label similarity to differences in physical quantities. Its value has a clear physical meaning: when τ→0, the label similarity function degenerates into a binary hard margin, losing its ranking continuity; when τ→∞, the similarity of all sample pairs approaches 1, losing its ranking constraint. This invention, considering the chlorophyll content distribution range of the LOPEX93 dataset (approximately 1–100 μg / cm²), after normalization, sets τ = 0.6 based on this data distribution characteristic. This value allows the label similarity function to decay rapidly when sample differences are large to enhance discriminative power, and to change smoothly when sample differences are small to maintain continuity, demonstrating a targeted adaptation to the spectral-biochemical parameter inversion task.
[0124] S53. Remove self-similar terms from the projection feature similarity matrix and the label similarity matrix, and calculate the mean square error between them as the ranking comparison loss value;
[0125] The formula for calculating the ranking comparison loss is:
[0126] ;
[0127] in, This indicates the ranking comparison loss value. Indicates the total number of samples;
[0128] S54. Minimize the ranking comparison loss value through the backpropagation algorithm to ensure that the similarity between projected feature vectors is consistent with the label similarity matrix;
[0129] Gradient descent is used to backpropagate the gradients of the ranking comparison loss values with respect to the parameters of each network layer, adjusting the weights of feature extraction and the projection head. The gradient of the loss function with respect to the parameters drives the model parameter updates, as shown in the following formula:
[0130] ;
[0131] in, For the updated set of network parameters, The set of network parameters for the current iteration step. The learning rate hyperparameter, To rank and compare the loss function with respect to the parameters gradient, This is the set of projected feature vectors output by the network. The set of true labels for the physiological parameters corresponding to the samples;
[0132] The gradient of the ranking-contrast loss with respect to the projected features has the following form:
[0133]
[0134] This gradient formula reveals the unique mechanism of this invention: adaptive attraction / repulsion – when the projected feature similarity S_ij is higher than the label similarity L_ij, a repulsive force is generated to push the features away; conversely, an attractive force is generated to pull them closer. The magnitude of the force is proportional to the degree of deviation between the feature similarity and the label similarity, achieving fine-grained control over the feature distribution. Simultaneously, the gradient calculation relies on the weighted sum of all other samples within the batch. Compared to Triplet Loss, which only relies on the local gradients of a few of the most difficult sample pairs, this loss function has less gradient noise, more stable training, and can effectively avoid the order reversal problem caused by the model getting trapped in local optima.
[0135] Existing contrastive losses, commonly used in conventional technologies, require constructing positive-negative sample pairs and are only applicable to classification tasks. Conventional regression losses focus only on absolute error and ignore the order relationship between samples. Unlike these methods, the ranking contrastive loss proposed in this invention directly utilizes the label differences of all samples within a batch to construct a target similarity matrix. By minimizing the mean squared error between projected feature similarity and label similarity, it maintains the order consistency between samples without constructing positive-negative pairs. The advantages of this loss function are: it explicitly introduces ranking information, enabling the model to simultaneously optimize absolute error and relative order in regression tasks, thereby significantly improving inversion accuracy; and the gradient form is a global ranking gradient, avoiding the positive-negative pair sampling bias problem of traditional contrastive losses. Existing contrastive losses, if directly applied to regression tasks, will result in the loss of label information due to the inability to define "absolutely positive samples." For example, chlorophyll content differences of 0.1 μg / cm² and 10 μg / cm² are both classified as different classes. This invention maps physical differences to continuous target similarity through an exponential decay function, fully preserving the numerical relative proximity relationship.
[0136] S6 optimizes model parameters through a joint loss function, including:
[0137] S61. Calculate the mean square error between the predicted value and the true value for each physiological parameter regression head, and generate multiple mean square error loss values.
[0138] The formula for calculating the mean squared error loss value is:
[0139] ;
[0140] in, For the first The mean squared error loss value of each physiological parameter For the first The sample at the th Predicted values for each physiological parameter For the first The sample at the th The true value of each physiological parameter The total number of physiological parameters to be predicted;
[0141] S62. Weighted sum of all mean squared error loss values and sorting comparison loss values to generate joint loss value;
[0142] The formula for calculating the joint loss value is:
[0143] ;
[0144] in, Represents the joint loss value. Chl), N), Car) represent the mean squared error loss values for chlorophyll, nitrogen, and carotenoids, respectively. These represent the ranking contrast loss values for chlorophyll, nitrogen, and carotenoids, respectively. This is the balance coefficient;
[0145] The multi-objective design of the joint loss described above is based on the following findings: MSE only focuses on absolute numerical deviation. In the later stages of training, the MSE gradient tends to zero, making the model prone to overfitting or disordered ordering. For example, the actual chlorophyll content of two leaves may differ by only 0.5 μg / cm², but the model's predicted value fluctuates by 5.0 μg / cm², completely reversing the predicted and actual ordering. The ranking contrast loss provides a continuous constraint on relative position—even if the MSE gradient disappears, the gradient still exists as long as the projected feature similarity matrix and the label similarity matrix are inconsistent, forcing the feature space to maintain an equidistant mapping. Experimental results show that adding this ranking contrast loss improves the consistency of the model's predictions and the accuracy of inversion, effectively improving the monotonicity of the predicted sequence.
[0146] S63. Based on the joint loss value, an optimizer is used to jointly optimize the network parameters of the shared feature extraction network, the band attention module, the regression head, and the projection head until the model converges.
[0147] S7 outputs the state assessment results of the sample under test, including:
[0148] S71. Standardized spectral feature data and plant physiological parameter content prediction results are used as dual-modal inputs and fed into the cross-attention fusion network;
[0149] S72. Through the bidirectional cross-attention mechanism of the cross-attention fusion network, the interaction attention weight between spectral features and physiological parameter features is calculated to generate a fused feature vector.
[0150] This step introduces a bidirectional cross-attention mechanism, using the spectral feature vector and the physiological parameter feature vector as the query and key / value inputs to the multi-head attention layer, respectively. The bidirectional interaction weight matrix is calculated, and the fused features are generated. The specific formula is as follows:
[0151] ;
[0152] ;
[0153] in, Here is the attention weight matrix. For querying the matrix, The key matrix, For value matrices, Let be the dimension of the key vector. This is the feature vector obtained by fusing spectral and physiological parameter features;
[0154] It should be noted that in this embodiment, bidirectional cross-attention is implemented in the form of bilinear projection and cross-modal residual connection. That is, spectral features and physiological parameter features are used as cross-modal information sources, respectively. After linear projection, they are added to the features of another modality to achieve feature interaction enhancement. In the implementation of bilinear projection and cross-modal residual connection, the interactive attention weight is reflected as the learned cross-modal projection matrix (i.e., the parameters of the linear projection layer), and the sample-by-sample weighting degenerates into an identity weighting of the projection. The above-mentioned scaled dot product cross-attention and bilinear projection + cross-modal residual connection are both implementations of the cross-attention mechanism of this invention. Those skilled in the art can choose to implement them according to actual needs.
[0155] S73. Input the fused feature vector into the classifier and output the state assessment result of the sample to be tested. The state assessment result includes the classification result of the pest and disease level.
[0156] The method also includes model calibration and periodic calibration steps:
[0157] S81. Before the model is put into use, the optimized multi-parameter spectral inversion model is calibrated by preparing a series of standard samples with different physiological parameter contents and measuring their true values.
[0158] To support supervised training and performance validation of the model, this step requires constructing a calibration dataset covering the entire spectrum. In a laboratory setting, researchers use sophisticated instruments such as chemical titration and chlorophyll meters to determine the true content of physiological parameters in a series of standard samples, and simultaneously collect high signal-to-noise ratio reflectance data across the entire spectrum. The true parameter values of the samples and their spectral reflectance curves together constitute training sample pairs, the specific relationship of which is described below:
[0159] ;
[0160] in, This is the standard sample dataset used for model training. For the first A standard sample at wavelength Spectral reflectance at that location No. A vector of true values of multidimensional physiological parameters corresponding to each sample. This represents the total number of standard samples in the dataset.
[0161] S82. During periodic calibration, the raw reflection data of each spectral channel is collected using a standard reflection reference as a new reference value.
[0162] S83. Replace the pre-stored factory reference value with the new reference value to complete the calibration.
[0163] Specific experiment:
[0164] Overall Experimental Setup
[0165] This embodiment is used to verify the performance of the plant monitoring scheme for multi-parameter spectral inversion and pest and disease severity classification proposed in this invention. The scheme consists of two core parts:
[0166] Part 1: A multi-parameter spectral inversion model based on ranking contrastive learning and band attention was trained on the LOPEX93 dataset to extract three key physiological parameters—chlorophyll, nitrogen, and carotenoids—from the raw spectrum.
[0167] Part Two: A pest and disease classification model based on cross-attention fusion integrates the original spectral features with the physiological parameter features obtained by inversion, achieving high-precision classification on wheat pest and disease datasets.
[0168] Both parts share the same experimental verification process: the training set and the test set are randomly divided 5 times, with each division randomly splitting the dataset in a 7:3 ratio, and the average ± standard deviation of the 5 division results is taken as the final performance index; the verification is carried out under noise-free training conditions and under anti-interference conditions with σ=0.01 Gaussian noise added to the training data.
[0169] Example 1: Multi-parameter spectral inversion based on ranking contrastive learning and band attention
[0170] 2.1 Experimental Setup
[0171] This embodiment uses the LOPEX93 dataset to verify the performance of the inversion model of this invention. The experimental setup is as follows:
[0172] Experimental procedure: The training and test sets were randomly divided 5 times, and the mean ± standard deviation was taken.
[0173] Noise parameter: σ=0.01
[0174] Comparison methods: PLSR, SVR, RF, MLP, XGBoost
[0175] Performance metrics: Coefficient of determination (R²), Root mean square error (RMSE)
[0176] Training hyperparameters: The optimizer used is AdamW, with an initial learning rate of 1e-3 and a weight decay of 1e-4; the batch size is 32; the maximum number of training epochs is 500, with an early stopping strategy and a patience value of 80 epochs; the learning rate scheduling uses ReduceLROnPlateau, with a patience value of 30 epochs and a decay factor of 0.5; the maximum norm of gradient clipping is 1.0; 10% of the training set is allocated as a validation set.
[0177] 2.2 Inversion performance under noise-free conditions
[0178] Inversion performance of different methods under noise-free conditions:
[0179] Please see Figures 9-10 ;
[0180] As shown in the figure, the method of the present invention achieves high-precision synchronous inversion of three physiological parameters under noise-free conditions:
[0181] The chlorophyll inversion R² reached 0.7147 ± 0.0213 (mean RMSE 8.37), which is 27.7% higher than the optimal baseline MLP (R² = 0.5597);
[0182] The nitrogen inversion R² reached 0.7019 ± 0.0571 (mean RMSE 0.58), an improvement of 39.3% compared to the optimal baseline RF (R² = 0.5037);
[0183] The carotenoid inversion R² reached 0.7016±0.0372 (RMSE mean 2.10), which is an improvement of 49.8% compared with the optimal baseline MLP (R²=0.4685).
[0184] 2.3 Noise Robustness Verification
[0185] Comparison of inversion performance of different methods under noise-free conditions:
[0186] Please see Figures 11-13 ;
[0187] Experimental results show that, under the condition of adding σ=0.01 Gaussian noise, the inversion R² of the three parameters of the method of the present invention is still maintained at 0.6680±0.0374, 0.6531±0.0546 and 0.6225±0.0781 respectively (corresponding to RMSE mean values of 9.04, 0.62 and 2.37), and the performance degradation is less than 12%.
[0188] Example 2: Classification of Plant Diseases and Pests Based on Cross-Attention Fusion
[0189] 3.1 Experimental Setup
[0190] This embodiment uses a wheat flag leaf disease and pest dataset to verify the classification performance of the integrated monitoring scheme of this invention. This embodiment includes an independent inversion model training process: first, an inversion model based on ranking-contrast learning and band attention is trained on the LOPEX93 dataset; then, this model is used to extract chlorophyll, nitrogen, and carotenoids as biological features from the original spectra of the wheat dataset; finally, the original spectral features and biological features are input into a cross-attention fusion model for classification. The experimental setup is as follows:
[0191] Experimental procedure: The training and test sets were randomly divided 5 times, and the mean ± standard deviation was taken.
[0192] Noise parameter: σ=0.01
[0193] During training, Gaussian noise (single stacking standard deviation σ = 0.01) was added to the spectral features to enhance model robustness; the cross-attention fusion model, in particular, was enhanced during training with batch dynamic noise by adding two independent Gaussian noises, with an equivalent standard deviation σ_eff ≈ 0.0141. All methods were evaluated on the same noise-free test set under consistent comparison conditions.
[0194] Comparison methods: Spectra RF (random forest with single spectral features), Biochemical RF (random forest with single biological features, using features extracted by the inversion model trained in this embodiment), PLS-DA, SVM, PCA-RF;
[0195] Performance metrics: Classification accuracy
[0196] Training hyperparameters: The optimizer used is AdamW, with a learning rate of 1e-3 and a weight decay of 1e-4; the batch size is 32; the training run is 200 epochs; 20% of the training set is used as the validation set, and the best model is saved based on the accuracy of the validation set.
[0197] 3.2 Classification performance under noise-free conditions
[0198] Classification performance of different methods under noise-free conditions:
[0199] Please see Figures 14-15 ;
[0200] As shown in the figure, the cross-attention fusion method of the present invention achieves high-precision pest and disease classification under noise-free conditions:
[0201] The classification accuracy reached 0.9206±0.0389, which is comparable to the best comparison method PCA-RF;
[0202] Compared to the single spectral feature method (Spectra RF=0.8476), it represents an 8.6% improvement;
[0203] This represents a 32.4% improvement compared to a single biomarker method (Biochemical RF=0.6952).
[0204] Experimental results show that by fusing spectral features with physiological parameters obtained through inversion using the cross-attention mechanism, the complementary information between different features is fully explored, effectively solving the problem of insufficient representation ability of single features.
[0205] 3.3 Noise Robustness Verification
[0206] Comparison of classification performance of different methods under noise-free conditions:
[0207] Please see Figures 16-17 ;
[0208] Experimental results show that, under the condition of adding σ=0.01 Gaussian noise, the classification accuracy of the integrated scheme of the present invention is still maintained at 0.9016±0.0614, and the performance degradation is only 2.06%, which is better than the method using only a single feature (Spectra RF, Biochemical RF).
[0209] Compared with existing technologies, the present invention organically combines physiological parameter inversion with pest and disease identification, forming a complete intelligent monitoring technology system for plant growth status, which has important application value.
[0210] Unlike the "black box" nature of traditional end-to-end deep learning, this invention employs a hierarchical architecture. The first-stage outputs of chlorophyll, nitrogen, and carotenoids all have clear physiological significance, directly revealing which indicator's abnormality is causing the problem. The second-stage cross-attention mechanism characterizes the interaction between spectral and biochemical parameters, providing a basis for diagnosis. While maintaining classification accuracy comparable to existing state-of-the-art methods, this invention offers transparency and traceability unattainable by traditional methods, significantly improving the reliability of field applications.
[0211] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0212] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A multi-parameter spectral inversion method based on ranking and contrastive learning, characterized in that: The method includes the following steps: S1. Collect multispectral reflectance data of the sample to be tested, and preprocess the multispectral reflectance data to generate standardized spectral feature data; S2. Construct a shared feature extraction network that includes a band attention mechanism, extract deep spectral features based on the standardized spectral feature data, and generate a spectral feature vector with attention weights. S3. Based on the attention-weighted spectral feature vector, different plant physiological parameter contents are predicted by multiple parallel regression heads to generate preliminary physiological parameter prediction data. S4. Construct a ranking and contrast learning branch, map the attention-weighted spectral feature vector to the contrast space, and generate a projected feature vector; S5. Use the ranking comparison loss function to constrain the similarity of the projected feature vectors to be consistent with the similarity of the true values of the plant physiological parameters, and generate ranking consistency constraint data. S6. Integrate the preliminary physiological parameter prediction data with the sorting consistency constraint data, optimize the model parameters through a joint loss function, and generate an optimized multi-parameter spectral inversion model. S7. Input the standardized spectral feature data into the optimized multi-parameter spectral inversion model to obtain the prediction result, and then perform cross-attention fusion and classification on the prediction result and the standardized spectral feature data to output the state evaluation result of the sample to be tested.
2. The multi-parameter spectral inversion method based on ranking and contrastive learning according to claim 1, characterized in that: The generation of standardized spectral feature data in S1 includes: S11. Using a handheld analyzer with integrated multispectral sensors, the blades are illuminated by an active light source in a closed darkroom environment to collect raw data of reflected light intensity covering discrete spectral channels in the range of 410nm-940nm. S12. Perform dark current subtraction and standard reflectivity plate correction on the original reflected light intensity data to generate corrected reflectivity spectral data. S13. Perform standard normal variable transformation on the corrected reflectance spectral data to generate standardized spectral feature data; S14. Perform repeated measurements on the same sample, remove outliers, and take the average value as the final standardized spectral characteristic data.
3. The multi-parameter spectral inversion method based on ranking and contrastive learning according to claim 2, characterized in that: The standard normal variable transformation in S13 includes: S131. For each sample in the unstandardized spectral feature data, iterate through all spectral band reflectance values for that sample. S132. Calculate the average and standard deviation of the reflectance values for all spectral bands in the current sample. S133. Using the mean and standard deviation, the reflectance values of each spectral band in the sample are standardized to generate standardized intermediate variables. S134. Reorganize the standardized intermediate variables of all spectral bands according to the original spectral dimension order to generate the final standardized spectral feature data.
4. The multi-parameter spectral inversion method based on ranking and contrastive learning according to claim 3, characterized in that: The generation of attention-weighted spectral feature vectors in S2 includes: S21. Construct a multilayer perceptron consisting of multiple linear layers, batch normalization layers, nonlinear activation function layers, and dropout layers as the basic feature extractor. S22. Embed a band attention module in the basic feature extractor. The band attention module generates adaptive Sigmoid gate weights for each spectral feature channel through a fully connected network with a reduction rate. S23. Multiply the Sigmoid gate weights element-wise with the input basic spectral features to generate a spectral feature vector with attention weights.
5. The multi-parameter spectral inversion method based on ranking and contrastive learning according to claim 4, characterized in that: The preliminary physiological parameter prediction data generated in S3 includes: S31. Set up three parallel regression head networks, each consisting of a fully connected layer, to predict chlorophyll content, nitrogen content, and carotenoid content, respectively. S32. The input to each regression head is the attention-weighted spectral feature vector, and the output is a scalar value representing the predicted content of the corresponding physiological parameter.
6. The multi-parameter spectral inversion method based on ranking and contrastive learning according to claim 5, characterized in that: The generation of the projection feature vector in S4 includes: S41. Set up three parallel projection head networks, each projection head consisting of a fully connected layer, corresponding one-to-one with the three regression heads; S42. Each projection head maps the attention-weighted spectral feature vector to a low-dimensional contrast space to generate an L2-normalized projection feature vector.
7. The multi-parameter spectral inversion method based on ranking and contrastive learning according to claim 6, characterized in that: The generation of sorting consistency constraint data in S5 includes: S51. Within a batch, calculate the cosine similarity between the projected feature vectors of all samples and generate a projected feature similarity matrix. S52. Based on the true values of plant physiological parameters of all samples in the same batch, calculate the label similarity between any two samples using the exponential decay function, and generate a label similarity matrix. S53. Remove the self-similar terms from the projection feature similarity matrix and the label similarity matrix, and calculate the mean square error between them as the ranking comparison loss value; S54. Minimize the ranking comparison loss value through the backpropagation algorithm to ensure that the similarity between the projected feature vectors is consistent with the label similarity matrix.
8. The multi-parameter spectral inversion method based on ranking and contrastive learning according to claim 7, characterized in that: The optimization of model parameters through the joint loss function in S6 includes: S61. Calculate the mean square error between the predicted value and the true value for each physiological parameter regression head, and generate multiple mean square error loss values. S62. Weighted summation of all mean squared error loss values and sorting comparison loss values to generate joint loss value; S63. Based on the joint loss value, an optimizer is used to jointly optimize the network parameters of the shared feature extraction network, the band attention module, the regression head, and the projection head until the model converges.
9. A multi-parameter spectral inversion method based on ranking and contrastive learning according to claim 8, characterized in that: The state evaluation results of the sample to be tested output in S7 include: S71. The standardized spectral feature data and the predicted content of plant physiological parameters are used as dual-modal inputs and input into the cross-attention fusion network; S72. Through the bidirectional cross-attention mechanism of the cross-attention fusion network, calculate the interaction attention weight between spectral features and physiological parameter features, and generate a fused feature vector; S73. Input the fused feature vector into the classifier and output the state evaluation result of the sample to be tested.
10. The multi-parameter spectral inversion method based on ranking and contrastive learning according to claim 1, characterized in that: The method also includes model calibration and periodic calibration steps: S81. Before the model is put into use, the optimized multi-parameter spectral inversion model is calibrated by preparing a series of standard samples with different physiological parameter contents and measuring their true values. S82. During periodic calibration, the raw reflection data of each spectral channel is collected using a standard reflection reference as a new reference value. S83. Replace the pre-stored factory reference value with the new reference value to complete the calibration.