Detection method and detection system for protein content and moisture content in sorghum and storage medium

Through the hyperspectral imaging system and deep learning model CLNet, the problem of long detection cycle of sorghum protein and moisture content is solved, and the rapid and non-destructive detection effect is achieved, the detection efficiency and accuracy are improved, and the economic benefits are significant.

CN120507313APending Publication Date: 2025-08-19ANHUI GUJING DISTILLERY CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510372492.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-27
Publication Date
2025-08-19

AI Technical Summary

Technical Problem

In the prior art, the detection cycle of sorghum protein and moisture content detection methods is long and requires professional equipment. Real-time testing cannot be achieved, and fast and efficient non-destructive testing cannot be achieved.

Method used

Hyperspectral image of sorghum samples was collected using hyperspectral imaging system, spectral data were extracted through Otsu segmentation algorithm, combined with the CLNet model of the convolutional neural network CNN and the long and short-term memory network LSTM, a nonlinear mapping relationship between spectral characteristics and the content of substances to be measured was established, and rapid and lossless prediction of protein and moisture content was achieved.

Benefits of technology

It has achieved rapid and non-destructive testing of sorghum protein and moisture content, improved detection efficiency and accuracy, and has important economic benefits and application prospects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120507313A_ABST
    Figure CN120507313A_ABST
Patent Text Reader

Abstract

The invention provides a method and system for detecting protein and moisture content in sorghum and a storage medium, and belongs to the technical field of food detection. According to the detection method, hyperspectral images of sorghum samples are collected, spectral data are extracted by using an Otsu segmentation algorithm, and a CLNet model is constructed by combining models of a CNN (convolutional neural network) and an LSTM (long short-term memory) network, so that local and global features of the spectral data can be captured at the same time, and a nonlinear mapping relationship between the spectral features and the content of a substance to be detected is established. In the practical application, the hyperspectral image data of a sorghum sample to be detected is input into the trained CLNet model, so that the rapid and lossless prediction of the protein and moisture content of the sorghum can be realized, and the visual result of the content can be intuitively presented. The method greatly improves the detection efficiency and accuracy, can be widely applied to raw material quality control and product quality improvement in white spirit production, and has remarkable economic benefits and application prospects.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of food detection, and in particular relates to a method, a detection system and a storage medium for detecting the protein and moisture contents in sorghum. Background Art

[0002] Sorghum is one of the main raw materials for traditional Chinese liquor brewing. During the brewing process, protein and moisture content are two crucial evaluation indicators, directly affecting the growth of the koji (drinking yeast) and fermentation efficiency. Excessive protein content breaks down during fermentation to produce various amino acids, altering the flavor profile of the liquor. Moisture content, on the other hand, is associated with liquor yield; either excessively high or low levels can affect the liquor's quality. Currently, the determination of sorghum protein and moisture content primarily relies on traditional chemical and physical analysis methods, such as the Kjeldahl method and the drying method. However, these analytical methods have significant limitations: long detection cycles, the need for specialized equipment, and the inability to achieve real-time detection. Therefore, a rapid, efficient, and real-time detection method is needed. Summary of the Invention

[0003] The purpose of the present invention is to address the above-mentioned shortcomings of the existing technology and provide a method, detection system and storage medium for detecting protein and moisture content in sorghum based on a spectral feature and band relationship fusion network, thereby providing a method for detecting protein and moisture content with the advantages of rapid, non-destructive and accurate identification.

[0004] To achieve the above object, the present invention adopts the following technical solutions: The first object of the present invention is to provide a method for detecting the protein and water content in sorghum, comprising the following specific steps: S1. Using a hyperspectral imaging system to collect a hyperspectral image of a sorghum sample by push-broom linear scanning, and performing black-and-white correction processing, the spectral scanning range is 899.3-1700.04 nm; S2, using the Otsu algorithm to segment the hyperspectral image obtained after correction in S1 and extract spectral data; S3. Using chemical analysis methods to measure the protein and moisture content of sorghum, which are used for training the constructed content prediction model; S4, using the spectral data from S2, establishes a deep learning network CLNet model that captures the spectral features and band relationship fusion. Through the designed network structure, it simultaneously extracts the local and global features of the spectral data, establishes a nonlinear mapping relationship between the spectral features and the content of the substance to be measured, and determines the content prediction model; The CLNet model is composed of a model architecture that combines a convolutional neural network (CNN) and a long short-term memory (LSTM) network. S5. Input the spectral data of the sorghum to be tested into the content prediction model constructed in S4 to realize the visualization of the prediction of the protein and moisture content of the sorghum.

