Transfer learning method, system and application of fruit internal quality detection model

By employing multispectral imaging technology and interpretable transfer learning methods, key characteristic bands for fruit internal quality detection are identified, and a high-precision, interpretable transfer learning model is constructed. This solves the problems of low efficiency and poor robustness in fruit internal quality detection, achieving efficient and accurate non-destructive testing.

CN121599044BActive Publication Date: 2026-05-08HEFEI UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HEFEI UNIV
Filing Date
2026-01-27
Publication Date
2026-05-08

AI Technical Summary

Technical Problem

Existing methods for detecting the internal quality of fruits are inefficient, computationally burdensome, and have poor model robustness. Furthermore, they are difficult to achieve cross-task knowledge transfer and fully utilize the potential correlations between quality indicators, resulting in insufficient detection efficiency and accuracy.

Method used

By combining multispectral imaging technology with interpretable transfer learning, a high-precision and interpretable detection model is constructed by training a network architecture across the entire spectrum and key spectrum bands, identifying key feature bands, and using transfer learning technology to transfer knowledge between different quality indicators.

Benefits of technology

It significantly improves the accuracy and stability of fruit internal quality detection, solves the problem of model training difficulties under small sample conditions, enhances the model's generalization ability, and achieves high efficiency and accuracy in non-destructive testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121599044B_ABST
    Figure CN121599044B_ABST
Patent Text Reader

Abstract

The application provides a transfer learning method, system and application of a fruit internal quality detection model. The transfer learning method comprises the following steps: providing a training set; training a plurality of original network architectures and selecting an optimal network architecture; selecting a key feature wave band subset; retraining the optimal network architecture in the key feature wave band; performing full wave band transfer learning and key wave band transfer learning from a source quality indicator to a target quality indicator; and selecting one as a quality detection model of the target quality indicator. The application adopts an explainability analysis method to identify key feature wave bands, and uses a transfer learning technology to realize knowledge transfer and generalization between different quality indicators, thereby significantly improving the accuracy and stability of the model in a cross-quality prediction task. The method effectively solves the problem of model training difficulty under a small sample condition through transfer learning, enhances the generalization ability of the model, and provides a new technical approach for nondestructive detection of fruit internal quality.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the interdisciplinary field of non-destructive testing of agricultural products and artificial intelligence, specifically involving a transfer learning method, system and application of a fruit internal quality testing model. Background Technology

[0002] Traditional methods for testing the internal quality of fruits mainly rely on destructive physicochemical analysis, which is inefficient and cannot achieve rapid screening of batches of products. In recent years, spectral imaging technology has been widely used as an effective non-destructive testing method, capable of simultaneously acquiring spectral information and spatial images of samples.

[0003] However, in practical applications, this technology still faces significant challenges: First, the high dimensionality and redundancy of full-band spectral data make direct modeling computationally expensive and result in poor model robustness. Second, while deep learning models offer high prediction accuracy, their decision-making process is like a "black box," lacking interpretability and making it difficult to gain user trust and a deep understanding of the quality formation mechanism. Third, models built for specific varieties or growth environments generally lack generalization ability, exhibiting significant performance degradation when applied to new categories or different batches of products. Relabeling large amounts of training data and the high cost of modeling necessitate the development of a modeling method that can adapt to a small amount of labeled data. Finally, the approach of building models independently for different quality indicators fails to fully utilize the potential correlations between different quality indicators, limiting further improvements in detection efficiency.

[0004] Therefore, developing a nondestructive testing method that combines high precision, strong interpretability, excellent generalization ability, and the ability to transfer knowledge across tasks has become an urgent technical need in this field. Summary of the Invention

[0005] The main objective of this invention is to provide a transfer learning method, system, and application for a fruit internal quality detection model, in order to overcome the shortcomings of the prior art.

[0006] To achieve the above-mentioned objectives, the present invention adopts the following technical solution:

[0007] In a first aspect, the present invention provides a transfer learning method based on a multispectral and interpretable fruit internal quality detection model, wherein the fruit includes any one of blueberries, strawberries, and bananas, and the transfer learning method includes:

[0008] A training set is provided, which includes multispectral image data of fruits and various physicochemical analysis label data on multiple quality indicators of the fruits' interior.

[0009] Regarding source quality indicators

[0010] Based on the full-band multispectral image data, multiple original network architectures are trained, and the optimal network architecture is selected from the training results to obtain the full-band initial prediction model.

[0011] The training process of the optimal network architecture is analyzed based on the interpretability analysis method, and the bands that contribute highly to the prediction results are selected as the subset of key feature bands.

[0012] In the subset of key feature bands, the optimal network architecture is retrained to obtain the initial prediction model for the key bands;

[0013] For the target quality indicators

[0014] The network parameters of the initial full-band prediction model are transferred to the prediction task of the target quality index. By fine-tuning the network parameters, a full-band transfer learning model is constructed.

[0015] The network parameters of the initial prediction model for the key bands are transferred to the prediction task of the target quality index. By fine-tuning the network parameters, a transfer learning model for the key bands is constructed.

[0016] The performance of the full-band transfer learning model and the key-band transfer learning model is verified based on the physicochemical analysis label data, and the better one is selected as the quality detection model for the target quality index.

[0017] Secondly, the present invention also provides a full-spectrum detection method for the internal quality of fruit, as an application of the above-mentioned transfer learning method, which includes:

[0018] Provide multispectral image data of the target fruit and a quality detection model trained using the above transfer learning method;

[0019] The multispectral image data is input into the quality detection model to obtain predicted values ​​of the quality indicators of the target fruit.

[0020] Thirdly, corresponding to the above-mentioned transfer learning method, the present invention also provides a transfer learning system based on a multispectral and interpretable fruit internal quality detection model, wherein the fruit includes any one of blueberries, strawberries, and bananas, and the transfer learning system includes:

[0021] The raw data module provides a training set, which includes multispectral image data of fruits and various physicochemical analysis label data on multiple quality indicators of the fruits.

