A postharvest internal quality joint prediction method and device for table grapes, an electronic device, and a storage medium
Patent Information
- Application Number
- CN202611218936.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-12
- Publication Date
- 2026-10-30
AI Technical Summary
[0006](1)特征选择波段缺乏明确的物理与化学机理解释:传统的CARS等筛选方法主要依赖统计贡献进行排序,面对高维非线性光谱特征时易引入伪相关噪声
[0051]1、本发明通过CB-SHAP三阶段递进式特征筛选策略,利用CARS与Boruta剔除高维冗余及伪相关变量,并引入博弈论SHAP量化各波段对多指标的非线性边际贡献,不仅使数据维度大幅降低,更赋予了最终核心特征波段明确的物理化学意义。
Smart Images

Figure CN123012534A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of agricultural intelligent detection technology, and in particular to a method, device, electronic equipment and storage medium for joint prediction of the internal quality of fresh grapes after harvest. Background Technology
[0002] Traditional post-harvest internal quality testing of fresh grapes often employs destructive sampling, which is cumbersome, time-consuming, and labor-intensive, making it impossible to achieve simultaneous online monitoring of large batches of samples.
[0003] Hyperspectral imaging technology, by combining the advantages of spectral analysis and image recognition, can simultaneously acquire the spatial information and spectral features of a sample, and is characterized by being non-destructive, efficient, and high in information content. A typical workflow usually includes hyperspectral image acquisition, experimental measurement of physicochemical indicators, spectral preprocessing, characteristic wavelength selection, and regression modeling.
[0004] Traditional spectral dimensionality reduction mainly relies on chemometric methods such as partial least squares regression (PLSR), support vector machines (SVM), and random forests (RF), combined with competitive adaptive reweighted sampling (CARS) to extract feature wavelengths. In recent years, with the development of deep learning, one-dimensional convolutional neural networks (1DCNNs), with their end-to-end nonlinear mapping capabilities, have been gradually applied to the automated extraction of deep spectral features.
[0005] Although existing detection methods based on hyperspectral imaging and deep learning have made some progress in ideal experimental environments, the following serious technical shortcomings still exist in cold chain storage and practical detection applications:
[0006] (1) The selection of feature bands lacks a clear physical and chemical mechanism explanation: Traditional screening methods such as CARS mainly rely on statistical contributions for ranking, which easily introduces spurious correlation noise when facing high-dimensional nonlinear spectral features. This results in the model fitting well on specific samples, but the wavelength selection lacks a clear molecular vibrational physical basis, has weak generalization ability across varieties and maturity stages, and cannot accurately quantify the nonlinear marginal contribution of features to multiple tasks.
[0007] (2) Ignoring temperature fluctuations in the external detection environment: In actual cold chain or shelf detection environments, frequent temperature fluctuations directly change the thermal motion state of water molecules inside the fruit, causing severe nonlinear drift in the near-infrared spectral baseline. Existing models generally use a single hyperspectral channel input, ignoring the nonlinear interference of environmental factors, resulting in poor robustness of the model across different scenarios.
[0008] (3) Single-task independent modeling severs the physiological synergistic relationship between multiple indicators: Existing technologies mostly adopt a single-task learning mode, that is, to establish independent prediction networks for SSC, pH or hardness respectively. This approach not only brings huge redundancy of computing resources and model maintenance burden, but also severs the inherent physiological synergistic relationship between various internal quality indicators of grapes during post-harvest storage, resulting in insufficient mining of deep shared features.
[0009] (4) The hyperparameter space of neural networks is complex and relies on manual tuning experience: The prediction accuracy and convergence speed of deep learning prediction models are highly dependent on the setting of hyperparameters such as learning rate, batch size, and dropout rate. Traditional manual experience-based parameter tuning or grid search is inefficient when facing high-dimensional parameter spaces and is prone to getting stuck in local optima, which restricts the fully automatic global optimization and adaptation of the model.
[0010] Therefore, a method, device, electronic equipment, and storage medium for joint prediction of the postharvest internal quality of table grapes are needed to solve the above problems. Summary of the Invention
[0011] The purpose of this invention is to provide a method, apparatus, electronic device, and storage medium for joint prediction of the internal quality of fresh grapes after harvest.
[0012] A method for joint prediction of postharvest internal quality of table grapes, comprising:
[0013] Raw hyperspectral data of fresh grapes were collected, and the corresponding ambient temperature was recorded. The raw hyperspectral data were preprocessed to obtain preprocessed hyperspectral data.
[0014] A progressive feature selection strategy based on CB-SHAP was adopted to extract key bands from the preprocessed hyperspectral data, resulting in a subset of core feature bands.
[0015] A TF-1DCNN prediction model was constructed, and the core hyperparameters of the model were adaptively optimized globally using the adaptive inertial weighted particle swarm algorithm to obtain the optimized TF-1DCNN prediction model.
[0016] The core feature band subset and the corresponding external ambient temperature are input into the optimized TF-1DCNN prediction model, which outputs joint prediction data of soluble solids content, pH value and pulp firmness of fresh grapes.
[0017] Furthermore, the preliminary preprocessing of the raw hyperspectral data specifically includes:
[0018] The Savitzky-Golay second-order derivative filtering method was used to denoise and eliminate baseline drift in the original hyperspectral data.
[0019] Furthermore, a progressive feature selection strategy based on CB-SHAP is employed to extract key bands from the preprocessed hyperspectral data, resulting in a subset of core feature bands, specifically including:
[0020] The competitive adaptive reweighted sampling method CARS is used to perform global coarse screening and dimensionality reduction in high-dimensional spectral space. The initial feature subset is obtained by interactive verification through Monte Carlo random sampling and partial least squares regression model to eliminate redundant bands with low regression coefficient weights.
[0021] The initial screening feature subset is used as input to the Boruta algorithm, and shadow features are randomly generated based on the original wavelength features.
[0022] The importance scores of the original wavelength features and the highest scores of the shadow features were statistically tested using random forest to remove spurious correlation variables and extract the core band features that were significantly correlated.
[0023] The marginal contribution of core band features to soluble solids content, pH value and pulp firmness was calculated using the game theory additive feature attribution (SHAP) method. The global importance of core band features was ranked according to the marginal contribution, marginal features were removed, and finally the subset of core feature bands was determined.
[0024] Furthermore, the construction of the TF-1DCNN prediction model specifically includes:
[0025] A spectral channel consisting of three cascaded one-dimensional convolutional layers is constructed. Input data is read through a one-dimensional convolutional kernel, and the dot product between the convolutional kernel and a local region of the input data is calculated to achieve convolutional output.
[0026] A pooling layer is connected after each one-dimensional convolutional layer to extract deep features, and the deep features are transformed into a one-dimensional spectral feature vector.
[0027] A temperature channel consisting of two fully connected layers is constructed, and each element in the feature map during the convolution operation is connected to each neuron of itself through a weight matrix;
[0028] External ambient temperature data is input into the temperature channel, and the nonlinear interference characteristics of ambient temperature on quality changes are captured by mapping through a fully connected layer, and the interference compensation feature vector is output.
[0029] A fusion layer and a multi-task output layer are constructed. The one-dimensional spectral feature vector and the interference compensation feature vector are losslessly concatenated by the matrix concatenation operator to obtain the multi-source fusion feature matrix.
[0030] A device for joint prediction of postharvest internal quality of table grapes, comprising:
[0031] The data processing module is used to collect raw hyperspectral data of fresh grapes, record the external ambient temperature corresponding to the raw hyperspectral data, and perform preliminary preprocessing on the raw hyperspectral data to obtain preprocessed hyperspectral data.
[0032] The band extraction module is used to extract key bands from the preprocessed hyperspectral data using a progressive feature selection strategy based on CB-SHAP, and obtain a subset of core feature bands.
[0033] The model optimization module is used to build the TF-1DCNN prediction model. It uses the adaptive inertial weighted particle swarm algorithm to adaptively optimize the core hyperparameters of the model globally, and obtains the optimized TF-1DCNN prediction model.
[0034] The joint prediction module is used to input the core feature band subset and the corresponding external environmental temperature into the optimized TF-1DCNN prediction model, and output joint prediction data of soluble solids content, pH value and pulp firmness of fresh grapes.
[0035] Furthermore, the preliminary preprocessing of the raw hyperspectral data in the data processing module specifically includes:
[0036] The Savitzky-Golay second-order derivative filtering method was used to denoise and eliminate baseline drift in the original hyperspectral data.
[0037] Furthermore, the band extraction module employs a CB-SHAP-based progressive feature selection strategy to extract key bands from the preprocessed hyperspectral data, resulting in a core feature band subset that specifically includes:
[0038] The competitive adaptive reweighted sampling method CARS is used to perform global coarse screening and dimensionality reduction in high-dimensional spectral space. The initial feature subset is obtained by interactive verification through Monte Carlo random sampling and partial least squares regression model to eliminate redundant bands with low regression coefficient weights.
[0039] The initial screening feature subset is used as input to the Boruta algorithm, and shadow features are randomly generated based on the original wavelength features.
[0040] The importance scores of the original wavelength features and the highest scores of the shadow features were statistically tested using random forest to remove spurious correlation variables and extract the core band features that were significantly correlated.
[0041] The marginal contribution of core band features to soluble solids content, pH value and pulp firmness was calculated using the game theory additive feature attribution (SHAP) method. The global importance of core band features was ranked according to the marginal contribution, marginal features were removed, and finally the subset of core feature bands was determined.
[0042] Furthermore, the model optimization module specifically includes the following steps for building the TF-1DCNN prediction model:
[0043] A spectral channel consisting of three cascaded one-dimensional convolutional layers is constructed. Input data is read through a one-dimensional convolutional kernel, and the dot product between the convolutional kernel and a local region of the input data is calculated to achieve convolutional output.
[0044] A pooling layer is connected after each one-dimensional convolutional layer to extract deep features, and the deep features are transformed into a one-dimensional spectral feature vector.
[0045] A temperature channel consisting of two fully connected layers is constructed, and each element in the feature map during the convolution operation is connected to each neuron of itself through a weight matrix;
[0046] External ambient temperature data is input into the temperature channel, and the nonlinear interference characteristics of ambient temperature on quality changes are captured by mapping through a fully connected layer, and the interference compensation feature vector is output.
[0047] A fusion layer and a multi-task output layer are constructed. The one-dimensional spectral feature vector and the interference compensation feature vector are losslessly concatenated by the matrix concatenation operator to obtain the multi-source fusion feature matrix.
[0048] An electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the various steps in the method for joint prediction of the postharvest internal quality of fresh grapes.
[0049] A storage medium storing a computer program that, when executed by a processor, implements the various steps of a method for joint prediction of the internal quality of fresh grapes after harvest.
[0050] The beneficial effects of this invention are as follows:
[0051] 1. This invention employs a three-stage progressive feature selection strategy using CB-SHAP, utilizing CARS and Boruta to eliminate high-dimensional redundant and pseudo-correlated variables, and introducing game theory SHAP to quantify the nonlinear marginal contribution of each band to multiple indicators. This not only significantly reduces the data dimensionality but also endows the final core feature bands with clear physicochemical significance.
[0052] 2. The spectral-temperature dual-channel architecture proposed in this invention captures the dynamic changes of ambient temperature through a fully connected temperature channel. It achieves deep, lossless splicing of interference compensation signals and spectral quality features in the feature fusion layer, effectively solving the model failure problem caused by spectral nonlinear baseline drift in complex temperature control / cold chain scenarios, and significantly enhancing the generalization robustness across scenarios.
[0053] 3. This invention, based on a 1DCNN multi-task learning framework, deeply characterizes the physiological synergistic relationship between SSC (Self-Containment Strain), pH value, and pulp firmness in grapes during post-harvest storage through underlying network parameter sharing. Compared to traditional single-task independent modeling, it significantly reduces computational resource consumption and multi-model maintenance costs, and prevents negative transfer phenomena.
[0054] 4. This invention introduces the Adaptive Inertial Weighted Particle Swarm Optimization (SAPSO) algorithm, which perfectly balances the global exploration and local development capabilities of the algorithm through a segmented dynamic adjustment mechanism. This avoids the high cost of traditional manual trial and error parameter tuning and realizes the optimal automated optimization of complex deep network architectures. Attached Figure Description
[0055] Figure 1 A schematic diagram of the overall architecture of the joint prediction system for the internal quality of fresh grapes after harvest;
[0056] Figure 2 This is a flowchart of the method for joint prediction of postharvest internal quality of fresh grapes according to the present invention.
[0057] Figure 3 This is a network structure diagram of a spectral-temperature dual-channel 1DCNN (TF-1DCNN) multi-task learning prediction model;
[0058] Figure 4 The image shows the prediction results of the TF-1DCNN model;
[0059] Figure 5 A schematic diagram of a combined prediction device for the internal quality of fresh grapes after harvest.
[0060] Figure 6 This is a schematic diagram of the structure of the electronic device of the present invention. Detailed Implementation
[0061] This invention proposes a method, apparatus, electronic device, and storage medium for joint prediction of the postharvest internal quality of fresh grapes. The invention will be further described below with reference to the accompanying drawings and specific embodiments.
[0062] Figure 1 This is a schematic diagram of the overall architecture of the post-harvest internal quality joint prediction system for table grapes. The system architecture in this embodiment, from left to right, includes: a data acquisition and preprocessing unit, a progressive feature extraction unit, and an adaptive dual-channel multi-task prediction unit. Specifically:
[0063] The left side shows the data acquisition and preprocessing unit. This module receives two types of input information: hyperspectral image data and ambient temperature data. The raw hyperspectral data is highly susceptible to noise contamination from non-chemical factors during acquisition. In this embodiment, the Savitzky-Golay second-derivative filtering method is used to denoise and eliminate baseline drift in the raw hyperspectral image data, extracting preprocessed spectral data with a high signal-to-noise ratio. Simultaneously, the ambient temperature data during hyperspectral acquisition is recorded by a temperature sensor or cold storage temperature control terminal as the input source for subsequent interference compensation.
[0064] The central region is a progressive feature extraction unit. Even after denoising, the hyperspectral data still exhibits extremely high dimensionality and severe overlap and collinearity issues. This module employs a cascaded feature evolution selection strategy based on CB-SHAP for multi-level refined screening. First, a global coarse screening and dimensionality reduction method (CARS) is used to eliminate redundant bands with low regression coefficient weights in the PLS model through multiple Monte Carlo random sampling. Then, the initially screened feature subset is input into the Boruta algorithm module, where shadow features are constructed and subjected to rigorous statistical testing using random forests to thoroughly eliminate spurious correlation variables in the high-dimensional data stream. Finally, the game-theoretic additive feature attribution (SHAP) method is introduced to quantify the nonlinear marginal contribution of the remaining core band features to rank and further simplify the data, ultimately determining a subset of core feature bands that possess both clear physicochemical mechanisms and high predictive potential.
[0065] The right side shows the adaptive dual-channel multi-task prediction unit. This module constructs a multi-task joint learning prediction architecture, containing two parallel input and feature extraction channels. The first is the spectral channel, which contains three cascaded one-dimensional convolutional modules (each module consists of a one-dimensional convolutional layer, a batch normalization layer, a ReLU activation function layer, and a max pooling layer cascaded together), used to slide along the one-dimensional spectral vector to extract local continuity and deep quality features. The second is the temperature channel, which consists of two cascaded fully connected layers, specifically used to capture the dynamic interference of external environmental temperature fluctuations on quality changes and spectral signals. The feature vectors extracted from the two channels are losslessly concatenated in the fusion layer using a matrix concatenation operator, fused into a high-dimensional matrix containing multi-source information, and input into the top-level multi-task fully connected output network. Through the underlying network parameter sharing mechanism, the soluble solids content (SSC), pH value, and flesh firmness of fresh grapes are predicted and output simultaneously and synchronously. Furthermore, to address the issues of complex hyperparameter space and low efficiency of manual tuning in deep neural networks, this module introduces the Adaptive Inertial Weight Particle Swarm Optimization (SAPSO) algorithm. Using the validation set prediction error as the fitness function, it balances global exploration and local development through a segmented dynamic inertial weight adjustment mechanism. This enables adaptive and automated global optimization of core hyperparameters such as model learning rate, batch size, number of convolutional kernels, convolutional kernel size, and Dropout ratio, thereby constructing the optimal TF-1DCNN prediction model.
[0066] This architecture clearly demonstrates how the present invention, through progressive strategy optimization, utilizes multi-source environmental information and a multi-task learning network to collaboratively enhance three levels: item feature analysis (CB-SHAP progressive screening), environmental interference analysis (spectral-temperature dual-channel compensation), and network optimization analysis (SAPSO automated adaptation). This effectively solves the accuracy and robustness issues of non-destructive testing of grape quality in complex environments.
[0067] Figure 2 This is a flowchart of the method for joint prediction of postharvest internal quality of fresh grapes according to the present invention. This embodiment includes the following steps:
[0068] S1: Collect multi-source data on fresh grapes and perform preliminary preprocessing; the multi-source data includes hyperspectral data and ambient temperature data; the specific steps of step S1 are as follows:
[0069] S11: Collect raw hyperspectral image data of fresh grape samples at different storage temperatures, and simultaneously record the external ambient temperature data during hyperspectral data acquisition;
[0070] S12: The Savitzky-Golay second-order derivative filtering method is used to denoise and eliminate baseline drift in the original hyperspectral image data. The preprocessed hyperspectral data is extracted, and the denoising calculation formula is as follows:
[0071] ;
[0072] In the formula, h is the wavelength sampling interval; w is the product half-window width (number of points on one side of the window); d j These are the Savitzky-Golay second-order derivative filter coefficients; x i+j It is the original spectral intensity value that is extended to the left and right by the i-th center.
[0073] S2: A progressive feature selection strategy based on CB-SHAP is used to extract key bands from the preprocessed hyperspectral data to obtain a subset of core feature bands;
[0074] The specific steps of step S2 are as follows:
[0075] S21: The competitive adaptive reweighted sampling (CARS) method is used to perform global coarse dimensionality reduction in the high-dimensional spectral space. Through multiple Monte Carlo random samplings and interactive verification with the partial least squares regression model, redundant bands with low regression coefficient weights are eliminated, and a preliminary feature subset is selected. The specific steps of step S21 are as follows:
[0076] S211: Perform Monte Carlo model sampling, randomly divide the hyperspectral data according to the proportion, establish a partial least squares regression model, and calculate the absolute value of the regression coefficients for each modeling step. and the weights of the absolute values of the regression coefficients Let m be the number of remaining variables, and its mathematical expression is as follows:
[0077] ;
[0078] S212: The corresponding bands with smaller values are lost through the exponential decay function, at which point the proportion of characteristic bands retained is... for:
[0079] ;
[0080] ;
[0081] ;
[0082] In the formula, For the first The proportion of characteristic bands retained in the next iteration; is the base parameter of the exponentially decaying function; The initial total number of variables; Total number of samples taken for Monte Carlo; These are auxiliary parameters for the exponentially decaying function;
[0083] S213: In multiple Monte Carlo sampling runs, a subset of variables is progressively selected and the corresponding RMSECV value is calculated. This process is based on multiple sampling and variable updates, prioritizing the elimination of variables with smaller regression coefficient weights, and finally using the subset of variables corresponding to the minimum RMSECV value as the initial selected feature subset.
[0084] S22: Input the initial screening feature subset into the Boruta algorithm, generate shadow features by randomly shuffling the original wavelength features, and perform a rigorous statistical test based on random forest on the importance scores of the original wavelength features and the highest scores of the shadow features to remove pseudo-correlated variables and extract the core band features that are significantly correlated.
[0085] S23: The game-theoretic additive feature attribution (SHAP) method is introduced to calculate the marginal contribution of core band features to soluble solids content, pH value, and pulp firmness. Features are then ranked globally based on their marginal contribution, and marginal features with weak contributions are removed, ultimately determining the subset of core feature bands. The specific steps of step S23 are as follows:
[0086] S231: Defining the SHAP Explanation Model Based on Additive Feature Attribution Method:
[0087] ;
[0088] In the formula, To explain the model; To simplify the representation of features; The total number of input features; This is the baseline value of the model when there are no feature inputs. For the first The SHAP value of a feature represents the contribution of that feature to the predicted deviation from the baseline value.
[0089] S232: Calculate the mean marginal contribution of each feature under all possible feature subset combinations, and sort the features in descending order according to the size of the absolute value. Select the features that meet the preset cumulative contribution threshold to form the core feature band subset.
[0090] S3: Construct a spectral-temperature dual-channel one-dimensional convolutional neural network multi-task learning model (TF-1DCNN prediction model), and introduce an adaptive inertial weight particle swarm algorithm to adaptively optimize the core hyperparameters of the model globally, thus obtaining the optimized TF-1DCNN prediction model;
[0091] Figure 3 This is a network structure diagram of the spectral-temperature dual-channel 1DCNN (TF-1DCNN) multi-task learning prediction model. Step S3 specifically involves the following steps:
[0092] S31: Construct a spectral channel, which contains three cascaded one-dimensional convolutional modules. Input data is read through one-dimensional convolutional kernels, and the dot product between the kernel and a local region of the input data is calculated to achieve convolutional output. The convolution operation formula for its (k+1)th layer is:
[0093] ;
[0094] In the formula, , The first Layer and first Feature map of the layer; For the first The first layer The weights of each convolutional kernel; For convolution kernel operators; For the corresponding bias term;
[0095] S32: Each one-dimensional convolutional layer is followed by a pooling layer to reduce the spatial size of the feature map, thereby reducing the number of computational parameters. The pooling process selects the maximum value from a specified region of the feature map as the output at the corresponding location. The pooling operation formula is:
[0096] ;
[0097] In the formula, This represents the OR convolution result of the output of the k-th convolutional layer; Indicates the first Feature maps output by each pooling layer; This represents the scale of the corresponding pooling element in the previous layer; The downsampling function transforms the deep features extracted from the spectral channels by the pooling layer into a one-dimensional spectral feature vector.
[0098] S33: Construct a temperature channel, which consists of two fully connected layers. Each fully connected layer connects each element in the feature map to each of its own neurons using a weight matrix, achieving a mapping from the feature space to the sample label space. The calculation formula for the fully connected layer is:
[0099] ;
[0100] In the formula, , The first Layers and The layer's output vector; For the first Weight matrix between layers; The corresponding bias term is used; the ambient temperature data is input into the temperature channel, and the nonlinear interference characteristics of the ambient temperature on the quality change are captured by the fully connected layer mapping, and the interference compensation feature vector is output.
[0101] S34: Construct a fusion layer and a multi-task output layer. Use a matrix concatenation operator to perform lossless feature concatenation of the one-dimensional spectral feature vector and the interference compensation feature vector to obtain a multi-source fusion feature matrix.
[0102] In step S3, the specific steps of introducing the adaptive inertia weighted particle swarm optimization algorithm for adaptive global optimization are as follows:
[0103] S341: Set the particle swarm size to The search space dimension is The overall prediction error of the model on the validation set is used as the fitness evaluation function for particles. ;
[0104] S342: A segmented dynamic inertia weight adjustment mechanism is used to update the inertia weight of each particle. :
[0105] Based on the relationship between particle fitness and the average level of the population, a segmented inertial weight adjustment strategy is adopted.
[0106] ;
[0107] In the formula, when the particle fitness is better than or equal to the average level... Weight exist The fitness value decreases linearly within the interval, and the closer the fitness value is to the optimal value, the better. The smaller the weight, the better the local development; when the particle fitness is worse than average... The weight w takes the maximum value. Maintain overall exploration capabilities.
[0108] S343: Dynamically adjust the velocity and position of particles based on the updated inertia weights until the maximum number of iterations is reached, output the optimal combination of hyperparameters, including the optimal learning rate, optimal batch size, optimal number of convolutional kernels, and optimal dropout ratio, and construct the TF-1DCNN prediction model accordingly.
[0109] S4: Input the core feature band subset and the corresponding ambient temperature data into the TF-1DCNN prediction model, and simultaneously output the joint prediction data of multiple physicochemical indicators such as the soluble solids content, pH value and flesh firmness of fresh grapes.
[0110] Step S4 is as follows:
[0111] S41: Input the core feature band subset into the spectral channel of the TF-1DCNN prediction model to perform cascaded one-dimensional convolution and pooling operations, extract the corresponding quality common feature vector, and at the same time input the collected external environmental temperature data into the corresponding temperature channel to perform nonlinear mapping of the fully connected layer, and output the corresponding temperature interference compensation feature vector.
[0112] S42: In the fusion layer, the matrix splicing operator is used to splice the quality common feature vector and the temperature interference compensation feature vector in parallel to generate a multi-source fusion feature matrix.
[0113] S43: Input the multi-source fusion feature matrix into the output layer of the multi-task fully connected network with shared parameters at the top level. Through the multi-task shared learning mechanism at the bottom layer of the network, the joint prediction data corresponding to soluble solids content, pH value and pulp firmness are output simultaneously and quantitatively.
[0114] To verify the accuracy and stability of the TF-1DCNN model constructed in this invention in actual prediction, this embodiment takes soluble solids content (SSC) as an example and uses an independent test set to evaluate the generalization performance of the optimized model. The prediction results are as follows: Figure 4 As shown. By Figure 4 The results show that the model's root mean square error (RMSE) on the test set is 0.11, mean absolute error (MAE) is 0.09, coefficient of determination (R²) reaches 0.96, explained variance (Exp Var) is also 0.96, and mean absolute percentage error (MAPE) is only 3%. These indicators collectively demonstrate that the joint prediction method proposed in this invention has extremely high prediction accuracy and good generalization ability in the quantitative inversion of core quality indicators, verifying the effectiveness and synergistic gain effect of the CB-SHAP progressive feature selection, spectral-temperature dual-channel fusion, and SAPSO hyperparameter global optimization strategy.
[0115] Figure 5 This is a schematic diagram of a combined post-harvest internal quality prediction device for table grapes. It includes:
[0116] The data processing module is used to collect raw hyperspectral data of fresh grapes, record the external ambient temperature corresponding to the raw hyperspectral data, and perform preliminary preprocessing on the raw hyperspectral data to obtain preprocessed hyperspectral data.
[0117] The band extraction module is used to extract key bands from the preprocessed hyperspectral data using a progressive feature selection strategy based on CB-SHAP, and obtain a subset of core feature bands.
[0118] The model optimization module is used to build the TF-1DCNN prediction model. It uses the adaptive inertial weighted particle swarm algorithm to adaptively optimize the core hyperparameters of the model globally, and obtains the optimized TF-1DCNN prediction model.
[0119] The joint prediction module is used to input the core feature band subset and the corresponding external environmental temperature into the optimized TF-1DCNN prediction model, and output joint prediction data of soluble solids content, pH value and pulp firmness of fresh grapes.
[0120] In summary, this invention not only significantly reduces data dimensionality but also endows the final core feature bands with clear physicochemical meaning. Furthermore, it effectively solves the model failure problem caused by spectral nonlinear baseline drift in complex temperature control / cold chain scenarios, significantly enhancing cross-scenario generalization robustness. Compared to traditional single-task independent modeling, it greatly reduces computational resource consumption and multi-model maintenance costs, prevents negative transfer phenomena, and avoids the high cost of traditional manual trial-and-error parameter tuning, achieving automated optimization of complex deep network architectures.
[0121] This embodiment also includes an electronic device and a storage medium. Figure 6 This is a schematic diagram of the electronic device of the present invention. An electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements various steps in the method for joint prediction of the postharvest internal quality of fresh grapes. A storage medium stores a computer program thereon. When the computer program is executed by a processor, it implements various steps in the method for joint prediction of the postharvest internal quality of fresh grapes.
[0122] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. The solutions in the embodiments of this application can be implemented in various computer languages, such as the object-oriented programming language Java and the interpreted scripting language JavaScript.
[0123] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0124] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0125] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0126] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.
[0127] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A method for joint prediction of the postharvest internal quality of table grapes, characterized in that, include: Raw hyperspectral data of fresh grapes were collected, and the corresponding ambient temperature was recorded. The raw hyperspectral data were preprocessed to obtain preprocessed hyperspectral data. A progressive feature selection strategy based on CB-SHAP was adopted to extract key bands from the preprocessed hyperspectral data, resulting in a subset of core feature bands. A TF-1DCNN prediction model was constructed, and the core hyperparameters of the model were adaptively optimized globally using the adaptive inertial weighted particle swarm algorithm to obtain the optimized TF-1DCNN prediction model. The core feature band subset and the corresponding external ambient temperature are input into the optimized TF-1DCNN prediction model, which outputs joint prediction data of soluble solids content, pH value and pulp firmness of fresh grapes.
2. The method for joint prediction of postharvest internal quality of fresh grapes according to claim 1, characterized in that, The preliminary preprocessing of the raw hyperspectral data is as follows: The Savitzky-Golay second-order derivative filtering method was used to denoise and eliminate baseline drift in the original hyperspectral data.
3. The method for joint prediction of postharvest internal quality of fresh grapes according to claim 1 or 2, characterized in that, A progressive feature selection strategy based on CB-SHAP was used to extract key bands from the preprocessed hyperspectral data, resulting in a subset of core feature bands, which specifically includes: The competitive adaptive reweighted sampling method CARS is used to perform global coarse screening and dimensionality reduction in high-dimensional spectral space. The initial feature subset is obtained by interactive verification through Monte Carlo random sampling and partial least squares regression model to eliminate redundant bands with low regression coefficient weights. The initial screening feature subset is used as input to the Boruta algorithm, and shadow features are randomly generated based on the original wavelength features. The importance scores of the original wavelength features and the highest scores of the shadow features were statistically tested using random forest to remove spurious correlation variables and extract the core band features that were significantly correlated. The marginal contribution of core band features to soluble solids content, pH value and pulp firmness was calculated using the game theory additive feature attribution (SHAP) method. The global importance of core band features was ranked according to the marginal contribution, marginal features were removed, and finally the subset of core feature bands was determined.
4. The method for joint prediction of postharvest internal quality of fresh grapes according to claim 3, characterized in that, The construction of the TF-1DCNN prediction model specifically includes: A spectral channel consisting of three cascaded one-dimensional convolutional layers is constructed. Input data is read through a one-dimensional convolutional kernel, and the dot product between the convolutional kernel and a local region of the input data is calculated to achieve convolutional output. A pooling layer is connected after each one-dimensional convolutional layer to extract deep features, and the deep features are transformed into a one-dimensional spectral feature vector. A temperature channel consisting of two fully connected layers is constructed, and each element in the feature map during the convolution operation is connected to each neuron of itself through a weight matrix; External ambient temperature data is input into the temperature channel, and the nonlinear interference characteristics of ambient temperature on quality changes are captured by mapping through a fully connected layer, and the interference compensation feature vector is output. A fusion layer and a multi-task output layer are constructed. The one-dimensional spectral feature vector and the interference compensation feature vector are losslessly concatenated by the matrix concatenation operator to obtain the multi-source fusion feature matrix.
5. A device for joint prediction of the internal quality of fresh grapes after harvest, characterized in that, include: The data processing module is used to collect raw hyperspectral data of fresh grapes, record the external ambient temperature corresponding to the raw hyperspectral data, and perform preliminary preprocessing on the raw hyperspectral data to obtain preprocessed hyperspectral data. The band extraction module is used to extract key bands from the preprocessed hyperspectral data using a progressive feature selection strategy based on CB-SHAP, and obtain a subset of core feature bands. The model optimization module is used to build the TF-1DCNN prediction model. It uses the adaptive inertial weighted particle swarm algorithm to adaptively optimize the core hyperparameters of the model globally, and obtains the optimized TF-1DCNN prediction model. The joint prediction module is used to input the core feature band subset and the corresponding external environmental temperature into the optimized TF-1DCNN prediction model, and output joint prediction data of soluble solids content, pH value and pulp firmness of fresh grapes.
6. The postharvest internal quality prediction device for fresh grapes according to claim 5, characterized in that, The preliminary preprocessing of the raw hyperspectral data in the data processing module specifically includes: The Savitzky-Golay second-order derivative filtering method was used to denoise and eliminate baseline drift in the original hyperspectral data.
7. The postharvest internal quality prediction device for fresh grapes according to claim 5 or 6, characterized in that, The band extraction module employs a CB-SHAP-based progressive feature selection strategy to extract key bands from the preprocessed hyperspectral data, resulting in a core feature band subset that specifically includes: The competitive adaptive reweighted sampling method CARS is used to perform global coarse screening and dimensionality reduction in high-dimensional spectral space. The initial feature subset is obtained by interactive verification through Monte Carlo random sampling and partial least squares regression model to eliminate redundant bands with low regression coefficient weights. The initial screening feature subset is used as input to the Boruta algorithm, and shadow features are randomly generated based on the original wavelength features. The importance scores of the original wavelength features and the highest scores of the shadow features were statistically tested using random forest to remove spurious correlation variables and extract the core band features that were significantly correlated. The marginal contribution of core band features to soluble solids content, pH value and pulp firmness was calculated using the game theory additive feature attribution (SHAP) method. The global importance of core band features was ranked according to the marginal contribution, marginal features were removed, and finally the subset of core feature bands was determined.
8. The postharvest internal quality prediction device for fresh grapes according to claim 7, characterized in that, The model optimization module specifically includes the following steps for constructing the TF-1DCNN prediction model: A spectral channel consisting of three cascaded one-dimensional convolutional layers is constructed. Input data is read through a one-dimensional convolutional kernel, and the dot product between the convolutional kernel and a local region of the input data is calculated to achieve convolutional output. A pooling layer is connected after each one-dimensional convolutional layer to extract deep features, and the deep features are transformed into a one-dimensional spectral feature vector. A temperature channel consisting of two fully connected layers is constructed, and each element in the feature map during the convolution operation is connected to each neuron of itself through a weight matrix; External ambient temperature data is input into the temperature channel, and the nonlinear interference characteristics of ambient temperature on quality changes are captured by mapping through a fully connected layer, and the interference compensation feature vector is output. A fusion layer and a multi-task output layer are constructed. The one-dimensional spectral feature vector and the interference compensation feature vector are losslessly concatenated by the matrix concatenation operator to obtain the multi-source fusion feature matrix.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements each step of the method for joint prediction of postharvest internal quality of fresh grapes as described in any one of claims 1 to 4.
10. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements each step of the method for joint prediction of postharvest internal quality of fresh grapes as described in any one of claims 1 to 4.