[0005] Furthermore, in step S1, the hyperspectral imaging system collects hyperspectral data of the Daqu sample by pushing a broom linear scan, and performs black and white correction on the collected hyperspectral data. The formula for black and white correction is: , Where, is the corrected hyperspectral data; is the original hyperspectral image; Dark reference image collected with the lens covered; is the collected standard whiteboard image.

[0006] Furthermore, in step S2, in the sorghum sample image, a region of interest is created with the image center as the center point and a radius of 180 pixels. The sample image is then segmented by combining the Otsu method with the watershed algorithm. Finally, the spectral data of each pixel of the sample in the region of interest is extracted through morphological transformation and mask operation.

[0007] Furthermore, in step S4, the combined convolutional neural network (CNN) model consists of three convolution blocks, each of which contains two convolution layers, and the last convolution layer is downsampled using a maximum pooling layer; after each convolution layer, a rectified linear unit activation function and batch normalization technology are used.

[0008] Furthermore, the convolution kernel sizes in the three convolution blocks are 7, 5, and 3, respectively, with a stride of 2, and zero padding of size 1 is used; the convolution kernel size and stride of the maximum pooling layer are 2 and 2, respectively; after the convolution block, an adaptive average pooling layer is used to reduce the feature map size to 1.

[0009] Furthermore, the long short-term memory network (LSTM) model collaboratively controls the addition, update, and deletion of information in the cell state through the forget gate, input gate, and output gate. When data passes through the LSTM unit at each time step, the state of each gate and the update of the cell state are calculated using the following formula: ; ; ; ; ; in, 、 and Represent the input, hidden state and cell state of the current time step respectively, and are the hidden state and cell state of the previous time step, 、 and are the activation values of the forget gate, input gate, and output gate, respectively. Represents the sigmoid activation function, which maps the input value to [0, 1]. Indicates that the hyperbolic tangent activation function maps the input value to [-1, 1], and denote the weight matrix and bias vector respectively.

[0010] Furthermore, in step S3, the constant weight method is used to measure the moisture content of the sorghum sample, and the calculation formula is: , in, is the water content in the sample, g / 100g; is the mass of the weighing bottle and sorghum sample, g; is the mass of the weighing bottle and sorghum sample after drying, g; is the mass of the weighing bottle, g; 100 is the unit conversion factor.

[0011] Furthermore, in step S3, the protein content of the sorghum sample is measured using the Kjeldahl method, and the calculation formula is: , in, is the protein content in the sample, g / 100g; is the volume of sulfuric acid or hydrochloric acid standard titrant consumed, mL; is the volume of sulfuric acid or hydrochloric acid standard titrant consumed by the reagent blank, mL; is the concentration of sulfuric acid or hydrochloric acid standard titration solution, mol / L, is the mass of the sample, g, is the volume of digestive fluid absorbed, mL; The conversion factor of nitrogen to protein is 6.25, and 100 is the conversion factor.

[0012] A second object of the present invention is to provide a system for detecting protein and moisture content in sorghum, wherein the system is based on the above method and comprises at least: The data acquisition module is configured to obtain a hyperspectral image of the sorghum sample, obtain a corresponding corrected spectral image through black and white correction, and then segment the image using the Otsu algorithm to delineate a region of interest and extract spectral data of the sorghum sample within the region of interest; The data processing module is configured to obtain normal spectral data, remove 8 and 21 wavelengths before and after the original spectrum, and finally retain spectral data of 483 valid wavelengths; The feature extraction module is configured as a feature extraction module in the convolutional neural network (CNN) model framework. When processing spectral data, it can automatically learn and extract key features, capture the correlation between different wavelengths, and use time series information to make accurate predictions; The content prediction module uses a CLNet model, which combines a convolutional neural network (CNN) and a long short-term memory (LSTM) architecture, as its content prediction model. It divides the standard values of protein and moisture content and characteristic spectral data into a calibration set and a prediction set in an 8:2 ratio. The module evaluates the calibration set and the prediction set, generates a prediction scatter plot to display the prediction accuracy, and obtains the protein and moisture content prediction results. The visualization module is configured with a trained deep learning network model to predict the protein and moisture content of each pixel in the sorghum hyperspectral image, and assign different colors to the pixels based on the predicted values; combined with the pixel coordinate information, a pseudo-color image is generated to intuitively display the spatial distribution characteristics of the protein and moisture content.

[0013] A third object of the present invention is to provide a computer-readable storage medium storing a program, wherein the program can be executed by one or more processors to implement the above-mentioned method for detecting the protein and moisture content in sorghum.

