Multi-variety blueberry soluble solid nondestructive detection method, device and equipment based on transfer learning and medium
Patent Information
- Application Number
- CN202610623783.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-08
- Publication Date
- 2026-08-21
AI Technical Summary
该方法通过迁移源域模型中的先验知识,可在减少样本需求的同时缓解不同品种间光谱差异对模型性能的影响,但相关研究仍相对有限,且对小样本条件下多种迁移策略的系统比较尚不充分
[0038] Firstly, this application uses hyperspectral imaging technology combined with a transfer learning model, which can quickly detect the soluble solids content without physically damaging the blueberries. This avoids the problems of cumbersome operation, low efficiency, high cost and destructive nature of refractometer method and high performance liquid chromatography method, and meets the needs of modern blueberry production for rapid, non-destructive and large-scale detection.
Smart Images

Figure CN122618263A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of soluble solids detection, and more particularly to a non-destructive testing method, apparatus, electronic equipment and computer-readable storage medium for soluble solids in multiple varieties of blueberries based on transfer learning. Background Technology
[0002] Blueberries are widely favored by consumers for their rich nutritional value and unique flavor. In the blueberry quality evaluation system, soluble solids content (SSC) is a core indicator reflecting the accumulation of sugar in the fruit and its edible flavor, and its level directly affects the consumer experience and the commercial value of the product.
[0003] Currently, conventional methods for SSC detection mainly include refractometer method and high performance liquid chromatography (HPLC). Although these methods offer high measurement accuracy, they generally suffer from problems such as cumbersome operation, high detection cost, low efficiency, and destructive nature, making it difficult to meet the demands of modern fruit production for rapid, non-destructive, and large-scale detection. Therefore, developing a rapid, non-destructive, high-precision SSC detection method for blueberries suitable for small sample conditions is of great significance for achieving precise quality control of blueberries and promoting the intelligent development of the industry.
[0004] Hyperspectral imaging (HSI) is a non-destructive testing method that integrates spatial and spectral information. Due to its advantages of speed, accuracy, and non-destructiveness, it has been widely used for the quantitative detection of internal quality in fruits. Significant progress has been made in SSC prediction. Although existing technologies have validated the effectiveness of hyperspectral imaging in fruit SSC detection, most models are built for single varieties. Because different fruit varieties exhibit significant differences in internal structure, chemical composition, and spectral response characteristics, the generalization ability of these models is limited, making direct transfer to other varieties difficult. Remodeling for each new variety requires a large amount of data and time, and also limits the large-scale application of hyperspectral imaging technology.
[0005] Furthermore, transfer learning provides an effective approach to improve the generalization ability of models across varieties. This method can mitigate the impact of spectral differences between different varieties on model performance while reducing sample requirements by transferring prior knowledge from the source domain model. However, related research is still relatively limited, and systematic comparisons of various transfer strategies under small sample conditions are insufficient.
[0006] In summary, traditional non-destructive testing methods for soluble solids in blueberries are cumbersome, costly, inefficient, and destructive, making them unsuitable for rapid, non-destructive, and large-scale testing. Furthermore, single-variety hyperspectral detection models have poor generalization capabilities and cannot be directly applied across varieties. Existing cross-variety transfer learning research is insufficient, and there is a lack of systematic comparison of transfer strategies under small sample conditions. Therefore, the applicant has undertaken corresponding explorations to address these issues. Summary of the Invention
[0007] The purpose of this application is to solve the above-mentioned problems by providing a non-destructive testing method, corresponding apparatus, electronic equipment and computer-readable storage medium for soluble solids of multiple blueberry varieties based on transfer learning.
[0008] To achieve the various objectives of this application, the following technical solution is adopted:
[0009] A non-destructive testing method for soluble solids in multiple blueberry varieties based on transfer learning, proposed to meet one of the purposes of this application, includes:
[0010] Obtain source domain datasets and target domain datasets, wherein the source domain dataset includes multiple source domain samples, the source domain samples include the first standard spectral data of the first blueberry variety and its corresponding first soluble solids measured value, and the target domain dataset includes multiple target domain samples, the target domain samples include the second standard spectral data of the second blueberry variety and its corresponding second soluble solids measured value.
[0011] A mixed training set is constructed based on the source domain samples and the target domain samples. The first standard spectral data and the second standard spectral data are used as inputs, and the first measured value of soluble solids and the second measured value of soluble solids are used as outputs to construct a random forest model and train it.
[0012] The hybrid training set is input into the TrAdaBoost.R2 transfer learning framework. The random forest model is used as the base learner. The weights of the source domain samples and the target domain samples are dynamically adjusted through iterative weighting to suppress negative transfer and enhance effective knowledge transfer, thereby training a cross-variety soluble solids prediction model.
[0013] The standard spectral data of the second blueberry variety to be tested is input into the cross-variety soluble solids prediction model to output the soluble solids content of the second blueberry variety to be tested, so as to complete the non-destructive detection of soluble solids in multiple blueberry varieties based on transfer learning.
[0014] Optionally, the steps for determining the first standard spectral data and the second standard spectral data include:
[0015] A first hyperspectral image of the first blueberry variety and a second hyperspectral image of the second blueberry variety were acquired, and black and white card corrections were performed on the first hyperspectral image and the second hyperspectral image, respectively.
[0016] The maximum inter-class variance method is used to perform threshold segmentation based on a preset feature band ratio, and the first region of interest spectrum and the second region of interest spectrum are extracted from the first hyperspectral image and the second hyperspectral image, respectively.
[0017] Savitzky-Golay convolution smoothing preprocessing is performed on the spectra of the first region of interest and the spectra of the second region of interest to obtain the first standard spectral data and the second standard spectral data.
[0018] Optionally, the mixed training set is input into the TrAdaBoost.R2 transfer learning framework, using the random forest model as the base learner. The weights of the source domain samples and the target domain samples are dynamically adjusted through iterative weighting to suppress negative transfer and enhance effective knowledge transfer, thereby training a cross-variety soluble solids prediction model, including:
[0019] The number of source domain samples and the number of target domain samples in the mixed training set are counted.
[0020] Initial weights are uniformly assigned to each source domain sample and target domain sample in the mixed training set to determine the first weight corresponding to the source domain sample and the second weight corresponding to the target domain sample; at the same time, the initial parameters for updating the weights of the weak regressor are set based on the number of source domain samples and the number of target domain samples.
[0021] Optionally, the mixed training set is input into the TrAdaBoost.R2 transfer learning framework, using the random forest model as the base learner. The weights of the source domain samples and the target domain samples are dynamically adjusted through iterative weighting to suppress negative transfer and enhance effective knowledge transfer, thereby training a cross-variety soluble solids prediction model, including:
[0022] In each iteration, a weak learner is trained using the random forest model as the base learner, based on the current sample weight distribution.
[0023] Based on the weak learner, the first absolute prediction error of all source domain samples and the second absolute prediction error of all target domain samples in the current round are calculated. Then, based on the maximum absolute prediction error among all samples in the current round, the absolute prediction errors of each source domain sample and each target domain sample are normalized to obtain the first relative prediction error of each source domain sample and the second relative prediction error of each target domain sample.
[0024] Based on the second weight and second relative prediction error of the target domain samples, the total weighted average error of the target domain samples in this iteration is calculated, and the weight update coefficient of this iteration is calculated according to the total weighted average error. If the total weighted average error is greater than or equal to 0.5, then the total weighted average error is set to 0.5.
[0025] The sample weights are updated based on the weight update coefficients and the first relative prediction error and the second relative prediction error. For the target domain sample, the larger the second relative prediction error, the greater the weight increase. For the source domain sample, the larger the first relative prediction error, the greater the weight decrease, so as to suppress negative transfer and enhance effective knowledge transfer.
[0026] Repeat the above steps until the preset maximum number of iterations is reached to obtain multiple weak regressors; integrate the prediction results of all weak regressors by weighted median to obtain the final cross-variety soluble solids prediction model.
[0027] Optionally, the random forest model is constructed from multiple CART regression trees; wherein the number of CART regression trees is 50 to 150, and the maximum tree depth is 11 to 13.
[0028] Optionally, the source domain samples and the target domain samples are divided using the spectral-physicochemical co-occurrence distance method, and the source domain training set and source domain prediction set in the source domain dataset and the target domain training set and target domain prediction set in the target domain dataset are obtained according to a preset ratio.
[0029] Optionally, when constructing the hybrid training set, if the target domain samples account for only 20%, the cross-variety soluble solids prediction model can achieve good prediction performance.
[0030] A non-destructive testing device for soluble solids in multiple blueberry varieties, provided for another purpose of this application, includes:
[0031] The dataset acquisition module is configured to acquire a source domain dataset and a target domain dataset. The source domain dataset includes multiple source domain samples, each of which includes the first standard spectral data of a first blueberry variety and its corresponding measured value of first soluble solids. The target domain dataset includes multiple target domain samples, each of which includes the second standard spectral data of a second blueberry variety and its corresponding measured value of second soluble solids.
[0032] The base learner training module is configured to construct a hybrid training set based on the source domain samples and the target domain samples, take the first standard spectral data and the second standard spectral data as inputs, and take the first soluble solids measured value and the second soluble solids measured value as outputs to construct a random forest model and train it.
[0033] The prediction model building module is configured to input the hybrid training set into the TrAdaBoost.R2 transfer learning framework, use the random forest model as the base learner, and dynamically adjust the weights of the source domain samples and the target domain samples through iterative weighting to suppress negative transfer and enhance effective knowledge transfer, thereby training a cross-variety soluble solids prediction model.
[0034] The soluble solids detection module is configured to input the standard spectral data of the second blueberry variety to be tested into the cross-variety soluble solids prediction model, so as to output the soluble solids content of the second blueberry variety to be tested, thereby completing the non-destructive detection of soluble solids in multiple blueberry varieties based on transfer learning.
[0035] An electronic device provided for another purpose of this application includes a central processing unit and a memory, the central processing unit being configured to invoke and run a computer program stored in the memory to perform the steps of the transfer learning-based nondestructive testing method for soluble solids in multi-variety blueberries described in this application.
[0036] A computer-readable storage medium is provided for another purpose of this application, which stores, in the form of computer-readable instructions, a computer program implemented according to the transfer learning-based nondestructive testing method for soluble solids in multiple blueberry varieties, which, when invoked by a computer, performs the steps included in the corresponding method.
[0037] Compared to existing technologies, this application addresses the problems of traditional non-destructive testing methods for soluble solids in blueberries, which are cumbersome, costly, inefficient, and destructive, making them unsuitable for rapid, non-destructive, and large-scale testing; the poor generalization ability of single-variety hyperspectral detection models, which cannot be directly applied across varieties; and the lack of existing cross-variety transfer learning research and systematic comparison of transfer strategies under small sample conditions. This application offers the following benefits, including but not limited to:
[0038] Firstly, this application uses hyperspectral imaging technology combined with a transfer learning model, which can quickly detect the soluble solids content without physically damaging the blueberries. This avoids the problems of cumbersome operation, low efficiency, high cost and destructive nature of refractometer method and high performance liquid chromatography method, and meets the needs of modern blueberry production for rapid, non-destructive and large-scale detection.
[0039] Secondly, this application utilizes the TrAdaBoost.R2 transfer learning framework to effectively address the limitation of existing hyperspectral models, which can only be built for a single variety and are difficult to transfer to other varieties. The model can learn spectral-SSC mapping knowledge from source domain varieties with abundant data (such as Duke) and transfer it to target domain varieties with limited data (such as Blue Gold), significantly reducing the dependence of new variety modeling on sample size and time, and improving the model's versatility and potential for large-scale application.
[0040] Thirdly, the TrAdaBoost.R2 framework of this application dynamically adjusts the sample weights through iterative weighting, and can still maintain excellent prediction performance under the condition that the sample size of the target domain accounts for only 20% of the training set. This solves the problem of the large dependence of cross-variety detection on the sample size of the target domain in existing studies, and provides a feasible solution for the quality detection of small sample blueberry varieties in the actual industry.
[0041] Fourth, this application uses random forest as the base learner and combines the dynamic reweighting mechanism of TrAdaBoost.R2, which can automatically reduce the weight of source domain samples that are inconsistent with the target domain, suppress the negative transfer caused by variety differences, and strengthen the focus on samples that are difficult to predict in the target domain. Compared with traditional models, it significantly improves the accuracy and stability of cross-variety detection. Attached Figure Description
[0042] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein:
[0043] Figure 1 This is a flowchart illustrating the non-destructive testing method for soluble solids in multiple blueberry varieties based on transfer learning, as described in this application.
[0044] Figure 2 This is a schematic diagram of the hyperspectral imaging acquisition system in an embodiment of this application;
[0045] Figure 3 This is a schematic diagram of the blueberry region of interest (ROI) extraction process in an embodiment of this application;
[0046] Figure 4 This is a schematic diagram of the workflow of the TrAdaBoost.R2 algorithm in the embodiments of this application;
[0047] Figure 5 This is a schematic diagram showing the distribution of soluble solids (SSC) content among different blueberry varieties in the embodiments of this application;
[0048] Figure 6 This is a schematic diagram of the average spectral reflectance curves of different blueberry varieties in the embodiments of this application;
[0049] Figure 7 This is a schematic diagram of the latent variable optimization results of the PLSR model in the embodiments of this application;
[0050] Figure 8 This is a schematic diagram of the SVR model parameter optimization process in an embodiment of this application;
[0051] Figure 9 This is a schematic diagram of the RF model parameter optimization results in the embodiments of this application;
[0052] Figure 10 This is a schematic diagram of the LSTM model parameter optimization results in the embodiments of this application;
[0053] Figure 11 This is a schematic diagram showing the prediction results of blueberry soluble solids content using different models in the embodiments of this application;
[0054] Figure 12 This is a schematic diagram comparing the cross-variety prediction performance of different transfer learning methods in the embodiments of this application;
[0055] Figure 13 This is a schematic diagram of the non-destructive testing device for soluble solids of multiple blueberry varieties based on transfer learning in the embodiments of this application;
[0056] Figure 14 This is a schematic diagram of the structure of the computer device in the embodiments of this application. Detailed Implementation
[0057] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain this application, and should not be construed as limiting this application.
[0058] Those skilled in the art will understand that, unless specifically stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the term “comprising” as used in this application means the presence of the stated features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof. It should be understood that when we say an element is “connected” or “coupled” to another element, it can be directly connected or coupled to the other element, or there may be intermediate elements. Furthermore, “connected” or “coupled” as used herein can include wireless connections or wireless coupling. The term “and / or” as used herein includes all or any units and all combinations of one or more associated listed items.
[0059] Those skilled in the art will understand that, unless otherwise defined, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. It should also be understood that terms such as those defined in general dictionaries should be understood to have the same meaning as in the context of the prior art, and should not be interpreted in an idealized or overly formal sense unless specifically defined as herein.
[0060] Those skilled in the art will understand that the terms "client," "terminal," and "terminal device" as used herein include both devices that receive wireless signals, devices that only possess wireless signal receiver capabilities without transmission capabilities, and devices with receiving and transmitting hardware, devices that have receiving and transmitting hardware capable of bidirectional communication over a bidirectional communication link. Such devices may include: cellular or other communication devices such as personal computers or tablets, having single-line displays, multi-line displays, or cellular or other communication devices without multi-line displays; PCS (Personal Communications Service) that can combine voice, data processing, fax, and / or data communication capabilities; PDAs (Personal Digital Assistants) that may include radio frequency receivers, pagers, internet / intranet access, web browsers, notebooks, calendars, and / or GPS (Global Positioning System) receivers; and conventional laptops and / or handheld computers or other devices that have and / or include radio frequency receivers. As used herein, "client," "terminal," and "terminal device" can be portable, transportable, installed in a means of transportation (air, sea, and / or land), or suitable and / or configured to operate locally and / or in a distributed manner, operating in any other location on Earth and / or in space. "Client," "terminal," and "terminal device" as used herein can also be a communication terminal, an internet access terminal, or a music / video playback terminal, such as a PDA, a MID (Mobile Internet Device), and / or a mobile phone with music / video playback capabilities, or a smart TV, set-top box, etc.
[0061] The hardware referred to by the names "server," "client," and "service node" in this application is essentially an electronic device with the equivalent capabilities of a personal computer. It is a hardware device with the necessary components revealed by the von Neumann architecture, such as a central processing unit (including an arithmetic logic unit and a control unit), memory, input devices, and output devices. The computer program is stored in its memory, and the central processing unit loads the program stored in the secondary storage into the main memory to run it, execute the instructions in the program, and interact with the input and output devices to complete specific functions.
[0062] It should be noted that the concept of "server" used in this application can also be extended to the case of server clusters. Based on the network deployment principles understood by those skilled in the art, the servers should be logically divided. Physically, these servers can be independent of each other but accessible through interfaces, or they can be integrated into a single physical computer or a computer cluster. Those skilled in the art should understand this flexibility and should not use it to constrain the implementation of the network deployment method in this application.
[0063] One or more of the technical features of this application, unless explicitly specified herein, can be deployed on a server and accessed by a client remotely calling the online service interface provided by the server, or can be directly deployed and run on a client for access.
[0064] Unless otherwise specified, the neural network models referenced or potentially referenced in this application may be deployed on a remote server and invoked remotely on the client, or deployed on a client with the capability to invoke directly. In some embodiments, when running on the client, the corresponding intelligence may be acquired through transfer learning in order to reduce the requirements on the client's hardware resources and avoid excessive consumption of the client's hardware resources.
[0065] Unless otherwise specified, all data involved in this application may be stored remotely on a server or on a local terminal device, as long as it is suitable for use by the technical solution of this application.
[0066] Those skilled in the art will understand that although the various methods in this application are described based on the same concept and thus present commonality among them, they can be performed independently unless otherwise specified. Similarly, the various embodiments disclosed in this application are all based on the same inventive concept; therefore, concepts expressed in the same way, as well as concepts that are appropriately changed for convenience but are expressed differently, should be understood equivalently.
[0067] Unless otherwise expressly stated, the various embodiments disclosed in this application can be combined in a cross-cutting manner to flexibly construct new embodiments, as long as such combination does not depart from the inventive spirit of this application and can meet the needs of the prior art or solve a certain deficiency in the prior art. Those skilled in the art should be aware of such modifications.
[0068] Please see Figure 1 In one embodiment of the nondestructive testing method for soluble solids in multiple blueberry varieties based on transfer learning of this application, the method includes:
[0069] Step S10: Obtain source domain dataset and target domain dataset, wherein the source domain dataset includes multiple source domain samples, the source domain samples include the first standard spectral data of the first blueberry variety and its corresponding first soluble solids measured value, and the target domain dataset includes multiple target domain samples, the target domain samples include the second standard spectral data of the second blueberry variety and its corresponding second soluble solids measured value.
[0070] The multi-variety blueberry soluble solids nondestructive testing system in the terminal device can acquire source domain datasets and target domain datasets. The source domain dataset includes multiple source domain samples, each of which includes first standard spectral data of a first blueberry variety and its corresponding measured first soluble solids value. The target domain dataset includes multiple target domain samples, each of which includes second standard spectral data of a second blueberry variety and its corresponding measured second soluble solids value.
[0071] Specifically, the first blueberry variety can be "Duke" and the second blueberry variety can be "Blue Gold". The selection of two blueberry varieties, "Duke" and "Blue Gold", as test subjects in this application does not constitute any limitation on this application.
[0072] The source and target domain samples were collected from a blueberry plantation on June 8, 2024. Immediately after harvesting, the blueberries were pre-cooled and transported to the laboratory in a preservation device. Blueberries of uniform size, consistent ripeness, and free from pests, diseases, and mechanical damage were selected as test samples. These samples were pre-cooled in a 4°C cold storage for 4 hours. Then, 120±1g of blueberries (approximately 35 berries) were weighed and placed in PET preservation boxes, with 3 boxes for each variety, for a total of 6 boxes. During the experiment, the samples were stored in a constant temperature incubator at 25±1°C and a relative humidity of 75%–85%RH.
[0073] In some embodiments, the source domain samples and the target domain samples are divided using the spectral-physicochemical co-occurrence distance method, and the source domain training set and source domain prediction set in the source domain dataset and the target domain training set and target domain prediction set in the target domain dataset are obtained according to a preset ratio.
[0074] In some embodiments, when the proportion of target domain samples is only 20% when constructing the hybrid training set, the cross-variety soluble solids prediction model can achieve good prediction performance.
[0075] In some embodiments, the step of determining the first standard spectral data and the second standard spectral data includes:
[0076] Step S101: Acquire the first hyperspectral image of the first blueberry variety and the second hyperspectral image of the second blueberry variety, and perform black and white plate correction on the first hyperspectral image and the second hyperspectral image respectively;
[0077] Please see Figure 2 The hyperspectral image acquisition system used is such as Figure 2 As shown, the system consists of a hyperspectral imaging spectrometer (ImSpector V10E), a CCD camera with a resolution of 392×1040 (IGV-B1410M), a displacement platform (IRCP0076-1), two 150W fiber optic halogen lamps (3900-Illuminatior), and a matching darkroom (120 cm × 50 cm × 140 cm) and computer (DELL Vostro5560D-1528). The hyperspectral imaging system has a wavelength acquisition range of 400 to 1000 nm, a spectral resolution of 1.27 nm, and includes 472 bands.
[0078] Before the experiment, the system was preheated for 30 minutes to ensure equipment stability and reduce baseline drift. During image acquisition, 30 blueberry samples (stem-side up) were randomly selected from each sample box and placed on the stage. The system parameters were set as follows: vertical distance between the sample and the camera lens was 33 cm, lens exposure time was 3 ms, and platform movement speed was 1.65 mm·s⁻¹. Hyperspectral images of 180 samples (2 varieties × 30 samples × 3 boxes) were finally obtained.
[0079] To eliminate the effects of camera dark current and noise, the original image needs to be calibrated using a black and white calibration plate. First, a white calibration plate with a reflectivity close to 100% is scanned to obtain a fully white calibration image. Then, put the lens cap on and obtain a completely black calibration image. The corrected hyperspectral image was calculated. Among them, the corrected hyperspectral image The calculation formula is expressed as:
[0080] ;
[0081] in, This represents the corrected hyperspectral image; This represents a fully white calibration image; This indicates a completely black calibration image.
[0082] Furthermore, after acquiring hyperspectral images, the SSC values of blueberry samples were determined using a digital refractometer. The samples were wrapped in sterile gauze and juice was extracted by squeezing. 0.3 mL of juice was then transferred using a pipette and dropped onto the refractometer surface for measurement. The measurement range was 0–45 °Brix, with an accuracy of ±0.1 °Brix. Each sample was measured in triplicate, and the average value was taken.
[0083] Step S102: Using the maximum inter-class variance method, threshold segmentation is performed based on the preset feature band ratio, and the first region of interest spectrum and the second region of interest spectrum are extracted from the first hyperspectral image and the second hyperspectral image, respectively.
[0084] Step S103: Perform Savitzky-Golay convolution smoothing preprocessing on the first region of interest spectrum and the second region of interest spectrum to obtain the first standard spectral data and the second standard spectral data.
[0085] Specifically, the characteristic band ratio can be the ratio between the 645.57 nm band and the 880.83 nm band, etc. During the acquisition of blueberry hyperspectral images, due to the influence of the spherical geometry of the sample, the high reflectivity of the fruit surface, and the complex structure of the stem region, overexposure, shadows, and background interference are prone to occur in the image, resulting in spectral information distortion. To reduce the impact of the above factors on the modeling accuracy, this application proposes a region of interest (ROI) extraction method based on the characteristic band ratio. First, the spectral characteristics of the background, blueberry surface, stem, and overexposed areas in the hyperspectral image were analyzed. The results show that the 645.57 nm and 880.83 nm bands are located at the typical absorption valley and reflection peak of blueberries, respectively, and can effectively identify the above-mentioned different regions. Therefore, a feature-enhanced image is constructed by calculating the ratio of these two bands to highlight the normal reflectivity area of the blueberry. Subsequently, the Otsu's method is used to perform adaptive threshold segmentation on the contrast image to generate a binary image, which is further converted into a binary mask. Finally, the binary mask is used to accurately extract the Regions of Interest (ROIs) that represent the overall spectral characteristics of blueberries from the original hyperspectral image. The specific process is as follows: Figure 3 As shown in the figure. This method effectively suppresses the effects of noise, fruit stalk, and local reflectance differences, improving the reliability and representativeness of subsequent spectral data and providing high-quality input data for accurate SSC modeling.
[0086] In spectral analysis, raw spectral data is often affected by various factors such as random noise, baseline drift, scattering effects, and optical path differences, which may reduce the stability and prediction accuracy of the model. Therefore, spectral preprocessing is an indispensable and crucial step before modeling, aiming to reduce irrelevant information and enhance effective features, thereby improving the robustness and generalization ability of the model. This application systematically compares the effects of five commonly used preprocessing methods, including Savitzky-Golay smoothing (SG), Standard Normal Variate (SNV), Multiplicative Scatter Correction (MSC), First Derivative (D1), and Second Derivative (D2). By modeling and analyzing the full-band spectrum, the impact of each preprocessing method on the SSC prediction performance is evaluated, and the Savitzky-Golay smoothing method is selected for subsequent transfer learning modeling.
[0087] Regarding sample set partitioning, this application employs sample set partitioning based on joint XY distances (SPXY) to partition the preprocessed spectral data and corresponding SSC values of two blueberry varieties at a 3:1 ratio, resulting in a source domain training set (68 samples) and a source domain prediction set (22 samples) in the source domain dataset, and a target domain training set (68 samples) and a target domain prediction set (22 samples) in the target domain dataset. Subsequently, the rationality of the sample partitioning is evaluated by calculating the maximum, minimum, average, standard deviation, and coefficient of variation of the SSC values of the training and prediction sets.
[0088] Step S20: Construct a mixed training set based on the source domain samples and the target domain samples, using the first standard spectral data and the second standard spectral data as inputs, and the first measured value of soluble solids and the second measured value of soluble solids as outputs, to construct a random forest model and train it.
[0089] After obtaining the source domain dataset and the target domain dataset, a hybrid training set is constructed based on the source domain samples and the target domain samples. The first standard spectral data and the second standard spectral data are used as inputs, and the first measured value of soluble solids and the second measured value of soluble solids are used as outputs to construct a random forest model and train it.
[0090] Specifically, partial least squares regression (PLSR) is one of the most widely used linear regression methods in spectral analysis. It effectively reduces dimensionality and models high-dimensional data by extracting latent variables that are highly correlated with the dependent variable (SSC) from spectral data. In this application, 5-fold cross-validation is used to determine the optimal number of latent variables, ensuring model accuracy while avoiding overfitting, thereby constructing a reliable benchmark model.
[0091] Support vector regression (SVR) is a nonlinear regression method based on support vector machines. It effectively characterizes complex nonlinear relationships by introducing a kernel function to map input data to a high-dimensional feature space. This application uses a radial basis function as the kernel function and employs a grid search algorithm to automatically optimize the hyperparameters (penalty factor c and kernel parameter γ) to improve the model's predictive performance.
[0092] Backpropagation (BP) neural networks are a typical type of multilayer feedforward neural network. They use an error backpropagation algorithm to iteratively update the connection weights and biases in the network to minimize prediction error. This model has strong nonlinear fitting capabilities.
[0093] Random forest (RF) is a regression algorithm based on ensemble learning. It achieves prediction by constructing multiple decision trees and integrating their outputs. During training, RF effectively reduces model variance and improves generalization ability and noise resistance by randomly sampling samples and features.
[0094] Extreme learning machine (ELM) is a fast learning algorithm developed from a single hidden layer feedforward neural network. Its hidden layer parameters are randomly generated, and only the output weights need to be solved. Therefore, it has the advantages of fast training speed and high computational efficiency, and is suitable for rapid modeling of high-dimensional spectral data.
[0095] Long Short-Term Memory (LSTM) networks are an improved recurrent neural network architecture that effectively models long-term dependent information by introducing gating mechanisms such as forget gates, input gates, and output gates. The cell states in the core units are used for storing and transmitting long-term information, while the gating results are responsible for filtering, updating, and outputting information, thus alleviating the gradient vanishing problem in traditional RNNs. Although hyperspectral data is not strictly a time series, its continuity and local correlation in the wavelength dimension allow LSTM to effectively capture inter-band dependencies, thereby improving modeling capabilities.
[0096] To ensure fairness in comparing the prediction performance of different models, all models were constructed and evaluated based on the same training and prediction sets.
[0097] To comprehensively evaluate the applicability and performance of different modeling strategies in blueberry SSC prediction, this application selected six representative quantitative analysis algorithms to construct prediction models, including partial least squares regression (PLSR), support vector regression (SVR), backpropagation (BP) neural network, random forest (RF), extreme learning machine (ELM), and long short-term memory network (LSTM). Through systematic comparison of the prediction results of each model, random forest (RF) demonstrated strong nonlinear fitting ability, excellent noise resistance and generalization performance, good adaptability to high-dimensional spectra and small sample sizes, efficient and stable training, and high compatibility with the TrAdaBoost.R2 iterative weighting mechanism. It can significantly improve the prediction accuracy and transfer learning effect of cross-variety blueberry SSC, thus selecting the random forest model as the optimal base learner for quantitative analysis of blueberry SSC. The random forest model is constructed from multiple CART regression trees; the number of CART regression trees is 50 to 150, and the maximum tree depth is 11 to 13.
[0098] Step S30: Input the hybrid training set into the TrAdaBoost.R2 transfer learning framework, use the random forest model as the base learner, and dynamically adjust the weights of the source domain samples and the target domain samples through iterative weighting to suppress negative transfer and enhance effective knowledge transfer, thereby training a cross-variety soluble solids prediction model.
[0099] A hybrid training set is constructed based on the source domain samples and the target domain samples. The first standard spectral data and the second standard spectral data are used as inputs, and the first measured value of soluble solids and the second measured value of soluble solids are used as outputs. After constructing and training a random forest model, the hybrid training set is input into the TrAdaBoost.R2 transfer learning framework. The random forest model is used as the base learner. The weights of the source domain samples and the target domain samples are dynamically adjusted through iterative weighting to suppress negative transfer and enhance effective knowledge transfer. A cross-variety soluble solids prediction model is then trained.
[0100] Specifically, to improve the generalization ability of the blueberry SSC prediction model under cross-variety conditions, this application introduces two representative transfer learning methods: transfer component analysis (TCA) based on feature transformation and TrAdaBoost.R2 based on instance reweighting. Both methods alleviate the distributional differences between the source and target domains from different levels and are suitable for small-sample transfer learning scenarios.
[0101] TCA (Transfer-Based Acquisition) is a classic feature-level transfer learning method. Its core idea is to project source and target domain data into the same high-dimensional reproducing kernel Hilbert space through kernel mapping, and minimize the maximum mean discrepancy (MMD) of the data distributions in this space, thereby achieving feature distribution alignment. While reducing inter-domain discrepancies, TCA can preserve as many of the main structural features of the original data as possible. Since the estimation of the maximum mean discrepancy (MMD) distance depends on the selected kernel function, this application uses a Gaussian kernel function for mapping, sets the feature space dimension to 10 to 20, and determines the optimal parameter combination through 5-fold cross-validation to achieve a balance between distribution adaptation and feature preservation, thereby improving the generalization performance of the cross-variety prediction model.
[0102] Please see Figure 4 TrAdaBoost.R2 is an extension of the TrAdaBoost algorithm for regression problems. Its core idea is to iteratively adjust the weights of source and target domain samples under the assumption that the feature and label spaces are consistent, to select source domain knowledge that is beneficial to the prediction of the target domain and assign it higher weights, while gradually reducing the weights of source domain samples with low transfer value, thereby weakening the negative transfer effect and enhancing the model's predictive ability in the target domain.
[0103] Since TrAdaBoost.R2 is an instance-level transfer learning framework for regression tasks, it can dynamically adjust the sample weights of the source and target domains through an iterative weighting mechanism without changing the hyperspectral feature structure, effectively suppressing negative transfer caused by variety differences. It still has excellent prediction performance under small sample target domain conditions, strong compatibility with random forest base learners, high model robustness, and simple engineering implementation. Therefore, it was selected as the optimal transfer learning framework for cross-variety prediction of blueberry soluble solids content.
[0104] In some embodiments, the hybrid training set is input into the TrAdaBoost.R2 transfer learning framework, using the random forest model as the base learner. The weights of the source domain samples and the target domain samples are dynamically adjusted through iterative weighting to suppress negative transfer and enhance effective knowledge transfer, thereby training a cross-variety soluble solids prediction model, including:
[0105] Step S301: Count the number of source domain samples and the number of target domain samples in the mixed training set;
[0106] Step S302: Evenly distribute initial weights to each source domain sample and target domain sample in the mixed training set to determine the first weight corresponding to the source domain sample and the second weight corresponding to the target domain sample; at the same time, set the initial parameters for updating the weak regressor weights based on the number of source domain samples and the number of target domain samples.
[0107] Specifically, let the number of samples in the source domain be m, and the number of samples in the target domain be n. Initially, the initial weights of the samples in the source domain are... Initial weights of the target domain samples The weights are evenly distributed to determine the first weights corresponding to the source domain samples and the second weights corresponding to the target domain samples; the initial parameters for the weak regressor weight update are set to a constant. Meanwhile, a dynamic parameter will be calculated in each subsequent iteration. The initial weights of the source domain samples are expressed as follows:
[0108] ;
[0109] in, Indicates the first The initial weights of each source domain sample, that is, the first weights corresponding to the source domain samples;
[0110] This represents the total number of samples in the source domain.
[0111] Furthermore, the expression for the initial weights of the target domain samples is:
[0112] ;
[0113] in, Indicates the first Initial weights for each target domain sample; This represents the total number of samples in the target domain.
[0114] Furthermore, the expression for the initial parameters of the weak regressor weight update is:
[0115] ;
[0116] in, This indicates that the initial parameters of the weak regressor are updated based on their weights. Indicates the total number of samples in the source domain; Indicates the total number of samples in the target domain; It represents the natural logarithm.
[0117] In a further embodiment, the hybrid training set is input into the TrAdaBoost.R2 transfer learning framework, using the random forest model as the base learner. The weights of the source domain samples and the target domain samples are dynamically adjusted through iterative weighting to suppress negative transfer and enhance effective knowledge transfer, thereby training a cross-variety soluble solids prediction model, including:
[0118] Step S3001: In each iteration, based on the current sample weight distribution, a weak learner is trained using the random forest model as the base learner.
[0119] Step S3002: Based on the weak learner, calculate the first absolute prediction error of all source domain samples and the second absolute prediction error of all target domain samples in the current round. Then, using the maximum absolute prediction error among all samples in the current round as a benchmark, normalize the absolute prediction errors of each source domain sample and each target domain sample to obtain the first relative prediction error of each source domain sample and the second relative prediction error of each target domain sample.
[0120] Step S3003: Based on the second weight and second relative prediction error of the target domain samples, calculate the total weighted average error of the target domain samples in this iteration, and calculate the weight update coefficient of this iteration according to the total weighted average error. If the total weighted average error is greater than or equal to 0.5, then set the total weighted average error to 0.5.
[0121] Step S3004: Update the sample weights based on the weight update coefficients, the first relative prediction error, and the second relative prediction error. For the target domain sample, the larger the second relative prediction error, the greater the weight increase. For the source domain sample, the larger the first relative prediction error, the greater the weight decay. This is to suppress negative transfer and enhance effective knowledge transfer.
[0122] Step S3005: Repeat the above steps until the preset maximum number of iterations is reached to obtain multiple weak regressors; integrate the prediction results of all weak regressors by weighted median to obtain the final cross-variety soluble solids prediction model.
[0123] Specifically, in the In each iteration, based on the current sample weight distribution, a weak learner is trained on the mixed training set using the random forest model as the base learner. Calculate the first absolute prediction error for all source domain samples in the current round. The second absolute prediction error for all target domain samples Using the maximum absolute prediction error among all samples in the current round as a benchmark, the absolute prediction errors of each source domain sample and each target domain sample are normalized to obtain the first relative prediction error of each source domain sample and the second relative prediction error of each target domain sample. The formula for calculating the first relative prediction error of each source domain sample is as follows:
[0124] ;
[0125] in, Indicates the first In the first iteration, the... The first relative prediction error for each source domain sample; Indicates the first The first absolute prediction error for each source domain sample; Indicates the first In each round of iterations, the maximum absolute prediction error between all source domain samples and target domain samples; Indicates the first In the first iteration, the... A weak learner obtained by training on samples from the source domain; Indicates the first Measured values of soluble solids in each source domain sample;
[0126] The formula for calculating the second relative prediction error of each target domain sample is as follows:
[0127] ;
[0128] in, Indicates the first In the first iteration, the... The second relative prediction error for each target domain sample; Indicates the first In each round of iterations, the maximum absolute prediction error between all source domain samples and target domain samples; Indicates the first The second absolute prediction error for each target domain sample; Indicates the first In the first iteration, the... A weak learner obtained by training on samples from the target domain; Indicates the first Measured values of soluble solids in each target domain sample;
[0129] Furthermore, based on the second weights and second relative prediction errors of the target domain samples, the total weighted average error of the target domain samples in this iteration is calculated, wherein the formula for calculating the total weighted average error of the target domain samples is expressed as:
[0130] ;
[0131] in, Indicates the first In the round of iterations, the total weighted average error of the target domain samples, if If ≥ 0.5, then let =0.5, to ensure effective algorithm iteration; Indicates the first In the first iteration, the... The current weight of the nth target domain sample, that is, the nth The second weight of each target domain sample; Indicates the first In the first iteration, the... The second relative prediction error for each target domain sample; This indicates the preset maximum number of iterations.
[0132] Furthermore, based on the total weighted average error of the target domain samples... Calculate the weight update coefficients for this iteration. This is used to specifically adjust the update magnitude of the sample weights in this round, where the weight update coefficient is... The calculation formula is expressed as:
[0133] ;
[0134] in, Indicates the first The weight update coefficients for each iteration are used to control the magnitude of the sample weight update in this round.
[0135] Furthermore, the coefficients are updated based on the weights. Compared with the first relative prediction error Second relative prediction error The updated sample weights are calculated using the following formula:
[0136] ;
[0137] in, Indicates the first In the first iteration, the... The updated sample weights of each source domain sample;
[0138] Indicates the first In the first iteration, the... The current weight of the nth source domain sample, that is, the nth The first weight of each source domain sample; Indicates the first In the first iteration, the... Updated sample weights for each target domain sample; Indicates the first In the first iteration, the... The current weight of each target domain sample, which is also the second weight of the target domain sample; Indicates the first In the first iteration, the... The first relative prediction error for each source domain sample; Indicates the first In the first iteration, the... The second relative prediction error for each target domain sample; Indicates the first The weight update coefficients in each iteration are used to control the magnitude of the sample weight update in this round. For the target domain samples, the larger the second relative prediction error, the greater the weight increase; for the source domain samples, the larger the first relative prediction error, the greater the weight decay, in order to suppress negative transfer and enhance effective knowledge transfer.
[0139] Furthermore, repeat the above steps until the preset maximum number of iterations is reached. Multiple weak regressors were obtained. The final output is the weighted median of all weak regressor predictions, which exhibits better robustness compared to a weighted average. This algorithm, through a dynamic reweighting mechanism, iteratively strengthens beneficial transfer and suppresses ineffective transfer, thereby enabling the construction of a high-accuracy cross-variety soluble solids (SSC) prediction model even with limited target domain data. Combining feature-level and instance-level transfer learning methods provides a multi-perspective basis for model transfer evaluation and optimization for blueberry cross-variety SSC prediction.
[0140] In some embodiments, after the cross-variety soluble solids prediction model is constructed, the determination coefficients of the training set are used as indicators. (decision coefficient of calibration set) and its corresponding root mean square error RMSEC, and the coefficient of determination of the test set. The predictive performance of the model is evaluated using the decision coefficient of the prediction set, its corresponding root mean square error (RMSEP), and the ratio of sample standard deviation to prediction root mean square error (RPD). The formulas for calculating RMSE and RPD are expressed as follows:
[0141] ;
[0142] in, Indicates the coefficient of determination; Indicates the first Predicted values for each sample; This represents the mean of the measured values for all samples. Indicates the first Measured values of a sample;
[0143] ;
[0144] in, Indicates the root mean square error; Indicates the first Measured values of a sample; Indicates the first The predicted value for each sample.
[0145] ;
[0146] in, Indicators representing the model's predictive stability and generalization ability; The standard deviation of the measured values of the sample in the prediction set; This represents the root mean square error of the prediction set.
[0147] In general, The closer the RPD is to 1, the higher the model's goodness of fit; the smaller the RMSE, the higher the prediction accuracy; the larger the RPD, the stronger the model's stability and generalization ability. Referring to conventional criteria: RPD < 1.5 indicates insufficient model prediction ability; 1.5 < RPD < 2 indicates average model prediction ability; 2 < RPD < 2.5 indicates good model prediction performance and quantitative analysis capability; RPD ≥ 2.5 indicates excellent model prediction performance and high reliability.
[0148] Step S40: Input the standard spectral data of the second blueberry variety to be tested into the cross-variety soluble solids prediction model to output the soluble solids content of the second blueberry variety to be tested, so as to complete the non-destructive detection of soluble solids in multiple blueberry varieties based on transfer learning.
[0149] The hybrid training set is input into the TrAdaBoost.R2 transfer learning framework. Using the random forest model as the base learner, the weights of the source domain samples and the target domain samples are dynamically adjusted through iterative weighting to suppress negative transfer and enhance effective knowledge transfer. After training to obtain a cross-variety soluble solids prediction model, the standard spectral data of the second blueberry variety to be detected is input into the cross-variety soluble solids prediction model to output the soluble solids content of the second blueberry variety to be detected, thereby completing the non-destructive detection of soluble solids in multiple blueberry varieties based on transfer learning.
[0150] In some embodiments, Figure 5 The SSC distribution characteristics of two blueberry varieties, 'Duke' and 'Blue Gold', are presented. It can be seen that the SSC of both blueberry varieties exhibits an approximately normal distribution, but there are significant differences in distribution range and central tendency. 'Duke' blueberries have a relatively high overall SSC level, mainly distributed in the 8–12 °Brix range, accounting for 85.56% of the samples, with the peak position biased towards the high SSC region. In contrast, 'Blue Gold' blueberries have a slightly lower overall SSC distribution, mainly concentrated in the 7–11 °Brix range, accounting for 87.78% of the total samples, with the distribution center shifted relatively to the left. These results indicate significant differences in sugar accumulation levels among different blueberry varieties. The differences in SSC distribution among varieties not only reflect differences in their physiological characteristics and ripening features but may also lead to changes in corresponding hyperspectral response characteristics, thus affecting the generalization ability of spectral-based prediction models. Therefore, in subsequent modeling processes, it is necessary to construct SSC prediction models for different varieties separately and further explore the effectiveness of transfer learning methods in cross-variety prediction.
[0151] To ensure the reliability of model construction and evaluation, this application employs the SPXY sample partitioning method, dividing the samples of both varieties into training and prediction sets at a 3:1 ratio. The specific sample composition is shown in Table 1. Statistical results show that the SSC range of "Zhu Ke" blueberry is 6.90–12.87 °Brix, with an average of 9.86 °Brix; the SSC range of "Lan Jin" blueberry is 6.77–13.40 °Brix, with an average of 9.13 °Brix. Further comparison of the SSC range, mean, and standard deviation of the training and prediction sets reveals that the training set fully covers the SSC variation range of the prediction set, indicating that the samples selected using the SPXY method are highly representative, laying a reliable data foundation for subsequent model training and transfer learning analysis.
[0152] Table 1. SPXY method for statistical analysis of SSC content in blueberries of different varieties and sample sets.
[0153]
[0154] In some embodiments, in hyperspectral data analysis, the initial and final bands often have significant noise interference due to unstable sensor response. This application selects spectral data (464 effective wavelengths) in the range of 405.45–995.79 nm for subsequent modeling and analysis.
[0155] Please see Figure 6 , Figure 6 The average spectral curves and fluctuation ranges of "Duke" and "Blue Gold" blueberries within the aforementioned wavelength range are shown. Overall, the spectral variation trends of the two blueberry varieties are basically consistent, but some differences still exist. In the 400-700 nm wavelength range, the spectral reflectance is generally low with small differences between samples. This region is mainly affected by the absorption of pigments such as chlorophyll, carotenoids, and anthocyanins. Although these components do not directly determine the sugar content, their changes are closely related to fruit ripeness, thus indirectly affecting sugar accumulation. In the 700-810 nm range, the reflectance increases rapidly with increasing wavelength, and the slope of the spectral curve is relatively large. This region is more sensitive to changes in cell internal structure and water content, and therefore, the distribution of SSCs can be indirectly reflected through changes in cell water potential and structure. A significant reflectance peak appears in the 840-900 nm wavelength range. This region corresponds to the absorption characteristics of carbohydrates. Since the main component of SSCs is soluble sugars, this range becomes a key area for constructing a quantitative prediction model for SSCs. An absorption valley caused by the stretching vibration of OH bonds in water can be observed near 970 nm. Increased moisture content dilutes soluble solids, so this band can also serve as an important basis for predicting SSC.
[0156] It is noteworthy that across the entire effective wavelength range, the spectral reflectance of 'Duke' blueberry is generally higher than that of 'Blue Gold', indicating a significant difference in the spectral response characteristics between the two blueberry varieties. This inter-varietal spectral difference may limit the generalization ability of SSC prediction models built based on a single variety when applied across different varieties. Therefore, this application, based on the establishment of SSC calibration models for 'Duke' and 'Blue Gold' blueberries respectively, further introduces transfer learning methods to explore the effective transferability of the models across different blueberry varieties.
[0157] To determine the optimal spectral preprocessing method, this application uses the original spectrum and data transformed by five preprocessing methods as input, and employs a partial least squares regression (PLSR) model, which can effectively overcome the problem of spectral collinearity, for performance evaluation. The prediction results for each method are shown in Table 2.
[0158] Table 2. Results of PLSR models established using different spectral preprocessing methods for predicting soluble solids content.
[0159]
[0160] Analysis of Table 2 shows that both Savitzky-Golay convolutional smoothing preprocessing and first derivative (D1) processing can improve the SSC prediction performance of the two blueberry varieties to varying degrees. Among them, Savitzky-Golay convolutional smoothing preprocessing has the most outstanding overall performance: for the "Duke" blueberry, its prediction set... The efficiency was 0.8934, RMSEP was 0.4866, and RPD was 3.14; in "Blue Gold" blueberries, the Savitzky-Golay (SG) convolution smoothing... The accuracy reached 0.9060, the RMSEP was 0.3590, and the RPD was improved by approximately 10.2% compared to the original spectrum. These results demonstrate that Savitzky-Golay convolutional smoothing preprocessing effectively suppresses spectral noise, enhances the effective signal, and significantly improves the model's prediction accuracy and robustness. Therefore, subsequent modeling in this application is based on the spectral data preprocessed with Savitzky-Golay convolutional smoothing.
[0161] In some embodiments, each prediction method was optimized to determine the optimal architecture and parameters for six modeling methods (PLSR, SVM, BP, RF, ELM, LSTM). For the PLSR model, the number of latent variables was determined using 5-fold cross-validation and the minimum RMSECV criterion to avoid overfitting and ensure the objectivity of model selection. The optimization process is as follows: Figure 7 As shown. Figure 7 (a) shows the optimization process of the Duke blueberry model. When the number of latent variables reaches 15, RMSECV reaches its minimum. Figure 7 (b) shows the optimization process of the Blue Gold Blueberry model. The model has the best prediction effect when the number of latent variables is 2.
[0162] For the SVR model, this application uses the radial basis function (RBF) as the kernel function and employs a grid search algorithm combined with 5 cross-validations to automatically optimize the hyperparameters (penalty factor C and kernel function parameter γ) to improve the model's prediction performance. The initial optimization ranges for C and γ are both
[10] . -10 10 10 The optimal SVR model for "Duke" has C=4 and γ=0.707106781 (log2C=2, log2γ=0), while the optimal SVR model for "BlueGold" has a penalty factor of C=512 and γ=0.000976563 (log2C=9, log2γ=-10). The optimization process is as follows: Figure 8 As shown.
[0163] The BP model determines the dual hidden layer structure through structure search, with the hidden layers set to a fixed structure of [16,8], i.e., 16 neurons in the first hidden layer and 8 neurons in the second hidden layer. The input spectral data is normalized in the [0,1] interval, and the Sigmoid activation function is used for nonlinear mapping. The training process uses the Levenberg-Marquardt optimization algorithm, with a maximum of 50 iterations, and an early stopping mechanism is introduced to improve training efficiency.
[0164] For RF models, parameter optimization mainly focuses on two key hyperparameters: the number of decision trees (ntrees) and the maximum depth of the decision trees (ntrees). The optimal parameter combination was determined using a grid search combined with 5-fold cross-validation. Based on the preliminary tuning results, the model was built using the TreeBagger function, with the number of decision trees ranging from 50 to 300 and the maximum tree depth ranging from 3 to 15. The final parameter optimization results are as follows. Figure 9 As shown, the optimal RF prediction model for "Duke" has 50 trees and a maximum depth of 13; the optimal RF prediction model for "BlueGold" has 150 trees and a maximum depth of 11, and its prediction performance is the best.
[0165] The ELM model employs a single-hidden-layer feedforward neural network architecture. The input layer dimension matches the feature dimension of the spectral data, with 30 hidden layer nodes. The hidden layers use the Sigmoid activation function to introduce a non-linear transformation, and the output layer uses linear regression units. During training, the model achieves efficient non-iterative training by randomly generating input weights and biases and directly calculating the output layer weights using the Moore-Penrose generalized inverse matrix.
[0166] The LSTM model employs a progressive optimization strategy, introducing batch normalization layers and Dropout layers to enhance model stability. Optimal parameter combinations are determined through grid search validation. The number of hidden layer units is set to 64, 128, and 256, and the number of iterations is set to 400, 600, and 800. The Adam optimizer, combined with a piecewise learning rate decay strategy, overcomes the premature convergence problem caused by the traditional fixed learning rate. Furthermore, L2 regularization and early stopping mechanisms are introduced to further suppress overfitting. The final optimized model parameters are shown below. Figure 10 As shown. Among them, Figure 10 (a) shows the training process of the "Duke" prediction model, and the model's prediction performance is best when the number of hidden layer units is 128 and the number of iterations is 800. Figure 10 (b) The best performance of the “Blue Gold” prediction model occurs under the condition of 128 hidden layer units and 600 iterations.
[0167] In some embodiments, the spectral density (SSC) of 'Duke' and 'BlueGold' blueberries is predicted using PLSR, SVR, BP, RF, ELM, and LSTM models as input. The results are as follows: Figure 11 As shown in the figures, Figures A to F present the results of six prediction models for "Duke," and Figures G to L present the results of six prediction models for "Blue Gold." The SG-RF model predictions for both varieties are highly consistent with the measured values, and the test set sample points are evenly distributed on both sides of the 1:1 reference line, demonstrating a good fit.
[0168] Among the "Duke" varieties, its The RMSEP reached 0.9029, the RMSEP was as low as 0.3771, and the RPD was 3.28; among the "Blue Gold" varieties, The performance of the RF model is 0.9124, RMSEP is 0.3774, and RPD is 3.46. The superior performance of the RF model may stem from its ensemble learning mechanism's control over model variance, the ability of random feature selection to filter key bands, and its robustness to noise and outliers. In contrast, the PLSR model, as a linear model, has limitations in capturing the complex nonlinear relationship between the blueberry spectrum and SSC. While models such as SVR, BP, ELM, and LSTM perform well on the training set, their performance degrades on the prediction set, indicating relatively weak generalization ability.
[0169] In summary, the RF model demonstrates excellent performance in terms of accuracy, robustness, and generalization ability, and is therefore identified as the optimal model for blueberry SSC prediction, providing reliable methodological support for subsequent research.
[0170] In some embodiments, to evaluate the generalization ability of the SG-RF model among blueberry varieties, this application adopts a cross-testing strategy: the model is trained using the spectrum of the "Duke" variety and used to predict the SSC of the "Bluegold" variety, and then trained using the spectrum of the "Bluegold" variety and used to predict the SSC of the "Duke" variety. The results are shown in Table 4.
[0171] Table 4. Predicted soluble solids content of different varieties based on RF model.
[0172]
[0173] As shown in Table 4, the direct model transfer prediction performance among different blueberry varieties was not ideal. When using the SG-RF model developed based on the "Duke" blueberry variety to predict the SSC of "Blue Gold," the model performance significantly decreased. The RMSEP decreased from 0.9029 to 0.4377, while the RMSEP increased from 0.3771 to 0.8762, and the RPD decreased from 3.28 to 1.36. A similar situation occurred when using the "Blue Gold" model to predict the "Duke" variety. The RMSEP value was only 0.2902, the RMSEP increased to 0.9824, and the RPD value was only 1.21, indicating that the model lost its effective predictive ability. This phenomenon mainly stems from the inherent differences in physicochemical properties, cell tissue structure, and peel thickness among different blueberry varieties, leading to systematic biases in their spectral response characteristics. The results show that SSC calibration models built based on a single variety are difficult to directly apply to quantitative predictions of other varieties. Therefore, systematically studying the transferability of SSC models among different blueberry varieties and developing calibration methods adapted to varietal differences has significant research value and practical necessity.
[0174] In some embodiments, to achieve accurate prediction of blueberry SSC under the condition of limited target domain samples, this application employs two transfer learning algorithms, TCA and TrAdaBoost.R2, to construct a hybrid training set by fusing samples from the source and target domains. This method can extract transferable information from the source domain and use an adaptive weight mechanism to select samples valuable for modeling the target domain, thereby establishing a high-performance prediction model. Specifically, the TrAdaBoost.R2 algorithm uses a RF model as the base learner.
[0175] Migration performance based on target domain The core evaluation metric is RPD, combined with the number of samples in the target domain for comprehensive evaluation: higher RPD results indicate higher RPD. A higher RPD value and a smaller target domain sample size indicate better transfer efficiency. The experiment set eight target domain sample ratios from 0.1 to 0.8, which were then integrated into the source domain to construct a mixed training set. This application used "Blue Gold" and "Duke" as the source domains and another variety as the target domain, employing two transfer learning algorithms for modeling. The prediction performance is as follows: Figure 12 As shown.
[0176] The results show that, in different source-target domain combinations, as the proportion of target domain samples in the mixed training set increases, the performance of both the TCA and TrAdaBoost.R2 models improves. Both the RPD value and the prediction accuracy showed a steady upward trend, indicating a significant improvement in prediction accuracy. When using "Blue Gold" as the source domain to predict "Duke" ( Figure 12 a) After the target domain proportion reached 0.6, the RPD of both models was greater than 2.5, indicating that the models had good predictive ability. When predicting "Blue Gold" using "Duke" as the source domain ( Figure 12(b) TrAdaBoost.R2 requires only a target domain ratio of 0.2 (4 samples) to achieve an RPD of 3.0, while TCA achieves an RPD exceeding 2.5 even with a ratio of 0.4 (9 samples). Notably, TrAdaBoost.R2 achieves its best performance with "Duke" as the source domain, reaching a maximum RPD of 3.6124. The RPD is 0.9234. To achieve an RPD > 2.5, TrAdaBoost.R2 consistently requires fewer target domain samples than TCA. Performance comparisons further demonstrate that TrAdaBoost.R2 significantly outperforms TCA in transfer learning under small sample conditions. This advantage may stem from its dynamic weighting mechanism, which effectively suppresses samples in the source domain that differ significantly from the target domain, while TCA only performs feature space alignment, limiting its adaptability to situations with a large number of irrelevant samples in the source domain. Therefore, TrAdaBoost.R2 is more suitable for real-world modeling scenarios where target domain samples are scarce.
[0177] This application systematically compared six modeling methods: PLSR, SVR, BP, RF, ELM, and LSTM. The results showed that the SG-RF model performed best in predicting SSC of "Duke" and "Blue Gold" blueberries, with Rp2 of 0.9257 and 0.9139, and RPD of 3.75 and 3.48, respectively.
[0178] To address the issue of poor cross-domain applicability of single-variety models, we further compared two transfer learning methods: TCA and TrAdaBoost.R2. The results show that TrAdaBoost.R2 performs better in cross-variety prediction, requiring fewer target domain samples to achieve the same prediction accuracy (RPD > 2.5). For example, in the transfer from "Blue Gold" to "Duke," only 20% of the target domain samples are needed. The efficiency ratio is 0.87, and the RPD is 2.73. Its advantages mainly stem from three mechanisms: first, iterative reweighting suppresses source domain samples with large distribution differences, thus mitigating negative transfer; second, the ensemble learning framework enhances the generalization ability for small samples; and third, the weight reorganization strategy focuses on high-value source domain samples, improving information utilization efficiency.
[0179] Although this application improves the small-sample modeling performance through SPXY sample partitioning and transfer learning strategies, the scale of 90 samples per variety is still insufficient and may limit the performance of complex models such as LSTM. Future research could further enhance model robustness by increasing the sample size or introducing data augmentation techniques. In summary, TrAdaBoost.R2 provides an effective solution for cross-variety blueberry quality non-destructive testing model transfer, especially suitable for real-world scenarios where target domain samples are scarce.
[0180] As can be seen from the above embodiments, compared with the prior art, this application addresses the problems of traditional non-destructive testing methods for soluble solids in blueberries being cumbersome, costly, inefficient, and destructive, making it difficult to meet the needs of rapid, non-destructive, and large-scale testing; the poor generalization ability of single-variety hyperspectral detection models, which cannot be directly applied across varieties; and the lack of existing cross-variety transfer learning research and systematic comparison of transfer strategies under small sample conditions. This application provides, but is not limited to, the following beneficial effects:
[0181] Firstly, this application uses hyperspectral imaging technology combined with a transfer learning model, which can quickly detect the soluble solids content without physically damaging the blueberries. This avoids the problems of cumbersome operation, low efficiency, high cost and destructive nature of refractometer method and high performance liquid chromatography method, and meets the needs of modern blueberry production for rapid, non-destructive and large-scale detection.
[0182] Secondly, this application utilizes the TrAdaBoost.R2 transfer learning framework to effectively address the limitation of existing hyperspectral models, which can only be built for a single variety and are difficult to transfer to other varieties. The model can learn spectral-SSC mapping knowledge from source domain varieties with abundant data (such as Duke) and transfer it to target domain varieties with limited data (such as Blue Gold), significantly reducing the dependence of new variety modeling on sample size and time, and improving the model's versatility and potential for large-scale application.
[0183] Thirdly, the TrAdaBoost.R2 framework of this application dynamically adjusts the sample weights through iterative weighting, and can still maintain excellent prediction performance under the condition that the sample size of the target domain accounts for only 20% of the training set. This solves the problem of the large dependence of cross-variety detection on the sample size of the target domain in existing studies, and provides a feasible solution for the quality detection of small sample blueberry varieties in the actual industry.
[0184] Fourth, this application uses random forest as the base learner and combines the dynamic reweighting mechanism of TrAdaBoost.R2, which can automatically reduce the weight of source domain samples that are inconsistent with the target domain, suppress the negative transfer caused by variety differences, and strengthen the focus on samples that are difficult to predict in the target domain. Compared with traditional models, it significantly improves the accuracy and stability of cross-variety detection.
[0185] Please see Figure 13This application provides a non-destructive testing device for soluble solids in multiple blueberry varieties based on transfer learning, comprising a dataset acquisition module 1100, a base learner training module 1200, a prediction model construction module 1300, and a soluble solids detection module 1400. The dataset acquisition module 1100 is configured to acquire source domain datasets and target domain datasets. The source domain dataset includes multiple source domain samples, including first standard spectral data of a first blueberry variety and its corresponding measured first soluble solids value. The target domain dataset includes multiple target domain samples, including second standard spectral data of a second blueberry variety and its corresponding measured second soluble solids value. The base learner training module 1200 is configured to construct a hybrid training set based on the source domain samples and the target domain samples, using the first standard spectral data and the second standard spectral data as input, and the first soluble solids value and the second soluble solids value as input. For output, a random forest model is constructed and trained; the prediction model construction module 1300 is configured to input the mixed training set into the TrAdaBoost.R2 transfer learning framework, using the random forest model as the base learner, and dynamically adjust the weights of the source domain samples and the target domain samples through iterative weighting to suppress negative transfer and enhance effective knowledge transfer, thereby training a cross-variety soluble solids prediction model; the soluble solids detection module 1400 is configured to input the standard spectral data of the second blueberry variety to be detected into the cross-variety soluble solids prediction model to output the soluble solids content of the second blueberry variety to be detected, thereby completing the non-destructive detection of soluble solids in multiple blueberry varieties based on transfer learning.
[0186] Based on any embodiment of this application, please refer to Figure 14 Another embodiment of this application also provides an electronic device, which can be implemented by a computer device, such as... Figure 14The diagram shows the internal structure of a computer device. This computer device includes a processor, a computer-readable storage medium, a memory, and a network interface connected via a system bus. The computer-readable storage medium stores an operating system, a database, and computer-readable instructions. The database stores control information sequences. When executed by the processor, the computer-readable instructions enable the processor to implement a non-destructive testing method for soluble solids in multiple blueberry varieties based on transfer learning. The processor provides computational and control capabilities, supporting the operation of the entire computer device. The memory stores computer-readable instructions, which, when executed by the processor, enable the processor to execute the non-destructive testing method for soluble solids in multiple blueberry varieties based on transfer learning as described in this application. The network interface of the computer device is used for communication with a terminal. Those skilled in the art will understand that… Figure 14 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0187] In this embodiment, the processor is used to execute... Figure 13 The specific functions of each module are defined within the device, and the memory stores the program code and various data required to execute these modules. The network interface is used for data transmission between the user terminal and the server. In this embodiment, the memory stores the program code and data required to execute all modules in the transfer learning-based non-destructive testing device for soluble solids in multiple blueberry varieties. The server can call the server's program code and data to execute the functions of all modules.
[0188] This application also provides a storage medium storing computer-readable instructions, which, when executed by one or more processors, cause the one or more processors to perform the steps of the non-destructive testing method for soluble solids of multiple blueberry varieties based on transfer learning as described in any embodiment of this application.
[0189] This application also provides a computer program product, including a computer program / instructions that, when executed by one or more processors, implement the steps of the non-destructive testing method for soluble solids of multi-variety blueberries based on transfer learning as described in any embodiment of this application.
[0190] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. This computer program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. The aforementioned storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0191] The above description is only a partial embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A non-destructive testing method for soluble solids in multiple blueberry varieties based on transfer learning, characterized in that, include: Obtain source domain datasets and target domain datasets, wherein the source domain dataset includes multiple source domain samples, the source domain samples include the first standard spectral data of the first blueberry variety and its corresponding first soluble solids measured value, and the target domain dataset includes multiple target domain samples, the target domain samples include the second standard spectral data of the second blueberry variety and its corresponding second soluble solids measured value. A mixed training set is constructed based on the source domain samples and the target domain samples. The first standard spectral data and the second standard spectral data are used as inputs, and the first measured value of soluble solids and the second measured value of soluble solids are used as outputs to construct a random forest model and train it. The hybrid training set is input into the TrAdaBoost.R2 transfer learning framework. The random forest model is used as the base learner. The weights of the source domain samples and the target domain samples are dynamically adjusted through iterative weighting to suppress negative transfer and enhance effective knowledge transfer, thereby training a cross-variety soluble solids prediction model. The standard spectral data of the second blueberry variety to be tested is input into the cross-variety soluble solids prediction model to output the soluble solids content of the second blueberry variety to be tested, so as to complete the non-destructive detection of soluble solids in multiple blueberry varieties based on transfer learning.
2. The non-destructive testing method for soluble solids in multiple blueberry varieties based on transfer learning according to claim 1, characterized in that, The steps for determining the first standard spectral data and the second standard spectral data include: A first hyperspectral image of the first blueberry variety and a second hyperspectral image of the second blueberry variety were acquired, and black and white card corrections were performed on the first hyperspectral image and the second hyperspectral image, respectively. The maximum inter-class variance method is used to perform threshold segmentation based on a preset feature band ratio, and the first region of interest spectrum and the second region of interest spectrum are extracted from the first hyperspectral image and the second hyperspectral image, respectively. Savitzky-Golay convolution smoothing preprocessing is performed on the spectra of the first region of interest and the spectra of the second region of interest to obtain the first standard spectral data and the second standard spectral data.
3. The non-destructive testing method for soluble solids in multiple blueberry varieties based on transfer learning according to claim 1, characterized in that, The hybrid training set is input into the TrAdaBoost.R2 transfer learning framework. Using the random forest model as the base learner, the weights of the source domain samples and the target domain samples are dynamically adjusted through iterative weighting to suppress negative transfer and enhance effective knowledge transfer, thereby training a cross-variety soluble solids prediction model, including: The number of source domain samples and the number of target domain samples in the mixed training set are counted. Initial weights are uniformly assigned to each source domain sample and target domain sample in the mixed training set to determine the first weight corresponding to the source domain sample and the second weight corresponding to the target domain sample; at the same time, the initial parameters for updating the weights of the weak regressor are set based on the number of source domain samples and the number of target domain samples.
4. The non-destructive testing method for soluble solids in multiple blueberry varieties based on transfer learning according to claim 1, characterized in that, The hybrid training set is input into the TrAdaBoost.R2 transfer learning framework. Using the random forest model as the base learner, the weights of the source domain samples and the target domain samples are dynamically adjusted through iterative weighting to suppress negative transfer and enhance effective knowledge transfer, thereby training a cross-variety soluble solids prediction model, including: In each iteration, a weak learner is trained using the random forest model as the base learner, based on the current sample weight distribution. Based on the weak learner, the first absolute prediction error of all source domain samples and the second absolute prediction error of all target domain samples in the current round are calculated. Then, based on the maximum absolute prediction error among all samples in the current round, the absolute prediction errors of each source domain sample and each target domain sample are normalized to obtain the first relative prediction error of each source domain sample and the second relative prediction error of each target domain sample. Based on the second weight and second relative prediction error of the target domain samples, the total weighted average error of the target domain samples in this iteration is calculated, and the weight update coefficient of this iteration is calculated according to the total weighted average error. If the total weighted average error is greater than or equal to 0.5, then the total weighted average error is set to 0.
5. The sample weights are updated based on the weight update coefficients and the first relative prediction error and the second relative prediction error. For the target domain sample, the larger the second relative prediction error, the greater the weight increase. For the source domain sample, the larger the first relative prediction error, the greater the weight decrease, so as to suppress negative transfer and enhance effective knowledge transfer. Repeat the above steps until the preset maximum number of iterations is reached to obtain multiple weak regressors; integrate the prediction results of all weak regressors by weighted median to obtain the final cross-variety soluble solids prediction model.
5. The non-destructive testing method for soluble solids in multiple blueberry varieties based on transfer learning according to claim 1, characterized in that, The random forest model is constructed from multiple CART regression trees; the number of CART regression trees is 50 to 150, and the maximum tree depth is 11 to 13.
6. The non-destructive testing method for soluble solids in multiple blueberry varieties based on transfer learning according to claim 1, characterized in that, The source domain samples and the target domain samples are divided using the spectral-physicochemical co-occurrence distance method, and the source domain training set and source domain prediction set in the source domain dataset and the target domain training set and target domain prediction set in the target domain dataset are obtained according to a preset ratio.
7. The non-destructive testing method for soluble solids in multiple blueberry varieties based on transfer learning according to claim 1, characterized in that, When constructing the hybrid training set, the cross-variety soluble solids prediction model can achieve good prediction performance when the proportion of target domain samples is only 20%.
8. A non-destructive testing device for soluble solids in multiple varieties of blueberries based on transfer learning, characterized in that, include: The dataset acquisition module is configured to acquire a source domain dataset and a target domain dataset. The source domain dataset includes multiple source domain samples, each of which includes the first standard spectral data of a first blueberry variety and its corresponding measured value of first soluble solids. The target domain dataset includes multiple target domain samples, each of which includes the second standard spectral data of a second blueberry variety and its corresponding measured value of second soluble solids. The base learner training module is configured to construct a hybrid training set based on the source domain samples and the target domain samples, take the first standard spectral data and the second standard spectral data as inputs, and take the first soluble solids measured value and the second soluble solids measured value as outputs to construct a random forest model and train it. The prediction model building module is configured to input the hybrid training set into the TrAdaBoost.R2 transfer learning framework, use the random forest model as the base learner, and dynamically adjust the weights of the source domain samples and the target domain samples through iterative weighting to suppress negative transfer and enhance effective knowledge transfer, thereby training a cross-variety soluble solids prediction model. The soluble solids detection module is configured to input the standard spectral data of the second blueberry variety to be tested into the cross-variety soluble solids prediction model, so as to output the soluble solids content of the second blueberry variety to be tested, thereby completing the non-destructive detection of soluble solids in multiple blueberry varieties based on transfer learning.
9. An electronic device comprising a central processing unit and a memory, characterized in that, The central processing unit is used to invoke and run a computer program stored in the memory to perform the steps of the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, It stores, in the form of computer-readable instructions, a computer program implemented according to any one of claims 1 to 7, which, when invoked by a computer, executes the steps included in the corresponding method.