Method and system for rapidly detecting protein content and water content in plant-based product based on near infrared spectrum and deep learning

By combining near-infrared spectroscopy technology and deep learning models, a rapid method for detecting protein content and moisture content in plant-based products was developed, which solved the problems of expensive equipment and complex operation of existing detection methods, and achieved portable, efficient and non-destructive detection effects.

CN119643500AActive Publication Date: 2025-03-18CHINA AGRI UNIV +1

Patent Information

Application Number
CN202411720899.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-28
Publication Date
2025-03-18
Estimated Expiration
2044-11-28

AI Technical Summary

Technical Problem

The detection methods for protein content and moisture content in existing plant-based products have the disadvantages of expensive equipment, complex operation, inconvenience and environmental pollution, and cannot meet the needs of fast, lossless and portable testing.

Method used

Using a rapid detection method based on near-infrared spectroscopy and deep learning models, the original near-infrared spectral data were collected by immersing and drying plant-based samples, and fitting them through a deep learning model of the convolutional neural network and Transformer network architecture to establish a model for detecting protein content and moisture content.

Benefits of technology

It realizes rapid, accurate and non-destructive testing of protein content and moisture content in plant-based products, and provides a portable and efficient testing system to meet the urgent needs of the food production field.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119643500A_ABST
    Figure CN119643500A_ABST
Patent Text Reader

Abstract

The invention discloses a method and a system for efficiently and rapidly detecting protein content and moisture content in a plant-based product based on near infrared spectrum and deep learning, and the method comprises the following steps: obtaining spectral data of a plant-based sample, and carrying out experimental determination on the protein content and the moisture content; in combination with multi-step data preprocessing and adaptive dimensionality reduction, feature signals highly related to target detection are extracted, and a deep learning model based on a convolutional neural network and a self-attention mechanism is utilized to construct a high-precision detection model; a final stable detection model is obtained through multiple times of verification and optimization of the model, and hardware integration is carried out on the final stable detection model and a portable spectrometer to form a detection system. The detection system comprises a 3D printing shell, a spectrum sensor, a conversion line and a data processing unit, the protein content and the water content of a sample can be rapidly and nondestructively detected through one-key operation, and the whole process does not need chemical reagent intervention. The method has the advantages of being high in detection speed, high in portability, easy and convenient to operate, wide in application scene and the like, and is particularly suitable for application occasions needing efficient and on-site real-time detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of nondestructive testing, and in particular to a method and system for quickly detecting protein content and moisture content in plant-based products. Background Art

[0002] The world is paying more and more attention to sustainable food sources and animal welfare. Soy protein has attracted much attention due to its rich protein, nutritional value, and environmental friendliness. As a sustainable food source, the application of soy protein is of great significance in reducing the dependence of traditional animal husbandry on resources, reducing greenhouse gas emissions, and improving the safety of food models. Plant-based products are mostly made of soy protein, pea protein, etc., which are rich in high-quality protein and can be used to produce alternative meat products. They can effectively alleviate the protein shortage problem faced by the world, and at the same time inject new vitality into the diversification and innovation of the food industry. However, as these products become more popular in the market, it becomes particularly important to ensure their quality and safety.

[0003] Traditional detection methods, such as Kjeldahl nitrogen determination, Dumas combustion method, spectrophotometry and drying method, although reliable, have many inconveniences, including time-consuming, expensive equipment, the need for chemical reagents and environmental pollution. These factors make them unable to meet the needs of rapid, non-destructive and portable detection of protein content and moisture content in plant-based materials. Near-infrared spectroscopy (NIRS) is favored because of its advantages such as portability, rapidity, non-destructive damage to samples, low cost and real-time detection. It meets the urgent needs of the food production field and has been widely used in the field of traditional food ingredient detection. Deep learning (DL) is widely used, which can make the model more complex and large. By automatically extracting complex spectral features, it can process a large amount of unstructured, high-dimensional spectral data and extract useful information from it. This ability enables deep learning to cope with the challenges of complex samples or unknown substances in spectral analysis. Combined with deep learning, the application of NIRS can be further enhanced. Summary of the invention