[0014] Compared with the prior art, the technical solution provided by the present invention has the following beneficial effects: (1) The present invention provides a method for detecting the protein and moisture content of sorghum. The method first collects a hyperspectral image of a sorghum sample, and after preprocessing and correction, uses the Otsu segmentation algorithm to extract the spectral data of the sorghum sample. In order to improve the signal-to-noise ratio of the spectral data, 8 and 21 wavelengths before and after the original spectrum are removed, and the 483 most effective wavelength data are retained. Based on these spectral data, the present invention constructs a deep learning network model called CLNet. Through a carefully designed network structure, it can simultaneously capture the local and global features of the spectral data and establish a nonlinear mapping relationship between the spectral features and the content of the substance to be tested. In practical applications, it is only necessary to input the hyperspectral image data of the sorghum sample to be tested into the trained CLNet model to achieve a rapid and non-destructive prediction of the protein and moisture content of sorghum, and intuitively present the visualization results of the content.

[0015] (2) The detection method provided by the present invention overcomes the limitations of traditional detection methods and greatly improves detection efficiency and accuracy.

[0016] (3) The present invention uses near-infrared hyperspectral imaging technology combined with deep learning methods to establish a deep learning network model, which realizes efficient and non-destructive detection of sorghum protein and moisture content. It is of great significance to liquor companies in terms of raw material quality control and product quality improvement, and has significant economic benefits and application prospects. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 The overall process of the method of the present invention includes key steps such as sample preparation, data processing and analysis; Figure 2 This is a schematic diagram of the structure of 1DCNN, an important component of the deep learning model framework constructed in the method provided by the present invention; Figure 3 This is a schematic diagram of the structure of LSTM, another important component of the deep learning model framework constructed in the method provided by the present invention; Figure 4 This is a schematic diagram of the structure of the deep learning network CLNet model that captures the fusion of spectral features and band relationships constructed in the method provided by the present invention; Figure 5 The predicted scatter plot of protein content under each model in the method provided by the present invention; Figure 6 This is a scatter plot of the prediction of moisture content under various models in the method provided by the present invention; Figure 7 The visualization result of the method provided by the present invention in practical application for predicting the protein content of sorghum; Figure 8 The visualization result of the sorghum moisture content prediction using the method provided by the present invention in practical application; Figure 9 This is a schematic structural diagram of a system for detecting sorghum protein and moisture content provided by the present invention. DETAILED DESCRIPTION

[0018] To make the objectives, technical solutions, and advantages of the present invention more apparent, the following describes the specific embodiments of the present invention in further detail with reference to specific examples and accompanying drawings. Where specific techniques or conditions are not specified in the examples, the techniques or conditions described in the literature in the art or in the product instructions shall prevail.

[0019] Unless otherwise specified, the raw materials, equipment and methods used in the present invention are commonly used in the art.

[0020] like Figure 1 FIG. 5 is a flow chart of a method for detecting sorghum protein and moisture content according to the present invention, which comprises the following steps: S1. Prepare sorghum samples from different geographical locations and varieties; use a hyperspectral imaging system to collect hyperspectral images of the samples; S2, performing black and white correction on the collected hyperspectral image; S3, using the Otsu algorithm to segment the sample and background in the corrected hyperspectral image, and extracting the sample spectral data after background segmentation; S4. To improve the signal-to-noise ratio of the spectral data, 8 and 21 wavelengths before and after the original spectrum need to be removed, and finally 483 effective wavelengths are retained to obtain normal spectral data; S5. Use traditional chemical analysis methods to measure the protein and moisture content of sorghum for subsequent model training; S6. Utilize spectral data to establish a deep learning network CLNet model that captures the fusion of spectral features and band relationships. Through the designed network structure, the local and global features of the spectral data are extracted simultaneously, and a nonlinear mapping relationship between the spectral features and the content of the substance to be measured is established; S7. Input the hyperspectral image data to be tested into the trained deep learning network model to realize the visualization of the prediction of sorghum protein and moisture content.

[0021] In step S1, sorghum samples were prepared using 12 brewing sorghum varieties from different geographical regions: Inner Mongolia Jiza 217 / 218, Aohan Banner Jiza 218, Northeast Liaoza, Tongliao Jiza 30, Fuxin Songhang, Jianping Guyuan, Aohan Banner Fangze, Xincheng Zhongbang, Hanqing No. 1, Jiza 127, Jinza 109, and Jinza 112. To prepare the sorghum samples for the experiment, 20 samples of each sorghum variety were selected and evenly spread in an 80 cm diameter Petri dish. A total of 240 (20 × 12 = 240) sorghum samples were collected from the 12 varieties.

[0022] In step S1, the hyperspectral imaging system consists of a hyperspectral imaging instrument, a data acquisition computer, a halogen lamp, and a support system. Core components include the hyperspectral camera, an auxiliary support, a whiteboard, and data acquisition software. To obtain high-quality data, the sample must be placed in a glass Petri dish and positioned in the center of the acquisition platform, 40 cm from the imaging instrument lens.