[0022] The full-band pre-training module is used to train multiple original network architectures based on the full-band multispectral image data for source quality indicators, and select the optimal network architecture from the training results to obtain the full-band initial prediction model.

[0023] The feature band selection module analyzes the training process of the optimal network architecture based on the interpretability analysis method, and selects some bands that contribute highly to the prediction results as a subset of key feature bands.

[0024] The key band pre-training module is used to retrain the optimal network architecture in the key feature band subset for the source quality index, so as to obtain the initial prediction model of the key band.

[0025] The full-band transfer module is used to transfer the network parameters of the initial full-band prediction model to the prediction task of the target quality index. By fine-tuning the network parameters, a full-band transfer learning model is constructed.

[0026] The key band transfer module is used to transfer the network parameters of the initial prediction model of the key band to the prediction task of the target quality index. By fine-tuning the network parameters, a key band transfer learning model is constructed.

[0027] The model selection module is used to verify the performance of the full-band transfer learning model and the key-band transfer learning model based on the physicochemical analysis label data, and select the better one as the quality detection model for the target quality index.

[0028] Compared with the prior art, the beneficial effects of the present invention include at least the following:

[0029] This invention acquires multispectral image data of fruit samples through a multispectral imaging system, identifies key feature bands using interpretability analysis, and utilizes transfer learning technology to achieve knowledge transfer and generalization across different quality indicators, significantly improving the accuracy and stability of the model in cross-quality prediction tasks. This method effectively solves the problem of difficult model training under small sample conditions through transfer learning, enhances the model's generalization ability, and provides a new technical approach for non-destructive testing of fruit internal quality.

[0030] The above description is merely an overview of the technical solution of the present invention. In order to enable those skilled in the art to better understand the technical means of this application and to implement it in accordance with the contents of the specification, the preferred embodiments of the present invention are described below in conjunction with detailed drawings. Attached Figure Description

[0031] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0032] Figure 1 A flowchart illustrating the steps of a blueberry internal quality detection method based on multispectral and interpretable transfer learning, provided as a typical embodiment of the present invention.

[0033] Figure 2a A visualization of the original multispectral data of the blueberry quality index SCC provided as a typical embodiment of the present invention;

[0034] Figure 2b A visualization of the raw multispectral data of the blueberry quality index TA provided as a typical embodiment of the present invention;

[0035] Figure 3a A spectral visualization of blueberry quality index SCC after MA preprocessing, provided as a typical embodiment of the present invention;

[0036] Figure 3b A spectral visualization of blueberry quality index SCC after MSC preprocessing, provided as a typical embodiment of the present invention;

[0037] Figure 3c A spectral visualization of blueberry quality index SCC after MA-MSC preprocessing, provided as a typical embodiment of the present invention;

[0038] Figure 3d A spectral visualization of blueberry quality index TA after MA preprocessing, provided as a typical embodiment of the present invention;

[0039] Figure 3e A spectral visualization of blueberry quality index TA after MSC preprocessing, provided as a typical embodiment of the present invention;

[0040] Figure 3f A spectral visualization of blueberry quality index TA after MA-MSC preprocessing, provided as a typical embodiment of the present invention;

[0041] Figure 4 The network structure diagram of Residual Multilayer Perceptrons ResMLP1, ResMLP2, and ResMLP3 (from left to right) in the transfer learning method provided for a typical implementation of the present invention;

[0042] Figure 5a The DeepExplainer interpreter in the transfer learning method provided in a typical implementation case of the present invention analyzes the optimal model ResMLP2 and obtains the SHAP bee colony diagram of the blueberry quality index SCC.

[0043] Figure 5bA bar chart of blueberry quality index SCC obtained by the DeepExplainer interpreter in the transfer learning method provided in a typical implementation case of the present invention, which analyzes the optimal model ResMLP2.

[0044] Figure 5c The DeepExplainer interpreter in the transfer learning method provided in a typical implementation case of the present invention analyzes the SHAP bee colony graph of the blueberry quality index TA obtained by the optimal model ResMLP2.

[0045] Figure 5d A bar chart of blueberry quality index TA obtained by the DeepExplainer interpreter in the transfer learning method provided in a typical implementation case of the present invention, which analyzes the optimal model ResMLP2.

[0046] Figure 6 The TL-ResMLP2 network structure diagram in the transfer learning method provided in a typical embodiment of the present invention;

[0047] Figure 7a A visualization of the original multispectral data of the strawberry quality index SCC provided as another typical embodiment of the present invention;

[0048] Figure 7b A visualization of the raw multispectral data of the strawberry quality index TA provided as another typical embodiment of the present invention;

[0049] Figure 8a A spectral visualization of the strawberry quality index SCC after MA preprocessing, provided as another typical embodiment of the present invention;

[0050] Figure 8b A spectral visualization of the strawberry quality index SCC after MSC preprocessing, provided as another typical embodiment of the present invention;

[0051] Figure 8c A spectral visualization of the strawberry quality index SCC after MA-MSC preprocessing, provided as another typical embodiment of the present invention;

[0052] Figure 8d A spectral visualization of strawberry quality index TA after MA preprocessing, provided as another typical embodiment of the present invention;

[0053] Figure 8e A spectral visualization of strawberry quality index TA after MSC preprocessing, provided as another typical embodiment of the present invention;

[0054] Figure 8f A spectral visualization of the strawberry quality index TA after MA-MSC preprocessing, provided as another typical embodiment of the present invention;

[0055] Figure 9a The DeepExplainer interpreter in the transfer learning method provided in another typical embodiment of the present invention analyzes the SHAP bee colony graph of the strawberry quality index SCC obtained by the optimal model ResMLP2;

[0056] Figure 9b The bar chart of the strawberry quality index SCC obtained by the DeepExplainer interpreter in the transfer learning method provided in another typical embodiment of the present invention, which analyzes the optimal model ResMLP2;