[0004] In view of the problems that existing methods for detecting protein content and moisture content in plant-based products require the purchase of expensive instruments, are complicated and non-portable to operate, and use chemical reagents, the present invention provides a method and system for rapid detection of protein content and moisture content in plant-based products based on near-infrared spectroscopy and deep learning models.

[0005] The technical solution adopted by the present invention to solve the above problems is: Rapid detection methods for protein content and moisture content in plant-based products, including: S1 Soak plant-based samples from different production batches in water to ensure that the moisture content of the samples is uniform; S2 puts the fully soaked sample into a 70°C oven for drying, takes it out every 1 hour, weighs it and collects its original near-infrared spectrum data until the sample is completely dried and weighed again; S3 weighs the completely dried plant-based samples, measures the moisture content of the samples at different times and the protein content after drying according to the national standard method, and converts them into protein content under different conditions, thereby establishing a database to ensure that it corresponds to the original spectral data measured in S2; S4 preprocesses the collected raw near-infrared spectral data and randomly divides them into a training set and a validation set; S5 uses a convolutional neural network to introduce a self-attention mechanism based on the Transformer network architecture and a feedforward neural network to build a deep learning model, fits the near-infrared spectral data and protein content data of the training set samples, and establishes a deep learning model I for detecting the protein content in plant-based materials; fits the near-infrared spectral data and moisture content data of the training set samples, and establishes a deep learning model II for detecting the moisture content in plant-based materials; S6 minimizes the loss function through the back-propagation algorithm, reversely updates the weight parameters of Model I and Model II, and uses the validation set in S4 to verify and optimize the hyperparameters of the model to improve the accuracy and robustness of the model. After multiple verifications and optimizations, the final detection model is obtained; If the coefficient of determination R 2 >0.9, root mean square error RMSE<0.1, the model meets the requirements and can be used for rapid detection of protein content and moisture content of plant-based products; S7 prepares the plant-based sample to be tested, fully soaks it in water, and then puts it in a 70°C oven for drying; The samples were taken out and weighed every hour, and the original spectral data were measured; The original spectral data is input into the final detection model of S6, and the output result is the predicted value of protein content and moisture content of plant-based products.

[0006] As an improvement of the above technical solution, in S1, the sample is immersed for no less than 10 hours to make its moisture content reach a uniform state.

[0007] As an improvement of the above technical solution, in S2, the sample is taken out for spectral scanning at three different positions, and the average value is taken as the original spectral data of the sample; in order to ensure the accuracy and robustness of the model, at least 300 sets of spectral data are collected; wherein the scanning range of the near-infrared spectrometer is 10000~6250cm -1 .

[0008] As an improvement of the above technical solution, in S3, the sample is completely dried in a 70°C oven and then weighed. The protein content in the sample is determined according to the combustion method in GB5009.5-2010. The moisture content at different times is calculated by the weight difference of the sample before and after drying. The protein content at different times is calculated by keeping the total amount of protein in the sample unchanged before and after drying, and the results are matched one by one with the original spectral data.

[0009] As an improvement of the above technical solution, in S4, one or more methods selected from the group consisting of first-order difference, second-order difference, wavelet transformation, SG smoothing, multivariate scattering correction, standard normal transformation, trend correction, and sliding smoothing filtering are used to preprocess the collected raw spectral data.

[0010] As an improvement of the above technical solution, the specific steps of S5 include: (1) The SPXY algorithm is used to randomly divide the samples into training sets and validation sets; (2) Establish a regression model based on deep learning; (3) The spectral features of the preprocessed training set are automatically extracted through a 6-layer convolutional neural network. On this basis, the Self-Attention mechanism based on the Transformer network architecture and the feedforward neural network are introduced to build a model to enhance the depth and breadth of feature representation. The Self-Attention module in the Transformer network performs different linear transformations on the feature maps output by the convolutional layer to generate trainable Query (Q), Key (K) and Value (V) matrices. By calculating the dot product of K and Q, the model can capture the dependencies between channels in the spectral data and generate attention scores through scaling factors. These scores are used to perform weighted summation on the V matrix and normalize it through the Softmax layer. Finally, a weighted feature representation is output. This representation can reflect the relative importance of different spectral channels and is particularly helpful in identifying the key features of protein content and moisture content in near-infrared spectral data. Protein content ; ; Next, the feedforward neural network layer performs nonlinear transformation and feature abstraction on the weighted feature representation to enhance the model's ability to recognize complex patterns, and finally outputs predicted values ​​corresponding to the protein content and moisture content in the plant base.

