Rapid detection method and system for protein content and moisture content in plant-based products based on near-infrared spectroscopy and deep learning
By combining near-infrared spectroscopy and deep learning models with the Self-Attention mechanism of convolutional neural networks and Transformer network architecture, the problems of time-consuming and expensive equipment in traditional detection methods are solved, enabling rapid, accurate, and non-destructive detection of protein content and moisture content in plant-based products.
Patent Information
- Application Number
- CN202411720899.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2044-11-28
AI Technical Summary
Existing technologies are insufficient for the rapid, portable, and non-destructive testing of protein content and moisture content in plant-based products. Traditional methods are time-consuming, require expensive equipment, and pollute the environment.
By combining near-infrared spectroscopy with a deep learning model, and using the self-attention mechanism of convolutional neural networks and Transformer network architecture, a deep learning model for protein content and water content was established, and the detection was performed using a portable device.
This invention enables rapid, accurate, and non-destructive testing of protein content and moisture content in plant-based products, providing a portable and efficient testing method and system.
Smart Images

Figure CN119643500B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of nondestructive testing, and in particular to a rapid method and system for detecting protein content and moisture content in plant-based products. Background Technology
[0002] With increasing global focus on sustainable food sources and animal welfare, soy protein has garnered significant attention due to its rich protein content, nutritional value, and environmental friendliness. As a sustainable food source, the application of soy protein plays a crucial role in reducing the resource dependence of traditional livestock farming, lowering greenhouse gas emissions, and improving the safety of food models. Plant-based products, often made from soy protein and pea protein, are rich in high-quality protein and can be used to produce meat substitutes, effectively alleviating the global protein shortage while injecting new vitality into the diversification and innovation of the food industry. However, as these products become more widespread in the market, ensuring their quality and safety becomes paramount.
[0003] Traditional detection methods, such as the Kjeldahl nitrogen determination method, Dumas combustion method, spectrophotometry, and drying method, while providing reliable results, suffer from numerous inconveniences, including time consumption, expensive equipment, reliance on chemical reagents, and environmental pollution. These factors prevent them from meeting the need for rapid, non-destructive, and portable detection of protein and moisture content in plant-based materials. Near-infrared spectroscopy (NIRS) is favored due to its portability, speed, non-destructive nature, low cost, and real-time detection capabilities, meeting the urgent needs of the food production sector and finding widespread application in traditional food component analysis. Deep learning (DL) has wide applications, enabling more complex and robust models. By automatically extracting complex spectral features, it can process large amounts of unstructured, high-dimensional spectral data and extract useful information. This capability allows deep learning to handle the challenges of complex samples or unknown substances in spectral analysis. Combining deep learning with NIRS further enhances its application. Summary of the Invention
[0004] To address the problems of existing methods for detecting protein content and moisture in plant-based products, such as requiring expensive instruments, complex and inconvenient operation, and the use of chemical reagents, this invention provides a rapid detection method and system for 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 as follows:
[0006] Rapid detection methods for protein content and moisture content in plant-based products include:
[0007] S1 involves thoroughly immersing plant-based samples from different production batches in water to ensure that the sample moisture content is uniform.
[0008] S2 The fully soaked sample is placed in a 70°C oven for drying. It is taken out every 1 hour, weighed and its original near-infrared spectral data is collected until the sample is completely dried and then weighed and recorded again.
[0009] S3 Weigh the completely dried plant-based sample, determine the moisture content and protein content of the sample at different times according to the national standard method, and convert them into protein content under different conditions to establish a database to ensure that it corresponds to the original spectral data measured in S2.
[0010] S4 preprocesses the acquired raw near-infrared spectral data and randomly divides it into training and validation sets.
[0011] S5 uses a convolutional neural network, introduces 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 substrate; it fits the near-infrared spectral data and water content data of the training set samples to establish a deep learning model II for detecting water content in plant substrate.
[0012] S6 minimizes the loss function through the backpropagation algorithm, updates the weight parameters of Model I and Model II in reverse, and uses the validation set in S4 to validate and optimize the hyperparameters of the model to improve the accuracy and robustness of the model. After multiple validations and optimizations, the final detection model is obtained.
[0013] If the coefficient of determination R 2 >0.9, RMSE<0.1, the model meets the requirements and can be used for rapid detection of protein content and moisture content in plant-based products;
[0014] S7 prepares the plant-based sample to be tested, soaks it thoroughly in water, and then dries it in an oven at 70°C.
[0015] Every hour, the sample was removed, weighed, and the raw spectral data was measured.
[0016] Inputting the raw spectral data into the final detection model of S6 will output the predicted values of protein content and moisture content of plant-based products.
[0017] As an improvement to the above technical solution, in S1, the sample soaking time is not less than 10 hours to ensure that its moisture content reaches a uniform state.
[0018] As an improvement to the above technical solution, in S2, the extracted sample is spectrally scanned at three different locations, and the average value is taken as the original spectral data of the sample; 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 .
[0019] As an improvement to the above technical solution, in S3, after the sample is completely dried in an oven at 70℃, it is weighed and the protein content in the sample is determined by the combustion method in GB5009.5—2010. The moisture content at different times is calculated by the difference in sample weight before and after drying, and the protein content at different times is calculated by the fact that the total protein content of the sample remains unchanged before and after drying, and is matched one by one with the original spectral data.
[0020] As an improvement to the above technical solution, in S4, one or more of the following methods are used to preprocess the acquired raw spectral data: first-order difference, second-order difference, wavelet transform, SG smoothing, multivariate scattering correction, standard normal transform, trend correction, and sliding smoothing filter.
[0021] As an improvement to the above technical solution, the specific steps of S5 include:
[0022] (1) The SPXY algorithm is used to randomly divide the samples into training set and validation set;
[0023] (2) Establish a regression model based on deep learning;
[0024] (3) The spectral features of the preprocessed training set are automatically extracted by a 6-layer convolutional neural network. On this basis, a Self-Attention mechanism based on the Transformer network architecture and a feedforward neural network are introduced to build a model to enhance the depth and breadth of the feature representation. The Self-Attention module in the Transformer network performs different linear transformations on the feature map 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 normalization is achieved through the Softmax layer. Finally, a weighted feature representation is output. This representation can reflect the relative importance between different spectral channels, which is especially helpful in identifying the key features of protein content and water content in near-infrared spectral data.
[0025] Protein content ;
[0026] ;
[0027] 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 water content in the plant substrate.
[0028] As an improvement to the above technical solution, in S6, the backpropagation algorithm includes
[0029] The error loss is calculated using the mean squared loss function, and the model weights are updated using the Adam optimizer.
[0030] Select the evaluation index, coefficient of determination R. 2 The root mean square error (RMSE) represents the overall fitting effect of the model. It is used to visually demonstrate the accuracy of the model. The final detection model is obtained after multiple validations and optimizations on the validation set.
[0031] Coefficient of determination R 2 When the mean square error (RMSE) is greater than 0.9 and the root mean square error (RMSE) is less than 0.1, the model meets the requirements and can be used for the rapid detection of protein content and moisture content in plant-based products.
[0032] As an improvement to the above technical solution, in S7, under an environment of 26℃ and 45% relative humidity, the near-infrared spectrometer performs an average of 8 scans and has a mode width of 8.2; spectral data for each sample is collected once at three different locations, and the average value is taken as the original spectral data of the sample.
[0033] Specifically, the plant-based products are mainly meat substitutes or semi-finished products made from soy protein.
[0034] 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 being obtained based on the rapid detection method for protein content and moisture content in plant-based products.
[0035] To address the aforementioned problems, this invention also provides a rapid detection system for protein content and moisture content in plant-based products, comprising:
[0036] The raw sample data acquisition unit is used to acquire raw near-infrared spectral data, water content, and protein content of the sample at different times and to establish a database.
[0037] The data preprocessing unit is used to preprocess and extract features from the acquired raw near-infrared spectral data, and divide it into training and validation sets.
[0038] The deep learning model building unit uses a convolutional neural network, introduces a Self-Attention mechanism based on the Transformer network architecture and a feedforward neural network to build a 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 protein content in plant substrate; and fits the near-infrared spectral data and water content data of the training set samples to establish a deep learning model II for detecting water content in plant substrate.
[0039] The model validation and optimization unit is used to minimize the loss function through the backpropagation algorithm, update the weight parameters of Model I and Model II in reverse, and use the validation set to validate and optimize the hyperparameters of the model to improve the accuracy and robustness of the model. After multiple validations and optimizations, the final detection model is obtained.
[0040] The rapid sample detection unit acquires the raw spectral data of the sample to be tested, inputs the raw spectral data into the deep learning models I and II for protein content and water content in the plant substrate, and outputs the predicted values of protein content and water content in the plant substrate.
[0041] In order to solve the above problems, the present invention also 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, it implements the steps of a rapid detection method for protein content and moisture content in the plant-based product.
[0042] As an improvement to the above technical solution, the electronic device includes a 3D printed shell and a spectrometer and a tablet computer installed therein and connected via a USB conversion cable interface. The tablet computer is equipped with deep learning models I and II for protein content and moisture content in plant-based products. The detection function and UI interface are developed based on Python and PyQt5, forming a portable, efficient, and non-destructive electronic device for rapid detection of protein content and moisture content in plant-based products.
[0043] In order to solve the above problems, the present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the rapid detection method for protein content and moisture content in the plant-based product.
[0044] The beneficial effects of this invention are as follows:
[0045] This invention establishes a rapid detection method and system for detecting protein content and water content in plant-based materials based on near-infrared spectroscopy and deep learning. First, the moisture content and protein content of samples at different times and corresponding states, along with their corresponding near-infrared raw spectral data, were collected. After preprocessing, the samples were randomly divided into training and validation sets. Spectral features of the training set were automatically extracted using a convolutional neural network. A Self-Attention mechanism based on a Transformer network architecture and a feedforward neural network were introduced. The Self-Attention block performed different linear transformations on the output feature map of the convolutional layer to obtain three matrices: Q, K, and V. Attention scores were obtained by calculating the dot product of K and Q, capturing the dependencies between channels in the spectral data. These scores were used to perform a weighted summation of the V matrix, ultimately outputting a weighted feature representation. This representation reflects the relative importance between different spectral channels, and is particularly helpful in identifying key features of protein content and moisture content in near-infrared spectral data. The feedforward neural network layer performed nonlinear transformations and feature abstraction on this weighted feature representation, outputting predicted values. The loss function was minimized through backpropagation, and the model was iterated and optimized to obtain the final detection model, which can be used for the rapid detection of protein content and moisture content in plant-based products.
[0046] The final testing model combines a 3D-printed shell, a spectrometer, a USB adapter cable, and a tablet computer. Through integrated design and development, it forms a portable, non-destructive, and highly efficient testing device. It can achieve rapid and accurate detection of protein content and moisture content in plant-based products, providing a portable, fast, and efficient solution for research and practical applications in related fields. Attached Figure Description
[0047] The present invention will be further described below with reference to the accompanying drawings and specific embodiments:
[0048] Figure 1 This is a flowchart of the method for detecting protein content and moisture content in plant-based materials according to the present invention;
[0049] Figure 2 This is a schematic diagram of the original spectral images of the 480 samples in Example 1;
[0050] Figure 3 This is a schematic diagram showing the protein content and water content distribution of 480 samples in Example 1;
[0051] Figure 4 This is a diagram of the convolutional neural network structure of the present invention;
[0052] Figure 5 This is a diagram of the Self-Attention network structure of the present invention;
[0053] Figure 6This is a scatter plot of the national standard detection values and detection model prediction values of protein content in plant-based samples from the training and validation sets in Example 1;
[0054] Figure 7 This is a scatter plot of the national standard detection values and detection model prediction values of moisture content of plant-based samples in the training and validation sets in Example 1;
[0055] Figure 8 This is a structural diagram of the portable testing device of the present invention. Detailed Implementation
[0056] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0057] like Figure 1 As shown, this invention provides a rapid detection method for protein content and water content in plant-based materials, comprising:
[0058] S1 involves thoroughly soaking plant-based samples from different production batches in water to achieve a uniform moisture content.
[0059] S2. Plant-based samples with uniform moisture content were dried in a 70°C oven. The samples were taken out every hour, weighed, and the raw near-infrared spectral data were collected.
[0060] S3 Weigh the completely dried plant-based sample, test its protein content according to the national standard method, calculate the moisture content and protein content of the sample at different times as the true value, and establish a database corresponding to the original spectral data measured in S2.
[0061] S4 preprocesses and extracts features from the collected raw near-infrared spectral data, and randomly divides it into training and validation sets;
[0062] S5 utilizes convolutional neural networks and introduces a Self-Attention mechanism based on the Transformer network architecture and a feedforward neural network to construct a deep learning model. Based on the near-infrared spectral data and protein content data of the training set samples, Model I is established to detect the protein content in the plant substrate; based on the near-infrared spectral data and water content data of the training set samples, Model II is established to detect the water content in the plant substrate.
[0063] S6 minimizes the loss function using the backpropagation algorithm, updates the weight parameters in reverse, and after multiple iterations and optimizations, finally obtains two models with different weight parameters. The accuracy and robustness of the two models are verified using near-infrared spectral data, protein content data, and water content data of the validation set samples. If the validated model has R... 2 With a mean square error (RMSE) >0.9 and a root mean square error (RMSE) <0.1, this model can be used for the rapid detection of protein content and moisture content in plant-based products.
[0064] Specifically, the backpropagation algorithm includes
[0065] (1) The error Loss is calculated using the mean squared error loss function, and the Adam optimizer is used to update the model weights W;
[0066] ;
[0067] ;
[0068] (2) Select the evaluation index, the coefficient of determination R 2 The root mean square error (RMSE) represents the overall fitting effect of the model. It is used to visually demonstrate the accuracy of the model. The final detection model is obtained after multiple validations and optimizations on the validation set.
[0069] <0.1
[0070] >0.9
[0071] Coefficient of determination R 2 When the mean square error (RMSE) is greater than 0.9 and the root mean square error (RMSE) is less than 0.1, the model meets the requirements and can be used for the rapid detection of protein content and moisture content in plant-based products.
[0072] The S7 combines a 3D-printed shell 3, a spectrometer 1, a USB conversion cable 4, and a tablet computer 2. Through integrated design and development, it forms a portable, non-destructive, and efficient detection device. The final detection model embedded in the S6 enables rapid, accurate, and portable detection of protein content and moisture content in plant-based products.
[0073] Prepare the plant-based sample to be tested, soak it thoroughly in water, and then dry it in an oven at 70°C.
[0074] Every hour, the sample was removed, weighed, and the raw spectral data was measured.
[0075] The raw spectral data is input into the final detection model, and the output results are the predicted values of protein content and water content of plant-based products.
[0076] Example 1
[0077] This example provides a method for preparing plant-based samples and determining their protein content, water content, and corresponding near-infrared spectral data, specifically including:
[0078] Six different production batches of plant-based products were selected. Each complete plant-based product was evenly cut into eight small pieces, each approximately 5cm long and 3cm wide, resulting in a total of 48 small samples. All samples were soaked in water for 15 hours, then removed, the surface moisture was wiped off, and the samples were numbered and set aside for later use.
[0079] Forty-eight numbered samples were placed in a 70℃ drying oven for drying. Every hour, they were removed and cooled in a desiccator for 20 minutes, weighed, and the weight recorded. Simultaneously, the spectrometer was preheated for 15 minutes. The mode width was set to 8.2, and the average number of scans was 8. The samples were scanned at 26℃ and 45% relative humidity. Each sample was scanned three times at three different locations, and the average was taken as the raw spectral data. Figure 2 As shown.
[0080] The operation was repeated more than 10 times, collecting a total of 480 sets of near-infrared spectral data from 10 different batches of samples at different times. The 48 samples were completely dried, weighed, and the protein content was determined according to the combustion method in GB5009.5—2010. The moisture content and protein content of different batches of samples were calculated as the true values. The specific calculation formula is as follows:
[0081]
[0082]
[0083] Among them W 水 P represents the moisture content. 湿 P represents the protein content in its hydrated state. 干 The values represent the protein content in the dry state, m1 represents the weight of the sample, and m2 represents the weight of the sample after drying.
[0084] A database was established by mapping the water content and corresponding protein content of samples from different scanning batches to their near-infrared spectral data.
[0085] The statistical results of protein content and moisture content in 480 plant-based products are shown in Table 1 and... Figure 3 As shown, significant differences exist between different plant-based products, providing a benchmark for measuring the protein and moisture content levels of plant-based products.
[0086] Table 1. Protein content and moisture content of plant-based products
[0087]
[0088] Example 2
[0089] This embodiment is used to preprocess, extract features, and establish a deep learning model for the near-infrared spectral data collected in Embodiment 1. The specific process includes:
[0090] The collected raw spectral data were preprocessed using multivariate scattering correction and wavelet transform. The SPXY algorithm was used to divide the database samples into a training set and a validation set in a 7:3 ratio, with 336 training samples and 144 validation samples.
[0091] First, the spectral data is augmented with a channel dimension, creating a three-dimensional data structure (batch size, features, channels). This three-dimensional processing captures more local and global spectral features, enhancing the subsequent model's ability to represent complex spectral data. A six-layer convolutional neural network is then used to automatically extract spectral features from the training set, such as... Figure 4 As shown, each layer consists of two convolutional layers working together, sliding the convolutional kernel along the feature dimension and performing dot product operations to mine the intrinsic features of the spectral data. In addition, the ReLU activation function is used to enhance the nonlinear expressive power of the model, enabling the network to capture more complex data patterns. Max pooling is used for downsampling to reduce computational complexity and capture key feature information. Dropout layer, as a regularization technique, prevents overfitting by randomly dropping some network connections, thereby enhancing the model's generalization ability.
[0092] This embodiment introduces a self-attention mechanism based on the Transformer network architecture into the model, such as... Figure 5 As shown, this approach captures long-range dependencies in the input data. The self-attention mechanism, by calculating the correlations between input features, enables the model to dynamically allocate attention to important spectral regions. This characteristic is particularly suitable for near-infrared spectral data, as its high-dimensional features often contain a large amount of redundant information and noise, easily leading to overfitting and inaccurate feature extraction.
[0093] First, feature mapping is performed on the feature maps output by the convolutional layers, generating query (Q), key (K), and value (V) matrices. The Q matrix represents the query of the current input features, the K matrix provides the correlation between features, and the V matrix contains the value information of the features. 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 water content). This allows the model to effectively suppress noise interference and adaptively focus on spectral regions highly correlated with the target attributes.
[0094] Subsequently, the V matrix is weighted and summed based on the attention scores to generate a weighted representation of spectral features. This representation reflects the relative importance of different spectral channels, helping to identify key features of protein content and water content in near-infrared spectral data. Through this mechanism, the model can effectively capture the dependencies between channels in the spectral data, ultimately improving the accuracy of predictions.
[0095] 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 serve as the input to a feedforward neural network layer, which is responsible for further nonlinear transformations and feature abstraction of the features, ultimately outputting the predicted value. Throughout the training process, the model continuously optimizes and updates the weight parameters through the backpropagation 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 prediction of protein content and water content.
[0096] The accuracy and stability of the two models were verified using spectral data and corresponding protein content and water content data from the validation set samples. Through continuous verification and optimization, if the coefficient of determination R... 2 The root mean square error (RMSE) is greater than 0.9 and less than 0.1, indicating that the model is reliable, effective, generalizable, and robust, and can be used to predict protein content and moisture content in plants and their products. The relevant model parameters are shown in Table 2.
[0097] Table 2 Model-related parameters
[0098]
[0099] like Figure 6 As shown, the coefficient of determination R between the predicted and detected protein content values of the training set samples is... 2 The root mean square error (RMSE) was 0.9713, and the coefficient of determination (R²) for the predicted and detected protein content values in the validation set samples was 0.0140. 2 The value is 0.9829, and the root mean square error (RMSE) is 0.0136.
[0100] like Figure 7 As shown, the predicted and measured values of moisture content in the training set samples have a coefficient of determination R. 2 The root mean square error (RMSE) was 0.0188, and the coefficient of determination (R²) for the predicted and detected moisture content values of the validation set samples was 0.9694. 2 The value is 0.9721, and the root mean square error (RMSE) is 0.0172.
[0101] The deep learning model constructed in this embodiment innovatively combines the feature processing capabilities of Convolutional Neural Networks (CNNs), the Self-Attention module based on the Transformer architecture, and the efficient learning capabilities of feedforward neural networks. This model first expands two-dimensional near-infrared spectral data into three dimensions, fully considering the complex relationships between spectral wavelengths and the high-dimensionality of the data. Through the combination of CNNs and attention mechanisms, the model can effectively optimize feature extraction and dimensionality reduction of spectral data, thereby establishing a more accurate prediction model. During training, the weight parameters of the protein content model and the moisture content model in plant-based products are continuously optimized using the backpropagation algorithm, significantly improving prediction accuracy.
[0102] Validation results show that the model performs exceptionally well on the validation set, with determination coefficients (R²) exceeding 0.97, demonstrating extremely high reliability. Compared to traditional machine learning models, this model not only automates the training process, eliminating the need for complex feature extraction, but also achieves a significant improvement in prediction accuracy, far surpassing existing traditional algorithms.
[0103] Example 3
[0104] This embodiment provides a rapid detection system for protein content and moisture content in plant-based products. This system is used to implement the rapid detection method for protein content and moisture content in plant-based products described herein, and includes:
[0105] The raw sample data acquisition unit is used to acquire raw near-infrared spectral data, water content, and protein content of the sample at different times and to establish a database.
[0106] The data preprocessing unit is used to preprocess and extract features from the acquired raw near-infrared spectral data, and divide it into training and validation sets.
[0107] The deep learning model building unit uses a convolutional neural network, introduces a Self-Attention mechanism based on the Transformer network architecture and a feedforward neural network to build a 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 protein content in plant substrate; and fits the near-infrared spectral data and water content data of the training set samples to establish a deep learning model II for detecting water content in plant substrate.
[0108] The model validation and optimization unit is used to minimize the loss function through the backpropagation algorithm, update the weight parameters of Model I and Model II in reverse, and use the validation set to validate and optimize the hyperparameters of the model to improve the accuracy and robustness of the model. After multiple validations and optimizations, the final detection model is obtained.
[0109] The rapid sample detection unit acquires the raw spectral data of the sample to be tested, inputs the raw spectral data into the deep learning models I and II for protein content and water content in the plant substrate, and outputs the predicted values of protein content and water content in the plant substrate.
[0110] For details not covered in this embodiment, please refer to the preceding description.
[0111] Example 4
[0112] 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, it implements the steps of a rapid detection method for protein content and moisture content in the plant-based product.
[0113] Reference Figure 8 The electronic device includes a 3D printed shell 3 and a spectrometer 1 and a tablet computer 2 installed inside it and connected via a USB conversion cable interface 4. The tablet computer 2 is equipped with deep learning models I and II for protein content and moisture content in plant-based products. The detection function and UI interface are developed based on Python and PyQt5, forming a portable, efficient, and non-destructive electronic device for rapid detection of protein content and moisture content in plant-based products.
[0114] Example 5
[0115] This embodiment provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of a rapid detection method for protein content and moisture content in plant-based products.
[0116] It should be noted that the above description 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 foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A rapid method for detecting protein content and moisture content in plant-based products, characterized by: include S1 involves thoroughly immersing plant-based samples from different production batches in water to ensure that the sample moisture content is uniform. S2 The fully soaked sample is placed in an oven for drying. It is taken out every 1 hour, weighed and its original near-infrared spectral data is collected until the sample is completely dried and then weighed and recorded again. S3 Weigh the completely dried plant-based sample, determine the moisture content and protein content of the sample at different times according to the national standard method, and convert them into protein content under different conditions to establish a database to ensure that it corresponds to the original spectral data measured in S2. S4 preprocesses the acquired raw near-infrared spectral data and randomly divides it into training and validation sets. S5 automatically extracts the spectral features of the preprocessed training set through a 6-layer convolutional neural network. Based on this, it introduces a Self-Attention mechanism based on the Transformer network architecture and a feedforward neural network to construct a deep learning model to enhance the depth and breadth of feature representation. 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 substrates; it fits the near-infrared spectral data and water content data of the training set samples to establish a deep learning model II for detecting water content in plant substrates. S6 minimizes the loss function through the backpropagation algorithm, updates the weight parameters of Model I and Model II in reverse, and uses the validation set in S4 to validate and optimize the hyperparameters of the model to improve the accuracy and robustness of the model. After multiple validations and optimizations, the final detection model is obtained. If the coefficient of determination R 2 >0.9, RMSE<0.1, the model meets the requirements and can be used for rapid detection of protein content and moisture content in plant-based products; S7 prepares the plant-based sample to be tested, soaks it thoroughly in water, and then dries it in an oven at 70°C. Every hour, the sample was removed, weighed, and the raw spectral data was measured. Inputting the raw spectral data into the S6 final detection model will output the predicted values of protein content and moisture content of plant-based products.
2. The rapid detection method for protein content and moisture content in plant-based products according to claim 1, characterized in that: In S2, the extracted sample was spectrally scanned at three different locations, and the average value was taken as the raw spectral data of the sample. To ensure the accuracy and robustness of the model, at least 300 sets of spectral data were collected; the scanning range of the near-infrared spectrometer was 10000~6250 cm⁻¹. -1 .
3. The rapid detection method for protein content and moisture content in plant-based products according to claim 1, characterized in that: In S3, after the sample is completely dried in an oven at 70℃, it is weighed and the protein content in the sample is determined by the combustion method in GB5009.5—2010. The moisture content at different times is calculated by the difference in sample weight before and after drying, and the protein content at different times is calculated by the fact that the total protein content of the sample remains unchanged before and after drying, and is matched one by one with the original spectral data.
4. The rapid detection method for protein content and moisture content in plant-based products according to claim 1, characterized in that: In S4, one or more of the following methods are used to preprocess the acquired raw spectral data: first-order difference, second-order difference, wavelet transform, SG smoothing, multivariate scattering correction, standard normal transform, trend correction, and sliding smoothing filter.
5. The rapid detection method for protein content and moisture content in plant-based products according to claim 1, characterized in that: The specific steps of S5 include: The SPXY algorithm is used to randomly divide the samples into training and validation sets; Establish a regression model based on deep learning; The Self-Attention module in the Transformer network performs different linear transformations on the feature maps output by the convolutional layers 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 normalization is achieved through the Softmax layer. Finally, a weighted feature representation is output, which can reflect the relative importance between different spectral channels. It is especially helpful in identifying key features of protein content and water 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 water content in the plant substrate.
6. The rapid detection method for protein content and moisture content in plant-based products according to claim 1, characterized in that: In S6, the backpropagation algorithm includes The error loss is calculated using the mean squared loss function, and the model weights are updated using the Adam optimizer. Select the evaluation index, coefficient of determination R. 2 The root mean square error (RMSE) represents the overall fitting effect of the model. It is used to visually demonstrate the accuracy of the model. The final detection model is obtained after multiple validations and optimizations on the validation set. Coefficient of determination R 2 When the mean square error (RMSE) is greater than 0.9 and the root mean square error (RMSE) is less than 0.1, the model meets the requirements and can be used for the rapid detection of protein content and moisture content in plant-based products.
7. The rapid detection method for protein content and moisture content in plant-based products according to claim 1, characterized in that: In S7, at an environment of 26℃ and 45% relative humidity, the near-infrared spectrometer performed an average of 8 scans with a mode width of 8.
2. Spectral data for each sample were collected once at three different locations, 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 in that: The system is used to implement the rapid detection method for protein content and water content according to any one of claims 1 to 7, comprising: The raw sample data acquisition unit is used to acquire raw near-infrared spectral data, water content, and protein content of the sample at different times and to establish a database. The data preprocessing unit is used to preprocess and extract features from the acquired raw near-infrared spectral data, and divide it into training and validation sets. The deep learning model building unit automatically extracts the preprocessed spectral features of the training set through a 6-layer convolutional neural network. Based on this, it introduces a Self-Attention mechanism based on the Transformer network architecture and a feedforward neural network to construct a deep learning model to enhance the depth and breadth of feature representation. It fits the near-infrared spectral data and protein content data of the training set samples to establish a deep learning model I for protein content in plant substrate; and it fits the near-infrared spectral data and water content data of the training set samples to establish a deep learning model II for detecting water content in plant substrate. The model validation and optimization unit is used to minimize the loss function through the backpropagation algorithm, update the weight parameters of Model I and Model II in reverse, and use the validation set to validate and optimize the hyperparameters of the model to improve the accuracy and robustness of the model. After multiple validations and optimizations, the final detection model is obtained. The rapid sample detection unit acquires the raw spectral data of the sample to be tested, inputs the raw spectral data into the deep learning models I and II for protein content and water content in the plant substrate, and outputs the predicted values of protein content and water content in the plant substrate.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, it implements the steps of the rapid detection method for protein content and moisture content in plant-based products according to any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by the processor, it implements the steps of the rapid detection method for protein content and moisture content in plant-based products according to any one of claims 1 to 7.
Citation Information
Patent Citations
Fabric fiber component qualitative method based on self-attention
CN114112984A
Rapid detection method for mycelium protein content
CN117368146A