[0057] Figure 9c The DeepExplainer interpreter in the transfer learning method provided in another typical embodiment of the present invention analyzes the SHAP bee colony graph of the strawberry quality index TA obtained by the optimal model ResMLP2;

[0058] Figure 9d The bar chart of strawberry quality index TA obtained by the DeepExplainer interpreter in the transfer learning method provided in another typical embodiment of the present invention, which analyzes the optimal model ResMLP2;

[0059] Figure 10a A visualization of the original multispectral data of banana quality index SCC provided as another typical embodiment of the present invention;

[0060] Figure 10b A visualization of the original multispectral data of the banana quality index TA, provided as another typical embodiment of the present invention;

[0061] Figure 11a A spectral visualization of banana quality index SCC after MA preprocessing, which is another typical embodiment of the present invention;

[0062] Figure 11b A spectral visualization of banana quality index SCC after MSC preprocessing, which is another typical embodiment of the present invention;

[0063] Figure 11c A spectral visualization of banana quality index SCC after MA-MSC preprocessing, which is another typical embodiment of the present invention;

[0064] Figure 11d A spectral visualization of banana quality index TA after MA preprocessing, provided as another typical embodiment of the present invention;

[0065] Figure 11e A spectral visualization of banana quality index TA after MSC preprocessing, provided as another typical embodiment of the present invention;

[0066] Figure 11f A spectral visualization of banana quality index TA after MA-MSC preprocessing, which is another typical embodiment of the present invention;

[0067] Figure 12a The DeepExplainer interpreter in the transfer learning method provided as another typical implementation case of the present invention analyzes the SHAP bee colony graph of banana quality index SCC obtained by the optimal model ResMLP2.

[0068] Figure 12b The bar chart of banana quality index SCC obtained by the DeepExplainer interpreter in the transfer learning method provided in another typical implementation case of the present invention, which analyzes the optimal model ResMLP2;

[0069] Figure 12c The DeepExplainer interpreter in the transfer learning method provided as another typical implementation case of the present invention analyzes the SHAP bee colony graph of banana quality index TA obtained by the optimal model ResMLP2;

[0070] Figure 12d The bar chart showing the banana quality index TA obtained by the DeepExplainer interpreter in the transfer learning method provided in another typical implementation case of the present invention, which analyzes the optimal model ResMLP2. Detailed Implementation

[0071] In view of the shortcomings of the existing technology, and through long-term research and extensive practice, the technical solution of this invention has been proposed. The following will further explain and illustrate the technical solution, its implementation process, and its principles.

[0072] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and therefore the scope of protection of the invention is not limited to the specific embodiments disclosed below.

[0073] The purpose of this invention is to provide an innovative technical means that organically combines multispectral imaging technology with interpretable transfer learning technology to accurately detect and analyze the internal quality of blueberries, thereby overcoming the deficiencies and shortcomings of existing technologies in the non-destructive detection of blueberry internal quality.

[0074] For the purposes described above, see Figure 1 As shown, this embodiment of the invention first provides a transfer learning method for detecting the internal quality of fruits based on a multispectral and interpretable fruit model, wherein the fruit includes any one of blueberries, strawberries, and bananas, and includes the following steps:

[0075] A training set is provided, which includes multispectral image data of fruits and various physicochemical analysis label data on multiple quality indicators of the fruits' interior.

[0076] Regarding source quality indicators

[0077] Based on the multispectral image data of the entire band, multiple original network architectures are trained, and the optimal network architecture is selected from the training results of the multiple original network architectures. The training result of the optimal network architecture is used as the initial prediction model of the entire band.

[0078] The training process of the optimal network architecture is analyzed based on the interpretability analysis method. The bands in the optimal network architecture that contribute highly to the prediction results are selected as a subset of key feature bands. Here, "high contribution" means that the selected bands contribute more to the prediction results than the remaining unselected bands. For example, the bands can be ranked from high to low according to their contribution and the top-ranked ones can be selected as "bands with high contribution". Other equivalent screening methods are also acceptable.

[0079] In the feature bands corresponding to the subset of key feature bands, the optimal network architecture is retrained to obtain the initial prediction model for the key bands.

[0080] For the target quality indicators

[0081] The full-band initial prediction model based on the source quality index is used as a pre-trained model. The network parameters are transferred to the prediction task of the target quality index. By fine-tuning the network parameters, a full-band transfer learning model is constructed.

[0082] Based on the initial prediction model of the key band of the source quality index as a pre-trained model, the network parameters are transferred to the prediction task of the target quality index. By fine-tuning the network parameters, a key band transfer learning model is constructed.

[0083] The performance of the full-band transfer learning model and the key-band transfer learning model is verified based on the physicochemical analysis label data, and the better one is selected as the quality detection model related to the target quality index.

[0084] The above technical solution achieves efficient, accurate, and non-destructive detection of key internal quality parameters of fruits such as blueberries by analyzing the correlation mechanism between spectral features and internal quality, and by using transfer learning to improve the model's generalization ability.

[0085] In some further embodiments, the transfer learning method may also include the following steps:

[0086] The target quality indicator is selected from the plurality of quality indicators, and one of the remaining quality indicators is selected as the source quality indicator.

[0087] The process of pre-training and transfer learning is carried out until all the quality indicators are traversed, thus constructing a comprehensive model for detecting the internal quality of fruits.

[0088] The specific implementation methods provided in the embodiments of the present invention can select one of multiple quality indicators as the target quality indicator and select one of the remaining indicators as the source quality indicator, and perform transfer learning in rotation. For ease of understanding, a typical embodiment uses two quality indicators as the target and the source of each other for demonstration, but the number of quality indicators in actual applications is not limited to two.

[0089] Typically, when the number of quality indicators is greater than two, for each target quality indicator, different source quality indicators from the remaining quality indicators can be selected for transfer learning, thereby establishing one or more transfer learning models for each target indicator. For each target indicator, the model with the best performance can be selected as the final detection model for that target indicator from the results of transfer learning from multiple source indicators. This means that the preferred solution of this invention not only performs network architecture optimization and full-band / key-band optimization, but also performs multi-source quality indicator optimization for a target quality indicator. This triple optimization method is a completely novel training idea for fruit internal quality detection models in the field.