[0011] As an improvement of the above technical solution, in S6, the back propagation algorithm includes The error Loss is calculated by the mean square error loss function, and the Adam optimizer is used to update the model weights; Select the evaluation index determination coefficient R 2It indicates the overall fitting effect of the model. The root mean square error (RMSE) is used to intuitively display the accuracy of the model. The final detection model is obtained after multiple verifications and optimizations of the verification set. Coefficient of determination R 2 >0.9 and root mean square error RMSE<0.1, the model meets the requirements and can be used for rapid detection of protein content and moisture content of plant-based products.

[0012] As an improvement of the above technical solution, in S7, under the environment of 26°C and relative humidity of 45%, the near-infrared spectrometer scanned an average of 8 times and the mode width was 8.2; spectral data of each sample was collected once at three different positions, and the average value was taken as the original spectral data of the sample.

[0013] Specifically, the plant-based product is a finished or semi-finished meat substitute produced mainly from soy protein as raw material.

[0014] In order to solve the above problems, the present invention also provides a rapid detection model for protein content and moisture content in plant-based products. The model is obtained based on the rapid detection method for protein content and moisture content in plant-based products.

[0015] In order to solve the above problems, the present invention also provides a rapid detection system for protein content and moisture content in plant-based products, comprising: A sample raw data acquisition unit, which is used to obtain the raw near-infrared spectrum data, moisture content and protein content of the sample at different times, and establish a database; A data preprocessing unit, which is used to preprocess and extract features from the acquired raw near-infrared spectral data, and divide it into a training set and a validation set; The deep learning model building unit uses a convolutional neural network to introduce a self-attention mechanism based on the Transformer network architecture and a feedforward neural network to build a model, fits the near-infrared spectral data and protein content data of the training set samples, and establishes a deep learning model I for protein content in plant-based materials; fits the near-infrared spectral data and moisture content data of the training set samples, and establishes a deep learning model II for detecting moisture content in plant-based materials; The model verification and optimization unit is used to minimize the loss function through the back-propagation algorithm, reversely update the weight parameters of Model I and Model II, and use the verification set to verify and optimize the hyperparameters of the model to improve the accuracy and robustness of the model. After multiple verifications and optimizations, the final detection model is obtained; The sample rapid detection unit obtains the original spectral data of the sample to be tested, inputs the original spectral data into the deep learning models I and II of the protein content and moisture content in the plant base, and outputs the predicted values ​​of the protein content and moisture content in the plant base.

[0016] In order to solve the above-mentioned problem, the present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method for rapid detection of protein content and moisture content in plant-based products are implemented.

[0017] As an improvement of the above technical solution, the electronic device includes a 3D printed shell and a spectrometer and a tablet computer installed therein and connected to the computer via a USB conversion line interface. The tablet computer is implanted with the deep learning models I and II of the protein content and moisture content in the plant-based product, and the detection function is developed and the UI interface is designed based on Python and PyQt5, forming a portable, efficient, non-destructive electronic device for rapid detection of protein content and moisture content in plant-based products.

[0018] In order to solve the above problems, the present invention also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the steps of the method for rapid detection of protein content and moisture content in plant-based products.

[0019] The beneficial effects brought by the present invention are: The present invention establishes a detection method and system for rapidly detecting protein content and moisture content in plant-based materials based on near-infrared spectroscopy and deep learning. Firstly, the moisture content of the samples at different times and the protein content in the corresponding states and their corresponding near-infrared raw spectral data are collected. After preprocessing, the samples are randomly divided into a training set and a validation set. The spectral features of the training set are automatically extracted through a convolutional neural network, and the Self-Attention mechanism and feedforward neural network based on the Transformer network architecture are introduced. The Self-Attention block performs different linear transformations on the output feature map of the convolutional layer to obtain three matrices Q, K, and V. The attention score is obtained by calculating the dot product of K and Q to capture the dependency between the channels in the spectral data. These scores are used to perform weighted summation on the V matrix, and finally output a weighted feature representation. This representation can reflect the relative importance of different spectral channels, and is particularly helpful in identifying the key features of protein content and moisture content in near-infrared spectral data. The weighted feature representation is subjected to nonlinear transformation and feature abstraction processing through the feedforward neural network layer, and the predicted value is output. The loss function is minimized by the back-propagation algorithm, and the final detection model is obtained through continuous iteration and optimization, which can be used for the rapid detection of protein content and moisture content of plant-based products.