[0023] In step S2, to obtain a high-quality hyperspectral image, a black-and-white calibration is required to eliminate the effects of camera noise and uneven light sources. First, a full-white calibration image is taken with a whiteboard placed in the shooting area, with a reflectivity close to 100%, which can calibrate the effects of camera noise. Then, a full-black calibration image is taken with the lens cap on, with a reflectivity of approximately 0. By performing full-white and full-black calibration on the hyperspectral image and calculating using a specific formula, the effects of camera noise and uneven light sources can be effectively eliminated, thereby obtaining a relatively stable spectral reflectance. The black-and-white calibration can be calculated using the following formula:

[0024] In the formula is the corrected hyperspectral image, is the hyperspectral image before correction, Calibrate the image for the whiteboard, Calibrate the image for the blackboard.

[0025] In step S3, each hyperspectral image contains both sample and background information. To effectively remove background interference and improve the purity of sample information, we employ the Otsu algorithm to segment the image. This algorithm leverages the image's grayscale distribution to calculate the grayscale value of each pixel and intelligently determine the optimal segmentation threshold, dividing the image into two regions: the sample (foreground) and the background.

[0026] In step S4, the instrument's dark current and noise can affect the original spectral information during spectrum acquisition, especially at the ends of the spectral range. To improve the signal-to-noise ratio, the first 8 and last 21 wavelengths of the original spectrum are removed, reducing the spectral range from 886–1735.24 nm to 899.3–1700.04 nm. Ultimately, data from 483 valid wavelengths is retained.

[0027] In step S5, traditional chemical analysis methods, such as Kjeldahl nitrogen determination and oven-drying, are used to accurately determine the protein and moisture content of the sorghum. The reliable data obtained from these classical methods will serve as standard reference values for the subsequent development and training of a deep learning model based on near-infrared spectroscopy, enabling rapid and non-destructive testing of sorghum quality.

[0028] In step S6, a deep learning network (CLNet) model was constructed based on the fusion of spectral features and band relationships. This model, through its innovative network architecture, simultaneously extracts both local detail features and global correlation features from spectral data. This effectively establishes a nonlinear mapping relationship between spectral features and the content of the substance being measured, enabling accurate prediction of sorghum protein and moisture content.

[0029] In step S7, the collected sorghum hyperspectral image data is fed into a trained deep learning network model to visualize the protein and moisture content of the sorghum. The model analyzes each pixel in the hyperspectral image and predicts its corresponding protein and moisture content based on its spectral characteristics. The model then assigns a color representation to that pixel. Combined with the pixel's coordinate information, a pseudo-color image is generated, visually displaying the spatial distribution of protein and moisture content in the sorghum sample.

[0030] Example 1 1. Sorghum Sample Preparation In this example, sorghum samples were prepared from 12 brewing sorghum varieties from different geographical regions, including Inner Mongolia Jiza 217 / 218, Aohan Banner Jiza 218, Northeast Liaoza, Tongliao Jiza 30, Fuxin Songhang, Jianping Guyuan, Aohan Banner Fangze, Xincheng Zhongbang, Hanqing No. 1, Jiza 127, Jinza 109, and Jinza 112. To prepare the sorghum samples needed for the experiment, 20 samples of each sorghum variety were selected and evenly spread in an 80 cm diameter Petri dish. A total of 240 (20 x 12 = 240) sorghum samples from these 12 varieties were used to estimate their protein and moisture content.

[0031] 2. Hyperspectral imaging system and black and white correction The hyperspectral imaging system used in this embodiment mainly consists of the following parts: a hyperspectral camera, an auxiliary bracket for the support system, a whiteboard for calibration, computer software for data acquisition, and four 55W halogen lamps. The spectral acquisition range of the camera is 886-1735.34nm, the spectral resolution is 5nm, and the final acquired hyperspectral image is a three-dimensional cube image containing 512 bands, which contains rich spectral and spatial information. In order to ensure the stability of the hyperspectral camera when collecting samples, it is necessary to start the camera and preheat it 15 minutes in advance. A series of parameters were adjusted using SpectraVIEW software, and the exposure time was determined to be 2ms, the forward and backward speeds were 0.075cm / s and 0.2cm / s respectively, and the vertical distance between the sample and the camera was 40cm.

[0032] During the acquisition process, the camera's dark current and the uneven illumination intensity of the halogen lamp will affect the hyperspectral image data. Therefore, in order to eliminate the interference of these factors, it is necessary to perform black and white correction on the acquired hyperspectral image data. The correction formula is as follows: , In the formula is the corrected hyperspectral image, is the hyperspectral image before correction, Calibrate the image for the whiteboard, Calibrate the image for the blackboard.