[0090] Taking indicators A, B, and C as examples, the transfer learning methods can include:

[0091] 1. Try each one and choose the best: For the target quality indicator A, quality indicators B and C can be used as source quality indicators for transfer learning. Compare the performance (such as RMSE, RPD, etc.) of the two transfer models "A←B" and "A←C". Select the model with better performance as the final detection model for A.

[0092] 2. Selection based on prior knowledge or relevance: The source quality index with the strongest correlation to the target index can be selected based on literature reports or experimental data. For example, if the physicochemical properties of A and B are more similar, then B should be selected as the source quality index.

[0093] 3. Introducing methods such as Pearson correlation analysis as an auxiliary or decision-making basis for selecting source quality indicators is a reasonable and beneficial supplement. This can enhance the scientificity and interpretability of the method in the source indicator selection stage, especially when facing multiple quality indicators (the specific process may include calculating the Pearson correlation coefficient between each source quality indicator and the current target quality indicator, and taking the one with the largest absolute value of the Pearson correlation coefficient as the selected source quality indicator).

[0094] 4. Selection based on SHAP interpretability: When faced with three or more quality indicators (A, B, C), the selection of the source quality indicator can follow the following criteria, based on the obtained subset of key feature bands from SHAP analysis. Specifically, after obtaining the subsets of key feature bands for A, B, and C (e.g., the top 10 bands with the largest contribution) through SHAP analysis, the quality indicator with the highest overlap between its key band subset and the key band subset of the target quality indicator is selected as the source indicator. The rationale for this implementation is as follows: Logical consistency: This method is entirely based on the already implemented core step—SHAP interpretability analysis—without introducing new external methods, maintaining the purity and cohesion of the technical solution; Physical interpretability: High overlap of the key bands of two quality indicators means that their spectral response patterns are similar, and they are likely driven by the same or related internal chemical components (e.g., sugars, acids, water). This similarity of intrinsic mechanisms provides the most direct and reliable basis for knowledge transfer between models; Operational simplicity: Only the intersection size of the key band sets needs to be calculated to make a quick judgment. Therefore, the method of selecting the best source quality index is superior to the above three methods in both theory and practical application. While ensuring the accurate selection of the most relevant source quality index and guaranteeing the model training performance, it significantly reduces the need for additional computational overhead or manual data query for active selection.

[0095] Regarding the training data acquisition phase, in some implementation schemes, the process of acquiring the multispectral image data specifically includes:

[0096] Raw light intensity data of fruit samples were acquired using a multispectral imaging system;

[0097] The original light intensity data is converted into reflectance data through whiteboard calibration;

[0098] The reflectance data is preprocessed to obtain the multispectral image data. The preprocessing method includes any one or a combination of two of the following: moving average and multiplicative scattering correction. The optimal method is selected from among the various preprocessing methods based on the training performance.

[0099] Regarding the specific network architecture, in some implementation schemes, multiple of the original network architectures belong to the residual multilayer perceptron network architecture.

[0100] In some implementations, the residual multilayer perceptron network architecture includes an input layer, a residual block, and an output layer;

[0101] During transfer learning, only the parameters of the fully connected layers in the output layer are fine-tuned, while the remaining layers are frozen.

[0102] For the screening of key characteristic bands, in some implementations, the SHAP value is used as a measure of the contribution. For any characteristic band, the SHAP value is calculated as follows:

[0103] ;

[0104] in, Indicates in the sample Mid-characteristic band The sample SHAP value is used, and the average of the sample SHAP values ​​of all samples is used as the characteristic band. Contribution was filtered based on the SHAP values ​​of the bands; It is the set of all characteristic bands; Not including characteristic bands A subset of features; Indicates the use of subsets The predicted output of the optimal network architecture at that time; symbol The difference operation represents sets. Indicates from set Remove from The resulting set; For set Any subset of , denoted as ;symbol and Representing sets respectively and The number of elements in the radix (radix), ! represents the factorial operation; symbol Representing a subset With a single set The union of .

[0105] In some implementations, the screening process for the key feature band subset specifically includes:

[0106] With the characteristic band The band SHAP values ​​are sorted from high to low, and a preset number of characteristic bands are selected from the top rankings. As a subset of the key feature bands.

[0107] Of course, the contribution screening method based on interpretability is not limited to SHAP value. Those skilled in the art can replace it with other equivalent contribution screening methods based on the examples of this invention, which are all within the scope of this invention.

[0108] For the performance evaluation of the model, in some implementation schemes, the evaluation index for the optimal network architecture and quality detection model includes any one or a combination of two or more of the following: root mean square error, correlation coefficient, and residual prediction bias.

[0109] The root mean square error is calculated as follows:

[0110] ;

[0111] The correlation coefficient is calculated as follows:

[0112] ;

[0113] The calculation method for the residual prediction bias is expressed as follows:

[0114] ;

[0115] in, This represents the root mean square error; This represents the correlation coefficient; This indicates the residual prediction bias; This refers to the physicochemical analysis label data. This represents the average value of multiple samples of the physicochemical analysis label data; This represents the predicted value from the physicochemical analysis data. This represents the average of multiple samples of predicted values ​​from physicochemical analysis data. Indicates the number of samples; Indicates the sample number; This represents the standard deviation of the physicochemical analysis label data.

[0116] As a typical example, embodiments of the present invention take the detection of the internal quality of blueberries, including two quality indicators: soluble solids (SSC) and titratable acid (TA), as examples. A learning, training, and application method for a blueberry internal quality detection model based on multispectral and interpretable transfer learning is proposed, including the following main steps:

[0117] S1. Obtain multispectral image data of blueberry samples and reference physicochemical values ​​of their internal quality indicators; this step specifically involves acquiring multispectral images of blueberry samples using a multispectral imaging system and converting the raw light intensity data into reflectance data through whiteboard calibration, specifically including: acquiring the reflected light intensity of a reference whiteboard. Collect dark current values , Sample reflected light intensity The reflectance data R is calculated using the following formula:

[0118] ;

[0119] in, The value of the reflected light intensity of the sample. This is the dark current value. For reference, the reflected light intensity value of the whiteboard can be used; for physicochemical values, physicochemical analysis methods can be used to determine the SSC and TA of blueberry samples to establish a standardized reference database.

[0120] S2. Preprocess the acquired blueberry multispectral image data. This step specifically utilizes ViewmeterLab software to process the images and obtain the raw multispectral image data. Processing methods include, but are not limited to, noise removal, correction of spectral distortion and background interference, data compression and dimensionality reduction, smoothing of spectral curves, radiometric and geometric correction, and spectral matching and normalization, selecting the optimal preprocessing scheme. Typical preprocessing methods include moving average (MA), multiplicative scattering correction (MSC), and a combined moving average-multiplicative scattering correction method (MA-MSC). The formula for calculating moving average smoothing is:

[0121] ;

[0122] in Indicates the first Reflectance values ​​of each band after moving average smoothing; Indicates the window size and the number of spectral bands used for smoothing (usually an odd number). This represents the width of half a window, calculated using the following formula: ; Indicates the first spectral data in the original spectral data Reflectance values ​​for each band, The value ranges from arrive , indicating that the first A smooth window centered on each band;

[0123] Moving average smoothing is used to smooth raw spectral data, reducing noise and random fluctuations, and improving data quality. Preprocessing methods include moving average (MA), multiplicative scattering correction (MSC), or a combination thereof (MA-MSC), and the optimal preprocessing method is selected based on model performance in experiments.

[0124] The formula for calculating multiplicative scattering correction is:

[0125] ;

[0126] in This is the reflectance value after multiplicative scattering correction. This is the reflectance value after smoothing by moving average; The offset is obtained by performing linear regression between the sample spectrum and the average spectrum. The scattering coefficient is also obtained through linear regression and is used to correct for scattering effects in the spectrum.

[0127] This formula is used to further correct scattering effects in spectral data and enhance the correlation between the spectrum and internal quality indicators. It is usually one of the key steps in preprocessing.

[0128] Both formulas described above are spectral data preprocessing methods used to obtain raw reflectance data from multispectral imaging systems, which, after preprocessing, yield multispectral image data suitable for modeling. In a preferred embodiment, the choice of preprocessing method (MA, MSC, or MA-MSC) is based on the model's performance on the training set.

[0129] S3. Based on full-band spectral data, construct a full-band initial prediction model for the internal quality of blueberries using a residual multilayer perceptron network. Specifically, this step can be to construct a full-band initial prediction model for the internal quality of fruit using a residual multilayer perceptron network, and select the optimal architecture by comparing the performance of different network architectures.

[0130] S4. Use interpretability analysis to analyze the decision mechanism of the optimal initial prediction model, and identify and select a subset of key feature bands. Specifically, this step can use the SHAP interpretability analysis method to analyze the decision mechanism of the optimal initial prediction model, quantify the contribution of each band feature, and identify and select a subset of key feature bands for predicting each quality index. Specifically, the contribution of each band feature can be calculated using SHAP values, and the top 10 feature wavelengths with the highest contribution (which can be set to other values, depending on the number of bands and actual needs; this invention does not impose any restrictions on this) are selected as the key feature subset.

[0131] S5. Based on the selected subset of key feature bands, retrain the optimal architecture and construct the initial prediction model for each quality index as the baseline prediction model.

[0132] S6. Using the baseline prediction model of a certain quality indicator of blueberries (as the source quality indicator) as a pre-trained model, its network parameters are transferred to the prediction task of other quality indicators. Cross-quality knowledge transfer is achieved by fine-tuning the network parameters, including transfer learning across the entire band and transfer learning in key bands.

[0133] S7. Compare and evaluate the performance of different transfer learning models, verify their generalization ability in cross-quality prediction tasks, and select the best model for predicting the internal quality of blueberries. For multiple quality indicators of some fruits, the performance of full-band transfer learning of some quality indicators may be better, while the performance of key-band transfer learning of other quality indicators may be better. Therefore, for different fruits and different quality indicators, the best model should be selected based on the training results.

[0134] In the above example, the residual blocks in the residual multilayer perceptron network architecture achieve forward propagation by adding the identity mapping and the nonlinear transformation branch. The calculation formula is as follows:

[0135]

[0136] in, and These are the input and output vectors of the residual block, respectively. This represents a nonlinear transformation function consisting of fully connected layers and activation functions. The architecture includes ResMLP1, ResMLP2, and ResMLP3, but is not limited to these. In the baseline model construction step, a baseline prediction model is trained on key feature bands, and its performance is evaluated on a validation set. The performance results serve as the performance benchmark for subsequent transfer learning models. Taking the TL-ResMLP2 network obtained through full-band transfer learning as an example, this network inherits the ResMLP2 architecture from the source-quality full-band initial prediction model. In the full-band transfer learning and key feature band transfer learning steps, the fine-tuning process can be optimized using an adaptive moment estimation algorithm, with the learning rate set to 1×10⁻⁶. -4 Up to 5×10 -4 The training sessions consist of 500 to 1000 repetitions.

[0137] Taking the ResMLP2 network structure as an example, the ResMLP2 network structure consists of an input layer, two residual blocks, and an output layer connected in sequence. Each residual block contains two fully connected layers and a non-linear activation function. The gradient vanishing problem in deep network training is alleviated by using shortcut connections.

[0138] The specific implementation of the corresponding TL-ResMLP2 transfer learning network includes: loading the weight parameters of the source quality pre-trained model as network initialization, freezing the parameters of all fully connected layers in the first two residual blocks, and fine-tuning only the parameters of the fully connected layers in the output layer to complete cross-quality knowledge transfer and model training.