[0020] The final detection model combines a 3D printed shell, a spectrometer, a USB conversion cable and a tablet computer. Through integrated design and development, it can form a portable, non-destructive and efficient detection device. It can realize the rapid and accurate detection of the protein content and moisture content of plant-based products, and provide a portable, fast and efficient solution for research and practical applications in related fields. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments: Figure 1 It is a flow chart of the method for detecting the protein content and moisture content in the plant base of the present invention; Figure 2 is a schematic diagram of the original spectrum images of 480 samples in Example 1; Figure 3 is a schematic diagram of the distribution of protein content and moisture content of 480 samples in Example 1; Figure 4 It is a convolutional neural network structure diagram of the present invention; Figure 5 It is the Self-Attrntion network structure diagram of the present invention; Figure 6 is a scatter plot of the national standard detection value of protein content and the detection model prediction value of the plant-based samples in the training set and the validation set in Example 1; Figure 7 is a scatter plot of the national standard test value of moisture content of plant-based samples in the training set and the validation set and the predicted value of the test model in Example 1; Figure 8 It is a structural diagram of the portable detection device of the present invention. DETAILED DESCRIPTION

[0022] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0023] like Figure 1 As shown, the present invention provides a method for rapid detection of protein content and moisture content in plant-based materials, comprising: S1 Soak plant-based samples from different production batches in water until the moisture content is uniform; S2 placed the plant-based samples with uniform moisture content in a 70°C oven to dry, took them out every hour, weighed them, and collected the original near-infrared spectral data of the samples; S3 weighs the completely dried plant-based samples, detects their protein content according to the national standard method, calculates the moisture content and protein content of the samples at different times as the true value, and establishes a database corresponding to the original spectral data measured by S2; S4 preprocesses and extracts features from the collected raw near-infrared spectral data and randomly divides them into training sets and validation sets; S5 uses convolutional neural networks and introduces the Self-Attention mechanism based on the Transformer network architecture and feedforward neural networks to build a deep learning model. Based on the near-infrared spectral data and protein content data of the training set samples, Model I for detecting the protein content in plant-based materials is established; based on the near-infrared spectral data and moisture content data of the training set samples, Model II for detecting the moisture content in plant-based materials is established; S6 minimizes the loss function through the back propagation algorithm and updates the weight parameters in reverse. After multiple iterations and optimizations, two models with different weight parameters are finally obtained. The accuracy and robustness of the two models are verified based on the near-infrared spectral data, protein content data, and moisture content data of the validation set samples. 2 >0.9, root mean square error RMSE<0.1. This model can be used for rapid detection of protein content and moisture content in plant-based products.

[0024] Specifically, the back propagation algorithm includes (1) Calculate the error Loss through the mean square error loss function, and use the Adam optimizer to update the model weight W; ; ; (2) Select the evaluation index determination coefficient R 2 It indicates the overall fitting effect of the model. The root mean square error (RMSE) is used to intuitively display the accuracy of the model. The final detection model is obtained after multiple verifications and optimizations of the verification set. <0.1 >0.9 Coefficient of determination R 2 >0.9 and root mean square error RMSE<0.1, the model meets the requirements and can be used for rapid detection of protein content and moisture content of plant-based products.

[0025] S7 combines 3D printed housing 3, spectrometer 1, USB conversion cable 4 and tablet computer 2, and is designed and developed in an integrated manner to form a portable, non-destructive and efficient detection device. The final detection model implanted in S6 realizes rapid, accurate and portable detection of protein content and moisture content of plant-based products; Prepare the plant-based samples to be tested, soak them in water, and then put them in a 70°C oven for drying; The samples were taken out and weighed every hour, and the original spectral data were measured; The original spectral data is input into the final detection model, and the output result is the predicted value of protein content and moisture content of plant-based products.