[0033] 3. Extract sample spectral data To obtain spectral information for each sorghum sample, a region of interest (ROI) was selected from the black-and-white plate-calibrated hyperspectral image. The ROI was defined as a circular area that was always smaller than the Petri dish containing the sorghum, ensuring that spectral data was captured only from the sample area while minimizing background noise. The algorithm automatically located the center of each hyperspectral image and extracted an ROI based on a predefined size and shape around the center point. This approach ensured consistency and efficiency in the ROI selection process, eliminating the need for manual intervention. Subsequently, by averaging the spectral information of all pixels within the ROI, representative spectral data for each sorghum sample was obtained, providing a comprehensive dataset for further analysis.

[0034] 4. Spectral data processing During spectral image acquisition, the instrument's inherent dark current and noise can affect the original spectral information, particularly at the beginning and end of the spectral range, leading to abnormal data. To improve the signal-to-noise ratio of the spectral data, we removed eight and 21 wavelengths from the original spectrum, respectively. This reduced the original spectral range from 886–1735.24 nm to 899.3–1700.04 nm, ultimately retaining spectral data for 483 valid wavelengths.

[0035] 5. Determination of protein and moisture content Traditional chemical analysis methods, such as Kjeldahl nitrogen determination and oven drying, are used to accurately determine the protein and moisture content of sorghum. The protein content of sorghum is determined using the Kjeldahl nitrogen determination method in GB5009.5-2016, and the protein content is calculated according to the formula: , in, is the protein content in the sample, g / 100g; is the volume of sulfuric acid or hydrochloric acid standard titrant consumed, mL; is the volume of sulfuric acid or hydrochloric acid standard titrant consumed by the reagent blank, mL; is the concentration of sulfuric acid or hydrochloric acid standard titration solution, mol / L, is the mass of the sample, g, is the volume of digestive fluid absorbed, mL; The conversion factor of nitrogen to protein is 6.25, and 100 is the conversion factor.

[0036] The moisture content of sorghum was determined using the direct drying method in GB5009.3-2016. The moisture content of the sample can be calculated according to the formula: , in, is the water content in the sample, g / 100g; is the mass of the weighing bottle and sorghum sample, g; is the mass of the weighing bottle and sorghum sample after drying, g; is the mass of the weighing bottle, g; 100 is the unit conversion factor.

[0037] 6. Model construction and evaluation As one of the important models of deep learning, convolutional neural networks (CNNs) have achieved remarkable results in image, video and speech processing due to their powerful feature learning and extraction capabilities. The advantage of CNNs is that they can automatically learn feature representations in data without the need for manually designed feature extractors. Compared with traditional neural networks, CNNs show better performance in image and sequence data processing tasks. The present invention constructs a 1DCNN model, which is mainly composed of a convolutional layer, a maximum pooling layer, an average pooling layer and a fully connected layer. Figure 2 As shown in Figure 2, the model consists of three convolutional blocks, each containing two convolutional layers, with the final convolutional layer downsampled using a max pooling layer. To improve model training, rectified linear unit activation functions and batch normalization are used after each convolutional layer. The ReLU activation function introduces nonlinearity, enabling the model to learn complex features and effectively preventing gradient vanishing. By normalizing the output of the convolutional layers, model training is accelerated and performance is improved. The convolution kernel sizes in the three convolutional blocks are 7, 5, and 3, respectively, with a stride of 2 and zero padding of 1. The convolution kernel size and stride of the max pooling layer are 2 and 2, respectively. After the convolutional blocks, an adaptive average pooling layer is used to reduce the feature map size to 1, and then a flattening layer is used to convert it to a one-dimensional vector. Finally, this vector is processed through three fully connected layers, the first two using the ReLU activation function and the last one generating the output prediction.

[0038] LSTM is a special type of recurrent neural network (RNN) designed to address the vanishing and exploding gradient problems faced by traditional RNNs when processing long sequences of data. At the core of LSTM is the cell state, which acts as a channel for information transmission, allowing relevant information to flow through the sequence. LSTM uses three key gate structures: the forget gate, the input gate, and the output gate to collaboratively control the addition, update, and deletion of information in the cell state. This gate mechanism enables LSTM to learn and remember important information in long sequences of data while also selectively forgetting irrelevant information, effectively capturing long-term dependencies in the data. Figure 2 A typical LSTM structure is shown. When data passes through the LSTM unit at each time step, the state of each gate and the update of the cell state are calculated by the following formula: ; ; ; ; ; in, 、 and Represent the input, hidden state and cell state of the current time step respectively, and are the hidden state and cell state of the previous time step, 、 and are the activation values of the forget gate, input gate, and output gate, respectively. Represents the sigmoid activation function, which maps the input value to [0, 1]. Indicates that the hyperbolic tangent activation function maps the input value to [-1, 1], and denote the weight matrix and bias vector respectively.