[0139] Furthermore, embodiments of the present invention also provide an application of the transfer learning method provided in any of the above embodiments, namely, a full-spectrum detection method for the internal quality of fruit, which includes the following steps:

[0140] Provide multispectral image data of the target fruit and a quality detection model trained by the transfer learning method provided in any of the above embodiments;

[0141] The multispectral image data is input into the quality detection model to obtain predicted values ​​of the quality indicators of the target fruit.

[0142] Furthermore, corresponding to the above-mentioned transfer learning method, this embodiment of the invention also provides a transfer learning system based on a multispectral and interpretable fruit internal quality detection model, which includes:

[0143] The raw data module provides a training set, which includes multispectral image data of fruits and various physicochemical analysis label data on multiple quality indicators of the fruits.

[0144] The full-band pre-training module is used to train multiple original network architectures based on the multispectral image data of the full band for the source quality index, and select the optimal network architecture from the training results of the multiple original network architectures, and use the training result of the optimal network architecture as the initial prediction model of the full band.

[0145] The feature band selection module is used to analyze the training process of the optimal network architecture based on the interpretability analysis method, and select the bands in the optimal network architecture that contribute relatively highly to the prediction results as a subset of key feature bands.

[0146] The key band pre-training module is used to retrain the optimal network architecture in the feature bands corresponding to the key feature band subset for the source quality index, so as to obtain the initial prediction model of the key band.

[0147] The full-band transfer module is used to transfer network parameters to the prediction task of the target quality indicator based on the full-band initial prediction model of the source quality indicator as a pre-trained model, and construct a full-band transfer learning model by fine-tuning the network parameters.

[0148] The key band transfer module is used to transfer network parameters to the prediction task of the target quality index based on the initial prediction model of the key band of the source quality index as a pre-trained model. By fine-tuning the network parameters, a key band transfer learning model is constructed.

[0149] The model selection module is used to verify the performance of the full-band transfer learning model and the key-band transfer learning model based on the physicochemical analysis label data, and select the better one as the quality detection model related to the target quality index.

[0150] Finally, this embodiment of the invention also provides a readable storage medium storing a computer program, which, when run, executes the steps of the above-described transfer learning method, or the readable storage medium stores a quality detection model obtained by the above-described transfer learning method.

[0151] The technical solution of the present invention will be further described in detail below through several embodiments and in conjunction with the accompanying drawings. However, the selected embodiments are only for illustrating the present invention and do not limit the scope of the present invention.

[0152] Example 1

[0153] This embodiment takes the non-destructive testing of blueberries as an example, and the quality indicators are SSC content and TA content as examples, to illustrate a transfer learning method and application of a fruit internal quality detection model based on multispectral and interpretability, as shown below.

[0154] S1: Obtain multispectral image data of blueberry samples and reference physicochemical values ​​of their internal quality indicators;

[0155] Specifically, multispectral images of blueberry samples in the 405-970 nm spectral range were acquired using a multispectral imaging system, and the raw multispectral image data were obtained by processing the images using ViewmeterLab software. The SSC and TA contents of the blueberry samples were determined using physicochemical analysis methods. The resulting combined spectral-physicochemical index data are shown below. Figure 2a and Figure 2b As shown, this establishes a standardized reference database.

[0156] S2: Preprocess the multispectral image data;

[0157] Specifically, the multispectral data were preprocessed using various methods, including moving average smoothing, multiplicative scattering correction, and standard normal transformation. The processing results are as follows: Figures 3a-3f As shown. The original light intensity data is converted into reflectance data through whiteboard correction. The formula for calculating reflectance R is:

[0158]

[0159] in, The value of the reflected light intensity of the sample. This is the dark current value. The reference whiteboard reflects light intensity.

[0160] S3: Construct an initial prediction model for the entire band based on full-band spectral data;

[0161] Specifically, three residual network structures, ResMLP1, ResMLP2, and ResMLP3, were used to construct an initial prediction model for the internal quality of blueberries. The network structures are as follows: Figure 4 As shown in Table 1, the optimal network architecture was determined by comparing the performance of different network architectures on the validation set. The performance comparison of the three residual multilayer perceptron models for blueberry internal quality detection is shown in Table 1 below. The results show that ResMLP2 performs best on most quality metrics, therefore, this architecture was selected as the optimal architecture in this embodiment.

[0162] Table 1. Performance comparison of three residual multilayer perceptron models for blueberry internal quality detection.

[0163]

[0164] S4: Key characteristic bands are identified using the SHAP interpretability analysis method;

[0165] Specifically, the contribution of each band's characteristics is calculated using the SHAP value. The formula for calculating the SHAP value is as follows:

[0166] ;

[0167] in, Indicates the characteristic wavelength. For the complete feature set, Not included Feature subset, Indicates the use of subsets The predicted output of the time model.

[0168] The top 10 feature wavelengths by contribution were selected using a feature importance ranking method to form a key feature subset. The SHAP analysis results are as follows: Figures 5a-5d As shown, this illustrates the contribution of each band feature to the model predictions of different quality indices.

[0169] S5: Construct a baseline prediction model;

[0170] Specifically, the optimal network architecture is retrained on a subset of key feature bands to establish a lightweight prediction model (i.e., the initial prediction model for the key bands), and the model performance is validated using an independent validation set. The performance results of this baseline model serve as the performance benchmark for subsequent transfer learning models.

[0171] S6: Full-band transfer learning;

[0172] Specifically, using the full-band initial prediction model for SSC content as the source model, transfer learning models for TA content are constructed through parameter transfer and fine-tuning strategies. The TL-ResMLP2 network is used for full-band transfer learning. This network inherits the ResMLP2 architecture from the source quality full-band initial prediction model, and its network structure is as follows: Figure 6 As shown.

[0173] S7: Key Feature Transfer Learning;