[0026] Example 1 This example provides a preparation of a plant-based sample and a method for determining its protein content, moisture content and corresponding near-infrared spectral data, specifically including: Six plant-based products from different production batches were selected, and the complete plant-based products were evenly cut into 8 small pieces, each about 5 cm long and 3 cm wide, for a total of 48 small samples. All samples were soaked in water for 15 hours, then taken out, the surface moisture was wiped off, and they were numbered and kept aside.

[0027] Place the 48 numbered samples in a 70℃ drying oven for drying. Take them out every 1 hour and cool them in a dryer for 20 minutes. Weigh and record. Preheat the spectrometer for 15 minutes. Set the mode width to 8.2 and the average number of scans to 8. Scan the samples at 26℃ and 45% relative humidity. Scan each sample three times at three different locations and take the average as the original spectral data. Figure 2 shown.

[0028] The operation was repeated more than 10 times, and a total of 480 sets of near-infrared spectral data of 10 batches of samples at different times were collected. The 48 samples were completely dried and weighed, and the protein content in the samples was determined according to the combustion method in GB5009.5-2010. The moisture content and protein content of samples from different batches were calculated as the true value. The specific calculation formula is:

[0029]

[0030] Where W 水 Indicates moisture content, P 湿 Indicates the protein content in the water-containing state, P 干 It represents the protein content in the dry state, m1 represents the weight of the sample, and m2 represents the weight of the sample after drying.

[0031] The moisture content of samples in different scanning batches and their corresponding protein content are matched one by one with their near-infrared spectral data to establish a database.

[0032] The statistical results of protein content and moisture content in 480 plant-based products are shown in Tables 1 and Figure 3As shown, there are significant differences between different plant-based products, providing a benchmark for measuring the protein and moisture content levels of plant-based products.

[0033] Table 1 Protein content and moisture content of plant-based products

[0034] Example 2 This embodiment is used to preprocess the near infrared spectrum data collected in Example 1, extract features, and establish a deep learning model. The specific process includes: The collected raw spectral data were preprocessed using multivariate scattering correction and wavelet transform, and the database samples were divided into training set and validation set according to the ratio of 7:3 using SPXY algorithm, including 336 samples in the training set and 144 samples in the validation set.

[0035] First, the spectral data is added to the channel dimension to make it a data structure with a three-dimensional shape (batch size, features, channels). The three-dimensional processing method can capture more local and global feature information of the spectrum and enhance the ability of subsequent models to express complex spectral data. The six-layer convolutional neural network is used to automatically extract the spectral features of the training set, such as Figure 4 As shown in the figure, each layer is composed of two convolutional layers working together to slide the convolution kernel on the feature dimension and perform dot product operations to mine the intrinsic characteristics of spectral data. In addition, the ReLU activation function is used to enhance the nonlinear expression ability of the model, so that the network can capture more complex data patterns. The maximum pooling layer (Maxpooling) is used for downsampling to reduce computational complexity and capture key feature information. The Dropout layer is used as a regularization technique to prevent overfitting by randomly discarding some network connections, thereby enhancing the generalization ability of the model.

[0036] This example introduces a self-attention mechanism based on the Transformer network architecture into the model. Figure 5 As shown in Figure 2, the self-attention mechanism can capture long-range dependencies in the input data. The self-attention mechanism enables the model to dynamically allocate attention to important spectral regions by calculating the correlation between input features. This feature is particularly suitable for near-infrared spectral data because its high-dimensional features usually contain a lot of redundant information and noise, which can easily lead to overfitting of the model and inaccurate feature extraction.

[0037] First, the feature map output by the convolutional layer is feature mapped to generate query (Q), key (K), and value (V) matrices. The Q matrix represents the query of the current input feature, the K matrix provides the correlation between features, and the V matrix contains the value information of the feature. By calculating the dot product of Q and K, the model can identify the most critical spectral features when predicting targets (such as protein content and moisture content), which enables the model to effectively suppress noise interference and adaptively focus on spectral regions that are highly correlated with target attributes.