[0039] Since CNN performs well in feature extraction and can automatically extract local features in data, while LSTM has advantages in capturing long-term dependencies in sequence data, this paper proposes a model architecture that combines convolutional neural networks (CNN) and long short-term memory networks (LSTM). When processing spectral data, it can automatically learn and extract key features, capture the relationship between different wavelengths, and use time series information to make accurate predictions. Figure 3 As shown in the figure, the model primarily consists of convolutional layers, maximum pooling layers, adaptive average pooling layers, LSTM layers, and fully connected layers. First, the input spectral data passes through a series of one-dimensional convolutional layers to automatically learn and extract key features from the spectral data. Then, the spatial dimension of the feature map is reduced and resized to 512×1 using maximum pooling and adaptive average pooling layers. The resized feature map is input to the LSTM layer, which consists of a single LSTM layer with a hidden state size of 128. This layer learns and memorizes the temporal information in the spectral data, capturing the associations and dependencies between different wavelengths. Finally, the output of the LSTM layer is processed by a fully connected layer to generate the final prediction value.

[0040] Commonly used indicators for evaluating model performance include the calibration coefficient of determination (R C ²) and the predicted coefficient of determination (R P²), used to measure the correlation between the model's predicted value and the true value. The closer it is to 1, the higher the fit. The root mean square error of calibration (RMSEC) and the root mean square error of prediction (RMSEP) are used to measure the average deviation between the predicted value and the true value. The smaller the deviation, the better the prediction performance. And the residual prediction deviation (RPD) is used to evaluate the model's prediction performance and robustness. The larger the RPD, the stronger the prediction ability and the higher the stability. Among them, RPD between 1.5-2 has poor prediction ability; between 2-2.5 has certain prediction ability; greater than 2.5 has strong prediction ability and can accurately predict. C ²、R P The calculation formulas for ², RMSEC, RMSEP and RPD parameters are as follows: ; ; ; ; ; In the formula and are the predicted value and true value of protein or moisture content in the i-th sorghum sample, and are the average protein or moisture content of sorghum samples in the calibration set and prediction set, respectively. and are the number of samples in the calibration set and prediction set, respectively.

[0041] 7. Modeling results This paper uses a combination of deep learning regression models—convolutional neural networks (CNNs), long short-term memory networks (LSTMs), and CLNet—to predict sorghum protein and moisture content. The SNV-SPA-PLSR and 1st-CARS-PLSR models, which have shown excellent performance in traditional machine learning for predicting sorghum protein and moisture content, respectively, were used as comparison models.

[0042] Table 1. Protein and moisture content prediction modeling results

[0043] The results are shown in Table 1. In the protein and moisture content prediction tasks, the CLNet combination model has the best prediction effect. As a combination model, CLNet shows good prediction performance in the protein and moisture content prediction tasks. Compared with using CNN or LSTM models alone, the prediction effect is significantly improved. As can be seen from Table 1, CLNet has a good R P 2They reached 0.9807 and 0.9983 respectively, and the RMSEP were 0.0676 and 0.0313 respectively. P 2 The RMSEP was improved by 0.0237 and 0.0119 respectively, and the RMSEP was reduced by 0.0376 and 0.0577 respectively; compared with the LSTM model, R P 2 They increased by 0.2603 and 0.1828 respectively, and RMSEP decreased by 0.1895 and 0.2967 respectively.

[0044] Comparing traditional machine learning with deep learning, the SNV-SPA-PLSR model was selected for protein content prediction, which achieved the best prediction effect through preprocessing and feature selection (R P 2 =0.9492, RMSEP=0.1199 g / 100g). In the prediction of moisture content, the 1st-CARS-PLSR model has the best performance (R P 2 =0.9802, RMSEP=0.1165 g / 100g). This shows that the PLSR model has a certain predictive performance for the protein and moisture content of sorghum after different preprocessing and feature extraction methods. Using 1DCNN, which has a strong feature extraction ability in deep learning, to predict protein and moisture content, the corresponding R P 2 and RMSEP were 0.0.9632, 0.0933 and 0.9864, 0.089 respectively. In terms of protein content prediction, the prediction effect of 1DCNN was significantly improved compared with the SNV-SPA-PLSR model. P 2 The RMSEP was improved by 0.0207 and decreased by 0.0266. In terms of moisture content prediction, compared with the 1st-CARS-PLSR model R P 2 The RMSEP was improved by 0.0042 and decreased by 0.0275. However, in the LSTM model, for the prediction of protein and moisture content, R P 2 The performance of the proposed model is significantly reduced compared with the SNV-SPA-PLSR and 1st-CARS-PLSR models.