[0174] Specifically, the initial prediction model for the keyband of SSC content prediction is used as the source model, and its network parameters are transferred to the prediction task of the target quality index TA. A hierarchical fine-tuning strategy is adopted, freezing the parameters of the early layers of the source model and optimizing the parameters only for the later layers, with the learning rate set to 1×10. -4 Up to 5×10 -4 .

[0175] S8: Model performance evaluation and selection;

[0176] Specifically, root mean square error, prediction correlation coefficient, and relative analysis error were used as evaluation metrics to compare and evaluate the performance of the full-band transfer learning model and the key-band transfer learning model based on important features. The performance comparison of the full-band and key-band transfer learning models is shown in Table 2. The results show that the key-feature-based transfer learning model exhibits superior generalization ability and stability in most cross-quality prediction tasks, and therefore was selected as the final model for predicting the SSC and TA indicators of blueberry internal quality.

[0177] Table 2 Performance Comparison of Transfer Learning Models Based on Full-Band and Key-Band

[0178]

[0179] Note: In Tables 1 and 2, the RMSEC and RMSEP values ​​of the TA indicator are all expressed in terms of 10. -4 Expressed in units.

[0180] In the above example, both quality indicators were better than the full-band transfer learning model, based on the key band. Of course, this is just one example of a specific result. In various embodiments applied to different fruits and different quality indicator ranges, it is not limited to the fact that the key band-based transfer learning model is always better than the full-band transfer learning model. Therefore, based on the method provided in this embodiment, the system will automatically compare and select which transfer learning method is suitable for different quality indicators, thereby constructing a comprehensive quality detection system for multiple quality indicators of multiple fruits. For details, please refer to the following implementation cases for other fruits.

[0181] Example 2

[0182] This embodiment uses non-destructive testing of strawberries as an example, and the methods and steps are the same as those for blueberries in Embodiment 1.

[0183] S1: Obtain multispectral image data of strawberry samples and reference physicochemical values ​​of their internal quality indicators. The resulting combined spectral-physicochemical index data is as follows: Figure 7a and Figure 7b As shown, this establishes a standardized reference database;

[0184] S2: Preprocess the multispectral image data; the processing result is as follows: Figures 8a-8f As shown;

[0185] S3: Construct an initial prediction model for the entire band based on full-band spectral data;

[0186] The performance comparison of the three residual multilayer perceptron models for blueberry internal quality detection is shown in Table 3 below:

[0187] Table 3. Performance comparison of three residual multilayer perceptron models for strawberry internal quality detection.

[0188]

[0189] S4: Key characteristic bands were identified using the SHAP interpretability analysis method. The SHAP analysis results are as follows: Figures 9a-9d As shown, this illustrates the contribution of each band feature to the model predictions of different quality indices.

[0190] S5: Construct a baseline prediction model;

[0191] S6: Full-band transfer learning;

[0192] S7: Key Feature Transfer Learning;

[0193] S8: Model performance evaluation and selection.

[0194] The performance comparison of transfer learning models based on full-band and key-band frequencies is shown in Table 4 below:

[0195] Table 4 Performance Comparison of Transfer Learning Models Based on Full-Band and Key-Band

[0196]

[0197] Note: In Tables 3 and 4, the RMSEC and RMSEP values ​​of the TA index are all expressed in terms of 10. -4 Expressed in units.

[0198] Example 3

[0199] This embodiment uses non-destructive testing of bananas as an example, and the methods and steps are the same as those for blueberries in Embodiment 1.

[0200] S1: Obtain multispectral image data of banana samples and reference physicochemical values ​​of their internal quality indicators. The resulting combined spectral-physicochemical indicator data is as follows: Figure 10a and Figure 10b As shown, this establishes a standardized reference database;

[0201] S2: Preprocess the multispectral image data; the processing result is as follows: Figures 11a-11f As shown;

[0202] S3: Construct an initial prediction model for the entire band based on full-band spectral data;

[0203] The performance comparison of the three residual multilayer perceptron models for blueberry internal quality detection is shown in Table 5 below:

[0204] Table 5. Performance comparison of three residual multilayer perceptron models for banana internal quality detection.

[0205]

[0206] S4: Key characteristic bands were identified using the SHAP interpretability analysis method. The SHAP analysis results are as follows: Figures 12a-12d As shown, this illustrates the contribution of each band feature to the model predictions of different quality indices.

[0207] S5: Construct a baseline prediction model;

[0208] S6: Full-band transfer learning;

[0209] S7: Key Feature Transfer Learning;

[0210] S8: Model performance evaluation and selection.

[0211] The performance comparison of transfer learning models based on full-band and key-band frequencies is shown in Table 6 below:

[0212] Table 6 Performance Comparison of Transfer Learning Models Based on Full-Band and Key-Band

[0213]

[0214] Note: In Tables 5 and 6, the RMSEC and RMSEP values ​​of the TA indicator are all expressed in terms of 10. -4 Expressed in units.

[0215] The various embodiments of the present invention have been described above. These descriptions are exemplary and not exhaustive, nor are they limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments.

[0216] It should be understood that the above embodiments are merely illustrative of the technical concept and features of the present invention, and are intended to enable those skilled in the art to understand the content of the present invention and implement it accordingly. They should not be construed as limiting the scope of protection of the present invention. All equivalent changes or modifications made in accordance with the spirit and essence of the present invention should be covered within the scope of protection of the present invention.

Claims