[0038] Subsequently, the V matrix is ​​weighted and summed according to the attention score to generate a weighted spectral feature representation, which reflects the relative importance of different spectral channels and helps to identify the key features of protein content and moisture content in near-infrared spectral data. Through this mechanism, the model can effectively capture the dependencies between channels in spectral data and ultimately improve the accuracy of prediction.

[0039] Finally, the feature representation is normalized using the Softmax function to ensure that the sum of the weights of all features is 1. This normalized feature representation will be used as the input to the feedforward neural network layer, which is responsible for further nonlinear transformation and feature abstraction of the features and ultimately outputs the predicted value. Throughout the training process, the model continuously optimizes and updates the weight parameters through the back propagation algorithm to minimize the loss. This series of steps ensures that the model can accurately extract and utilize key features when faced with complex spectral data, thereby achieving efficient protein content and moisture content prediction.

[0040] The spectral data of the validation set samples and the corresponding protein content and moisture content data were used to verify the accuracy and stability of the two models. Through continuous verification and optimization, if the determination coefficient R 2 >0.9, RMSE<0.1, the marker model is reliable and effective, has generalization and robustness, and can be used to predict protein content and moisture content in plants and products. The relevant parameters of the model are shown in Table 2.

[0041] Table 2 Model related parameters

[0042] like Figure 6 As shown, the determination coefficient R of the predicted and detected values ​​of the protein content of the training set samples 2 The root mean square error (rmse) was 0.9713, the root mean square error (rmse) was 0.0140, and the determination coefficient R 2 The value is 0.9829, and the root mean square error RMSE is 0.0136.

[0043] like Figure 7 As shown, the prediction value and determination coefficient of the moisture content test value of the training set samples R 2is 0.9694, the root mean square error RMSE is 0.0188, and the determination coefficient R 2 The value is 0.9721, and the root mean square error RMSE is 0.0172.

[0044] The deep learning model constructed in this embodiment innovatively combines the feature processing capabilities of convolutional neural networks (CNNs) and the Self-Attention module based on the Transformer architecture, as well as the efficient learning capabilities of feedforward neural networks. This model first expands the two-dimensional near-infrared spectral data into three dimensions, fully considering the complex relationship between spectral wavelengths and the high-dimensional characteristics of the data. Through the combination of CNN and the attention mechanism, the model can effectively optimize the feature extraction and dimensionality reduction of spectral data, thereby establishing a more accurate prediction model. During the training process, the back-propagation algorithm is used to continuously optimize the weight parameters of the protein content model and the moisture content model in plant-based products, which significantly improves the prediction accuracy.

[0045] The verification results show that the model performs well on the verification set, with the coefficient of determination (R²) exceeding 0.97, showing extremely high reliability. Compared with traditional machine learning models, this model not only automatically completes the training process and eliminates the complex feature extraction process, but also achieves a significant improvement in prediction accuracy, far exceeding existing traditional algorithms.

[0046] Example 3 This embodiment is used to provide a system for rapid detection of protein content and moisture content in plant-based products. This system is used to implement the method for rapid detection of protein content and moisture content in plant-based products described herein, which includes: A sample raw data acquisition unit, which is used to obtain the raw near-infrared spectrum data, moisture content and protein content of the sample at different times, and establish a database; A data preprocessing unit, which is used to preprocess and extract features from the acquired raw near-infrared spectral data, and divide it into a training set and a validation set; The deep learning model building unit uses a convolutional neural network to introduce a self-attention mechanism based on the Transformer network architecture and a feedforward neural network to build a model, fits the near-infrared spectral data and protein content data of the training set samples, and establishes a deep learning model I for protein content in plant-based materials; fits the near-infrared spectral data and moisture content data of the training set samples, and establishes a deep learning model II for detecting moisture content in plant-based materials; The model verification and optimization unit is used to minimize the loss function through the back-propagation algorithm, reversely update the weight parameters of Model I and Model II, and use the verification set to verify and optimize the hyperparameters of the model to improve the accuracy and robustness of the model. After multiple verifications and optimizations, the final detection model is obtained; The sample rapid detection unit obtains the original spectral data of the sample to be tested, inputs the original spectral data into the deep learning models I and II of the protein content and moisture content in the plant base, and outputs the predicted values ​​of the protein content and moisture content in the plant base.