[0045] Scatter plot is one of the effective ways to evaluate the prediction performance of the model. Figure 5 and Figure 6As shown in the figure, scatter plots are used to intuitively present the performance of different models in predicting sorghum protein and moisture content. Among them, sub-graph a in the two figures corresponds to the prediction results of SNV-SPA-PLSR and 1st-CARS-PLSR models, while sub-graphs b, c, and d correspond to the prediction results of 1DCNN, LSTM, and CLNet models respectively. By observing Figure 5 and Figure 6 As shown in sub-figures a, b, and c, the 1DCNN model's calibration and prediction curves significantly outperform the SNV-SPA-PLSR, 1st-CARS-PLSR, and LSTM models in both protein and moisture content prediction. The LSTM model achieves the lowest fit, resulting in relatively poor prediction performance. Notably, sub-figure d demonstrates the CLNet model's outstanding performance in fitting calibration and prediction curves to measured values.

[0046] 8. Visualization of sorghum protein and moisture content To intuitively display the spatial distribution of sorghum protein and moisture content, the present invention uses the CLNet model to perform pixel-by-pixel prediction on the hyperspectral image and maps the results to each pixel of the image to generate a visual image of the protein and moisture content.

[0047] Figure 7 and Figure 8 The visualization of protein and moisture content for 12 sorghum varieties is shown. As can be seen from the color bar in the figure, the gradient from purple to red represents the continuous change in sorghum protein and moisture content, from low to high. This rich color variation intuitively reflects the significant differences in protein and moisture content between different sorghum varieties.

[0048] Example 2 This embodiment, based on the design of Example 1, discloses a system for detecting sorghum protein and moisture content. Figure 9 As shown, the system is based on the above-mentioned method for detecting sorghum protein and moisture content, and at least includes the following components: The data acquisition module is configured to obtain a hyperspectral image of the sorghum sample, obtain a corresponding corrected spectral image through black and white correction, and then segment the image using the Otsu algorithm to delineate a region of interest and extract spectral data of the sorghum sample within the region of interest; The data processing module is configured to obtain normal spectral data, remove 8 and 21 wavelengths before and after the original spectrum, and finally retain spectral data of 483 valid wavelengths; The feature extraction module is configured as a feature extraction module in the convolutional neural network (CNN) model framework. When processing spectral data, it can automatically learn and extract key features, capture the correlation between different wavelengths, and use time series information to make accurate predictions; The content prediction module uses a CLNet model, which combines a convolutional neural network (CNN) and a long short-term memory (LSTM) architecture, as its content prediction model. It divides the standard values of protein and moisture content and characteristic spectral data into a calibration set and a prediction set in an 8:2 ratio. The module evaluates the calibration set and the prediction set, generates a prediction scatter plot to display the prediction accuracy, and obtains the protein and moisture content prediction results. The visualization module is configured with a trained deep learning network model to predict the protein and moisture content of each pixel in the sorghum hyperspectral image, and assign different colors to the pixels based on the predicted values; combined with the pixel coordinate information, a pseudo-color image is generated to intuitively display the spatial distribution characteristics of the protein and moisture content.

[0049] Example 3 This embodiment, based on the design basis of Embodiments 1 and 2, discloses a computer-readable storage medium, which stores a program. The program can be executed by one or more processors to implement the above-mentioned sorghum protein and moisture content detection method.

[0050] In the absence of conflict, the above embodiments and features in the embodiments may be combined with each other.

[0051] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A method for detecting protein and moisture content in sorghum, characterized in that: The specific steps include: S1. Using a hyperspectral imaging system to collect a hyperspectral image of a sorghum sample by push-broom linear scanning, and performing black-and-white correction processing, the spectral scanning range is 899.3-1700.04 nm; S2, using the Otsu algorithm to segment the hyperspectral image obtained after correction in S1 and extract spectral data; S3. Using chemical analysis methods to measure the protein and moisture content of sorghum, which are used for training the constructed content prediction model; S4, using the spectral data from S2, establishes a deep learning network CLNet model that captures the spectral features and band relationship fusion. Through the designed network structure, it simultaneously extracts the local and global features of the spectral data, establishes a nonlinear mapping relationship between the spectral features and the content of the substance to be measured, and determines the content prediction model; The CLNet model is composed of a model architecture that combines a convolutional neural network (CNN) and a long short-term memory (LSTM) network. S5. Input the spectral data of the sorghum to be tested into the content prediction model constructed in S4 to realize the visualization of the prediction of the protein and moisture content of the sorghum.