1. A transfer learning method based on a multispectral and interpretable fruit internal quality detection model, characterized in that, The fruit includes any one of blueberries, strawberries, and bananas, and the transfer learning method includes: A training set is provided, which includes multispectral image data of fruits and various physicochemical analysis label data on multiple quality indicators of the fruits' interior. Regarding source quality indicators Based on the multispectral image data of the entire band, multiple original network architectures are trained, and the optimal network architecture is selected from the training results to obtain the initial prediction model of the entire band. Among them, multiple original network architectures belong to the residual multilayer perceptron network architecture. The training process of the optimal network architecture is analyzed based on interpretability analysis methods. A subset of bands that contribute significantly to the prediction results is selected as the key feature band subset. The SHAP value is used as a representation of this contribution. For any feature band, the SHAP value is calculated as follows: ; in, Indicates in the sample Mid-characteristic band The sample SHAP value is used, and the average of the sample SHAP values ​​of all samples is used as the characteristic band. Contribution was filtered based on the SHAP values ​​of the bands; It is the set of all characteristic bands; Not including characteristic bands A subset of features; Indicates the use of subsets The predicted output of the optimal network architecture at that time; symbol The difference operation represents sets. Indicates from set Remove from The resulting set; For set Any subset of , denoted as ;symbol and Representing sets and The number of elements in the middle, ! represents the factorial operation; the symbol Representing a subset With a single set The union of; In the subset of key feature bands, the optimal network architecture is retrained to obtain the initial prediction model for the key bands; For the target quality indicators The network parameters of the initial full-band prediction model are transferred to the prediction task of the target quality index. By fine-tuning the network parameters, a full-band transfer learning model is constructed. The network parameters of the initial prediction model for the key bands are transferred to the prediction task of the target quality index. By fine-tuning the network parameters, a transfer learning model for the key bands is constructed. The performance of the full-band transfer learning model and the key-band transfer learning model is verified based on the physicochemical analysis label data, and the better one is selected as the quality detection model for the target quality index. Selecting the target quality indicator from three or more quality indicators and choosing one of the remaining quality indicators as the source quality indicator specifically includes: obtaining key feature band subsets of multiple quality indicators based on interpretability analysis methods, and selecting the quality indicator with the highest overlap with the key band subset of the target quality indicator as the source quality indicator. The process of pre-training and transfer learning is carried out until all the quality indicators are traversed, and a comprehensive model for detecting the internal quality of fruit is constructed. The evaluation indicators for the optimal network architecture and quality detection model include any one or a combination of two or more of the following: root mean square error, correlation coefficient, and residual prediction bias. The root mean square error is calculated as follows: ; The correlation coefficient is calculated as follows: ; The calculation method for the residual prediction bias is expressed as follows: ; in, This represents the root mean square error; This represents the correlation coefficient; This indicates the residual prediction bias; This refers to the physicochemical analysis label data. This represents the average value of multiple samples of the physicochemical analysis label data; This represents the predicted value from the physicochemical analysis data. This represents the average of multiple samples of predicted values ​​from physicochemical analysis data. Indicates the number of samples; Indicates the sample number; This represents the standard deviation of the physicochemical analysis label data.

2. The transfer learning method according to claim 1, characterized in that, The process of acquiring the multispectral image data specifically includes: Raw light intensity data of fruit samples were acquired using a multispectral imaging system; The original light intensity data is converted into reflectance data through whiteboard calibration; The reflectance data is preprocessed to obtain the multispectral image data. The preprocessing method includes any one or a combination of two of the following: moving average and multiplicative scattering correction. The optimal method is selected from among the various preprocessing methods based on the training performance.

3. The transfer learning method according to claim 1, characterized in that, The residual multilayer perceptron network architecture includes an input layer, a residual block, and an output layer. During transfer learning, only the parameters of the fully connected layers in the output layer are fine-tuned, while the remaining layers are frozen.

4. The transfer learning method according to claim 1, characterized in that, The selection process for the subset of key feature bands specifically includes: With the characteristic band The band SHAP values ​​are sorted from high to low, and a preset number of characteristic bands are selected from the top rankings. As a subset of the key feature bands.

5. A full-spectrum detection method for the internal quality of fruit, characterized in that, include: Provides multispectral image data of the target fruit and a quality detection model trained by the transfer learning method described in any one of claims 1-4; The multispectral image data is input into the quality detection model to obtain predicted values ​​of the quality indicators of the target fruit.

6. A transfer learning system based on a multispectral and interpretable fruit internal quality detection model, characterized in that, The transfer learning system is used to execute the transfer learning method according to any one of claims 1-4, wherein the fruit includes any one of blueberries, strawberries, and bananas, and the transfer learning system includes: The raw data module provides a training set, which includes multispectral image data of fruits and various physicochemical analysis label data on multiple quality indicators of the fruits. The full-band pre-training module is used to train multiple original network architectures based on the full-band multispectral image data for source quality indicators, and select the optimal network architecture from the training results to obtain the full-band initial prediction model. The feature band selection module is used to analyze the training process of the optimal network architecture based on the interpretability analysis method, and select the bands that contribute highly to the prediction results as a subset of key feature bands. The key band pre-training module is used to retrain the optimal network architecture in the key feature band subset for the source quality index, so as to obtain the initial prediction model of the key band. The full-band transfer module is used to transfer the network parameters of the initial full-band prediction model to the prediction task of the target quality index. By fine-tuning the network parameters, a full-band transfer learning model is constructed. The key band transfer module is used to transfer the network parameters of the initial prediction model of the key band to the prediction task of the target quality index. By fine-tuning the network parameters, a key band transfer learning model is constructed. The model selection module is used to verify the performance of the full-band transfer learning model and the key-band transfer learning model based on the physicochemical analysis label data, and select the better one as the quality detection model for the target quality index. It also includes: selecting the target quality indicator from multiple quality indicators and choosing one of the remaining quality indicators as the source quality indicator, specifically including: obtaining key feature band subsets of multiple quality indicators based on interpretability analysis methods, and selecting the quality indicator with the highest overlap with the key band subset of the target quality indicator as the source quality indicator. The module performs pre-training and transfer learning processes until all the quality indicators are traversed, constructing a comprehensive model for detecting the internal quality of fruits.

Citation Information

Patent Citations

  • Pear quality prediction method based on visible near infrared spectrum and transfer learning

    CN115684074A

  • Visualization method for detecting mango quality based on hyperspectrum

    CN121364171A