[0047] For details not provided in this embodiment, please refer to the previous description.

[0048] Example 4 This embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method for rapid detection of protein content and moisture content in plant-based products are implemented.

[0049] Reference Figure 8 The electronic device includes a 3D printed shell 3 and a spectrometer 1 and a tablet computer 2 installed therein and connected to each other through a USB conversion line interface 4. The tablet computer 2 is implanted with the deep learning models I and II of the protein content and moisture content in the plant-based product, and the detection function is developed and the UI interface is designed based on Python and PyQt5, forming a portable, efficient, non-destructive electronic device for rapid detection of protein content and moisture content in plant-based products.

[0050] Example 5 The present embodiment provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for rapid detection of protein content and moisture content in plant-based products are implemented.

[0051] It should be noted that the above is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, it is still possible for those skilled in the art to modify the technical solutions described in the aforementioned embodiments or to make equivalent substitutions for some of the technical features therein. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for rapid detection of protein content and moisture content in plant-based products, characterized in that: include S1 Soak plant-based samples from different production batches in water to ensure that the moisture content of the samples is uniform; S2 puts the fully soaked sample into an oven for drying, takes it out every hour, weighs it and collects its original near-infrared spectrum data, and weighs and records it again after the sample is completely dried; S3 weighs the completely dried plant-based samples, measures the moisture content of the samples at different times and the protein content after drying according to the national standard method, and converts them into protein content under different conditions, thereby establishing a database to ensure that it corresponds to the original spectral data measured in S2; S4 preprocesses the collected raw near-infrared spectral data and randomly divides them into a training set and a validation set; S5 uses a convolutional neural network to introduce a self-attention mechanism based on the Transformer network architecture and a feedforward neural network to build a deep learning model. It fits the near-infrared spectral data and protein content data of the training set samples to establish a deep learning model I for detecting protein content in plant-based materials. It also fits the near-infrared spectral data and moisture content data of the training set samples to establish a deep learning model II for detecting moisture content in plant-based materials. S6 minimizes the loss function through the back-propagation algorithm, reversely updates the weight parameters of Model I and Model II, and uses the validation set in S4 to verify and optimize the hyperparameters of the model to improve the accuracy and robustness of the model. After multiple verifications and optimizations, the final detection model is obtained; If the coefficient of determination R 2 >0.9, root mean square error RMSE<0.1, the model meets the requirements and can be used for rapid detection of protein content and moisture content of plant-based products; S7 prepares the plant-based sample to be tested, fully soaks it in water, and then puts it in a 70°C oven for drying; The samples were taken out and weighed every hour, and the original spectral data were measured; The original spectral data is input into the S6 final detection model, and the output result is the predicted value of protein content and moisture content of plant-based products.

2. The method for rapid detection of protein content and moisture content in plant-based products according to claim 1, characterized in that: In S2, the sample is scanned at three different positions, and the average value is taken as the original spectral data of the sample; in order to ensure the accuracy and robustness of the model, at least 300 sets of spectral data are collected; wherein the scanning range of the near-infrared spectrometer is 10000~6250cm -1 .

3. The method for rapid detection of protein content and moisture content in plant-based products according to claim 1, characterized in that: In S3, the sample is completely dried in an oven at 70°C and then weighed. The protein content in the sample is determined according to the combustion method in GB5009.5-2010. The moisture content at different times is calculated by the weight difference of the sample before and after drying. The protein content at different times is calculated by the unchanged total amount of protein in the sample before and after drying, and the results are matched one by one with the original spectral data.

4. The method for rapid detection of protein content and moisture content in plant-based products according to claim 1, characterized in that: In S4, the collected raw spectral data are preprocessed by using one or more methods selected from the group consisting of first-order difference, second-order difference, wavelet transformation, SG smoothing, multivariate scattering correction, standard normal transformation, trend correction, and sliding smoothing filtering.