2. The detection method according to claim 1, wherein In step S1, the hyperspectral imaging system collects the hyperspectral data of the Daqu sample by pushing the broom linearly and performs black-white correction on the collected hyperspectral data. The formula for black-white correction is: , In the formula is the corrected hyperspectral image, is the hyperspectral image before correction, Calibrate the image for the whiteboard, Calibrate the image for the blackboard.

3. The detection method according to claim 1, wherein In step S2, in the sorghum sample image, a region of interest is created with the image center as the center point and a radius of 180 pixels. The sample image is then segmented by combining the Otsu method with the watershed algorithm. Finally, the spectral data of each pixel of the sample in the region of interest is extracted through morphological transformation and mask operation.

4. The detection method according to claim 1, wherein In step S4, the convolutional neural network (CNN) model consists of three convolution blocks, each of which contains two convolution layers, and the last convolution layer is downsampled using a maximum pooling layer; after each convolution layer, a rectified linear unit activation function and batch normalization technology are used.

5. The detection method according to claim 4, wherein The convolution kernel sizes in the three convolution blocks are 7, 5, and 3, respectively, with a stride of 2, and zero padding of size 1 is used; the convolution kernel size and stride of the maximum pooling layer are 2 and 2, respectively; after the convolution block, an adaptive average pooling layer is used to reduce the feature map size to 1.

6. The detection method according to claim 5, wherein The LSTM model collaboratively controls the addition, update, and deletion of information in the cell state through the forget gate, input gate, and output gate. When data passes through the LSTM unit at each time step, the state of each gate and the update of the cell state are calculated using the following formula: ; ; ; ; ; in, 、 and Represent the input, hidden state and cell state of the current time step respectively, and are the hidden state and cell state of the previous time step, 、 and are the activation values of the forget gate, input gate, and output gate, respectively. Represents the sigmoid activation function, which maps the input value to [0, 1]. Indicates that the hyperbolic tangent activation function maps the input value to [-1, 1], and denote the weight matrix and bias vector respectively.

7. The detection method according to claim 1, wherein In step S3, the constant weight method is used to measure the moisture content of the sorghum sample, and the calculation formula is: , in, is the water content in the sample, g / 100g; is the mass of the weighing bottle and sorghum sample, g; is the mass of the weighing bottle and sorghum sample after drying, g; is the mass of the weighing bottle, g; 100 is the unit conversion factor.

8. The detection method according to claim 7, wherein In step S3, the protein content of the sorghum sample is measured using the Kjeldahl method, and the calculation formula is: , in, is the protein content in the sample, g / 100g; is the volume of sulfuric acid or hydrochloric acid standard titrant consumed, mL; is the volume of sulfuric acid or hydrochloric acid standard titrant consumed by the reagent blank, mL; is the concentration of sulfuric acid or hydrochloric acid standard titration solution, mol / L, is the mass of the sample, g, is the volume of digestive fluid absorbed, mL; The conversion factor of nitrogen to protein is 6.25, and 100 is the conversion factor.

9. A system for detecting protein and moisture content in sorghum, characterized in that: The system is based on the method according to any one of claims 1 to 8, and includes at least: The data acquisition module is configured to obtain a hyperspectral image of the sorghum sample, obtain a corresponding corrected spectral image through black and white correction, and then segment the image using the Otsu algorithm to delineate a region of interest and extract spectral data of the sorghum sample within the region of interest; The data processing module is configured to obtain normal spectral data, remove 8 and 21 wavelengths before and after the original spectrum, and finally retain spectral data of 483 valid wavelengths; The feature extraction module is configured as a feature extraction module in the convolutional neural network (CNN) model framework. When processing spectral data, it can automatically learn and extract key features, capture the correlation between different wavelengths, and use time series information to make accurate predictions; The content prediction module uses a CLNet model, which combines a convolutional neural network (CNN) and a long short-term memory (LSTM) architecture, as its content prediction model. It divides the standard values of protein and moisture content and characteristic spectral data into a calibration set and a prediction set in an 8:2 ratio. The module evaluates the calibration set and the prediction set, generates a prediction scatter plot to display the prediction accuracy, and obtains the protein and moisture content prediction results. The visualization module is configured with a trained deep learning network model to predict the protein and moisture content of each pixel in the sorghum hyperspectral image, and assign different colors to the pixels based on the predicted values; combined with the pixel coordinate information, a pseudo-color image is generated to intuitively display the spatial distribution characteristics of the protein and moisture content.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a program, and the program can be executed by one or more processors to implement the method for detecting protein and moisture content in sorghum according to any one of claims 1 to 8.