5. The method for rapid detection of protein content and moisture content in plant-based products according to claim 1, characterized in that: S5 specific steps include: The SPXY algorithm was used to randomly divide the samples into training and validation sets; Build a regression model based on deep learning; The spectral features of the preprocessed training set are automatically extracted through a 6-layer convolutional neural network. On this basis, the Self-Attention mechanism based on the Transformer network architecture and the feedforward neural network are introduced to build a model to enhance the depth and breadth of feature representation; the Self-Attention module in the Transformer network performs different linear transformations on the feature maps output by the convolution layer to generate trainable Query (Q), Key (K) and Value (V) matrices. By calculating the dot product of K and Q, the model can capture the dependencies between channels in the spectral data and generate attention scores through scaling factors. These scores are used to perform weighted summation on the V matrix and normalize it through the Softmax layer. Finally, a weighted feature representation is output. This representation can reflect the relative importance of different spectral channels and is particularly helpful in identifying key features of protein content and moisture content in near-infrared spectral data. Next, the feedforward neural network layer performs nonlinear transformation and feature abstraction on the weighted feature representation to enhance the model's ability to recognize complex patterns, and finally outputs predicted values ​​corresponding to the protein content and moisture content in the plant base.

6. The method for rapid detection of protein content and moisture content in plant-based products according to claim 1, characterized in that: In S6, the back propagation algorithm includes The error Loss is calculated by the mean square error loss function, and the Adam optimizer is used to update the model weights; Select the evaluation index determination coefficient R 2 It indicates the overall fitting effect of the model. The root mean square error (RMSE) is used to intuitively display the accuracy of the model. The final detection model is obtained after multiple verifications and optimizations of the verification set. Coefficient of determination R 2 >0.9 and root mean square error RMSE<0.1, the model meets the requirements and can be used for rapid detection of protein content and moisture content of plant-based products.

7. The method for rapid detection of protein content and moisture content in plant-based products according to claim 1, characterized in that: In S7, at 26°C and 45% relative humidity, the near-infrared spectrometer scanned an average of 8 times with a mode width of 8.

2. Spectral data was collected once for each sample at three different positions, and the average value was taken as the original spectral data of the sample.

8. A rapid detection system for protein content and moisture content in plant-based products, characterized by: The system is used to implement the method for rapid detection of protein content and moisture content according to any one of claims 1 to 7, comprising: A sample raw data acquisition unit, which is used to obtain the raw near-infrared spectrum data, moisture content and protein content of the sample at different times, and establish a database; A data preprocessing unit, which is used to preprocess and extract features from the acquired raw near-infrared spectral data, and divide it into a training set and a validation set; The deep learning model building unit uses a convolutional neural network to introduce a self-attention mechanism based on the Transformer network architecture and a feedforward neural network to build a model, fits the near-infrared spectral data and protein content data of the training set samples, and establishes a deep learning model I for protein content in plant-based materials; fits the near-infrared spectral data and moisture content data of the training set samples, and establishes a deep learning model II for detecting moisture content in plant-based materials; The model verification and optimization unit is used to minimize the loss function through the back-propagation algorithm, reversely update the weight parameters of Model I and Model II, and use the verification set to verify and optimize the hyperparameters of the model to improve the accuracy and robustness of the model. After multiple verifications and optimizations, the final detection model is obtained; The sample rapid detection unit obtains the original spectral data of the sample to be tested, inputs the original spectral data into the deep learning models I and II of the protein content and moisture content in the plant base, and outputs the predicted values ​​of the protein content and moisture content in the plant base.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the method for rapid detection of protein content and moisture content in plant-based products according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method for rapid detection of protein content and moisture content in plant-based products according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Fabric fiber component qualitative method based on self-attention

    CN114112984A

  • Rapid detection method for mycelium protein content

    CN117368146A

  • A computer-implemented method of predicting quality of a food product sample

    GB202118033D0

Cited By

  • Automatic grading control system and method for royal jelly

    CN120146698A

  • Pumpkin sugar degree efficient detection method and system for enhancing multitask deep attention network collaborative near infrared spectrum

    CN120385642A

  • Industrial online detection method and system based on near infrared spectrum and medium

    CN120807489A

  • Automatic monitoring and management method and system for high-humidity process vegetable protein meat processing

    CN120951052A

  • Method and system for automated monitoring and management of high-moisture vegetable protein meat processing

    CN120951052B