Construction method of semen ziziphi spinosae origin recognition model
Through hyperspectral imaging technology and deep learning CNN model, rapid, simple and non-destructive origin identification of jujube seeds is solved, which solves the problems of time-consuming, costly and destructive samples of traditional detection methods, and achieves efficient and economical identification of jujube seeds.
Patent Information
- Application Number
- CN202311359474.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-19
- Publication Date
- 2025-04-22
AI Technical Summary
The prior art is difficult to identify the origin of jujube seeds quickly, easily and without damage, and the traditional detection methods are time-consuming, costly and highly destructive to samples.
Hyperspectral imaging technology combined with deep learning convolutional neural network (CNN) is used to construct a jujube seed origin recognition model. Hyperspectral images of jujube seed samples were obtained by push-swept line scanning hyperspectral reflection imaging system, pre-processing and feature extraction, and training and identification were performed using CNN-Resnimag or CNN-Shufimag models.
It realizes fast, simple and lossless identification of the origin of jujube seeds, reduces the detection cost and time, and can be widely used in industrial or market environments.
Smart Images

Figure CN119863682A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a nondestructive detection and evaluation method for the quality of traditional Chinese medicine materials, in particular to a method for constructing a model for identifying the origin of spinach seeds. Background Art
[0002] Ziziphus jujuba seeds are a common Chinese medicinal material in my country. They are the dried mature seeds of Ziziphus jujuba, a plant of the Rhamnaceae family. Ziziphus jujuba seeds are both medicinal and edible, and have the effects of nourishing the heart and liver, and calming the mind. Ziziphus jujuba seeds are widely distributed, among which the Xingzao seeds produced in Hebei are large, full, and of excellent quality, and are favored by consumers.
[0003] At present, the origin of sour jujube seeds is mainly identified by quantitative analysis of quality markers or key substances. The specific detection method is to use large-scale analytical technology, such as gas / liquid chromatography-mass spectrometry, capillary electrophoresis mass spectrometry, nuclear magnetic resonance hydrogen spectrum technology, etc. Although these detection methods provide a way to accurately identify chemical substances, they all need to be operated in the laboratory, which is not only time-consuming and costly, but also destructive to samples, making it difficult to be widely promoted and applied in modern and high-throughput industrial or market environments. Summary of the invention
[0004] The purpose of the present invention is to provide a method for constructing a model for identifying the origin of wild jujube seeds, so as to identify the origin of wild jujube seeds quickly, simply and non-destructively.
[0005] The object of the present invention is achieved in that:
[0006] A method for constructing a model for identifying the origin of spinach seeds comprises the following steps:
[0007] S101. Obtain samples of sour jujube kernels from at least three origins, obtain hyperspectral images of all sour jujube kernel samples using a push-broom line scanning hyperspectral reflectance imaging system, perform preprocessing on the obtained sample hyperspectral images, including removing redundant edge pixels and overexposed wavelength points on the core-shell surface, use a minimum noise separation method combined with an nD visualization tool to select a region of interest for the kernel in the sample hyperspectral images, and construct a mask image of the sour jujube kernel samples from each origin based on the preprocessing;
[0008] S102, performing processing on the masked images of all samples, including extracting sub-images of individual seeds of all wild jujube seed samples and filling the sub-images, denoising the spectra of the seed pixel points in the sub-images, calculating the average spectrum of the wild jujube seed samples, and identifying and excluding abnormal sample data by calculating the Mahalanobis distance of the average spectrum of the wild jujube seed samples;
[0009] S103, randomly dividing all sample data after excluding abnormalities into a training set, a validation set, and a test set in a ratio of 3:1:1;
[0010] S104, constructing a CNN-Resnimag model, inputting the sample data of the training set into the CNN-Resnimag model and training the model using cross entropy as a loss function, and using the sample data of the validation set to evaluate the prediction performance of the CNN-Resnimag model during the training process;
[0011] S105. Input the sample data of the training set, validation set and test set into the trained CNN-Resnimag model respectively, and evaluate and compare the performance of the model.
[0012] Furthermore, the CNN-Resnimag model in step S104 includes a channel compression module and a Resnet module; the channel compression module includes a two-dimensional convolutional layer; and the Resnet module includes a classic residual module.
[0013] Furthermore, when the CNN-Resnimag model is trained in step S104, the Adam optimizer is used, the learning rate is 0.001, the batch size is 60, and the epoch is 500.
[0014] Furthermore, the size of the mask image after filling in step S102 is 27 pixels×27 pixels×153 wavelengths.
[0015] The purpose of the present invention can also be achieved like this:
[0016] A method for constructing a model for identifying the origin of spinach seeds comprises the following steps:
[0017] S201. Obtain samples of sour jujube kernels from at least three origins, obtain hyperspectral images of all sour jujube kernel samples using a push-broom line scanning hyperspectral reflectance imaging system, perform preprocessing on the obtained sample hyperspectral images, including removing redundant edge pixels and overexposed wavelength points on the core-shell surface, use a minimum noise separation method combined with an nD visualization tool to select a region of interest for the kernel in the sample hyperspectral image, and construct a mask image of the sour jujube kernel samples from each origin based on the preprocessing;
[0018] S202, performing processing on the masked images of all samples, including extracting sub-images of individual seeds of all wild jujube seed samples and filling the sub-images, denoising the spectra of the seed pixel points in the sub-images, calculating the average spectrum of the wild jujube seed samples, and identifying and excluding abnormal sample data by calculating the Mahalanobis distance of the average spectrum of the wild jujube seed samples;
[0019] S203, randomly dividing all sample data after excluding abnormalities into a training set, a validation set, and a test set in a ratio of 3:1:1;
[0020] S204, constructing a CNN-Shufimag model, inputting the sample data of the training set into the CNN-Shufimag model and training the model using cross entropy as a loss function, and using the sample data of the validation set to evaluate the prediction performance of the CNN-Shufimag model during the training process;
[0021] S205. Use the sample data of the training set, validation set and test set to input into the trained CNN-Shufimag model respectively to evaluate and compare the performance of the model.
[0022] Furthermore, the CNN-Shufimag model in step S204 includes a channel compression module and a ShuffleNet module; the channel compression module includes a two-dimensional convolutional layer; the ShuffleNet module includes a point-by-point group convolutional layer, a channel shuffle layer and a depth group convolutional layer.
[0023] Furthermore, when the CNN-Shufimag model is trained in step S204, the Adam optimizer is used, the learning rate is 0.001, the batch size is 60, and the epoch is 500.
[0024] Furthermore, the size of the mask image after filling in step S202 is 27 pixels×27 pixels×153 wavelengths.
[0025] The present invention uses hyperspectral images to identify the origin of Chinese date seeds. Hyperspectral imaging will not damage the test samples, and the detection method is simple, the time required is short, and the cost is lower than that of gas / liquid chromatography-mass spectrometry and other technologies. In combination with deep learning convolutional neural networks, the emerging deep learning convolutional neural networks (CNNs) are different from the previous machine learning methods that rely on artificial generation of specific task features. They can quickly and reliably automatically extract more discriminative features from a large amount of spectral image data to achieve the recognition task. Therefore, hyperspectral imaging technology and deep learning convolutional neural networks are of great significance in the field of identification of Chinese herbal medicine origins.
[0026] Based on hyperspectral imaging and deep learning convolutional neural network technology, the present invention realizes a fast, simple and non-destructive method for identifying the origin of Chinese jujube kernel, which is helpful to develop online or portable quality detection instruments, further ensure the product quality of Chinese jujube kernel, and maintain a fair, just and healthy market trading environment. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 The present invention provides a flowchart of a method for constructing a model for identifying the origin of spinach seeds.
[0028] Figure 2It is a Mahalanobis distance result diagram of the wild jujube seed samples from different origins in the present invention.
[0029] Figure 3 This is the architecture diagram of the CNN-Resnimag model and the CNN-Shufimag model in the present invention.
[0030] Figure 4 It is the confusion matrix of the classification results of the test set by the CNN-Resnimag model in the present invention.
[0031] Figure 5 It is the confusion matrix of the classification results of the test set by the CNN-Shufimag model in the present invention.
[0032] Figure 6 It is the confusion matrix of the classification results of the test set by the PLSDA model in the present invention.
[0033] Figure 7 It is the confusion matrix of the classification results of the test set by the SVM model in the present invention.
[0034] Figure 8 It is the architecture diagram of the CNN-Resnspec model and the CNN-Shufspec model in the present invention.
[0035] Fig. 9 It is the confusion matrix of the classification results of the test set by the CNN-Resnspec model in the present invention.
[0036] Fig.10 It is the confusion matrix of the classification results of the test set by the CNN-Shufspec model in the present invention. DETAILED DESCRIPTION
[0037] The technical solution of the present invention will be clearly and completely described below in conjunction with examples, and the described embodiments do not limit the present invention in any form.
[0038] The method for constructing the origin identification model of the spiny jujube seeds provided by the present invention is as follows: Figure 1 As shown, the specific steps include:
[0039] S1. Obtain samples of Chinese jujube kernels from at least three origins, and use a push-broom line-scanning hyperspectral reflectance imaging system to obtain hyperspectral images of all Chinese jujube kernel samples. Preprocess the acquired sample hyperspectral images, including removing redundant edge pixels and overexposed wavelength points on the core-shell surface. Use the minimum noise separation method combined with the nD visualization tool to select the kernel region of interest in the sample hyperspectral image, and construct the mask image of the Chinese jujube kernel samples from each origin based on this.
[0040] Specifically, in the embodiment of the present invention, samples of Chinese jujube seeds from five different origins, namely Hebei, Henan, Shandong, Shaanxi and Shanxi, were collected. After obtaining the Chinese jujube seeds samples from different origins, the Chinese jujube seeds samples from different origins were sieved using a 10-mesh sieve to remove gravel, incomplete seeds and impurities. Before image acquisition, the Chinese jujube seeds samples can be sealed and stored in a cool, dry and ventilated environment.
[0041] Collect the hyperspectral image of the sour jujube kernel sample, place the sour jujube kernel on a pre-designed Teflon white board, the white board contains 504 shallow grooves (28 / row × 18 / column), place a sour jujube kernel in each shallow groove, use the push-broom line scanning hyperspectral reflectance imaging system to obtain the original sample hyperspectral image of the sour jujube kernel sample, and place the white board filled with sour jujube kernels of the same geographical origin on the electric translation stage of the acquisition system. Collect white reference images and black reference images, based on the white reference images and black reference images, according to The hyperspectral image (R) of the Suanzaorensis seed sample was calculated.
[0042] Among them, R 0 is the original sample hyperspectral image collected, R W is the white reference hyperspectral image, R D Hyperspectral image for black reference.
[0043] For the embodiment of the present invention, the spectral range of the hyperspectral cube data corresponding to the obtained wild jujube kernel sample is 936nm-1720nm, the spectral resolution is 3.45nm, the image resolution is 0.32mm / pixel, and a total of five hyperspectral images are collected (corresponding to the five production areas of Hebei, Henan, Shandong, Shaanxi and Shanxi), and each image contains 504 samples from the same production area.
[0044] Furthermore, after collecting the hyperspectral image of the spinach kernel sample, the size of the hyperspectral image was first adjusted to remove the redundant edge pixels and the overexposed wavelength points caused by the smooth surface of the kernel shell, and a hyperspectral image with a size of 580 pixels × 870 pixels × 153 wavelengths was obtained; the minimum noise separation method combined with the nD visualization tool was used to select the kernel region of interest in the hyperspectral image of the sample. The mask image of the spinach kernel sample of the origin was constructed based on the selected region of interest to remove the background pixels.
[0045] S2. The masked images of all samples are processed by extracting sub-images of individual seeds of all wild jujube kernel samples and filling the sub-images, denoising the spectra of the seed pixels in the sub-images, calculating the average spectrum of the wild jujube kernel samples, and identifying and excluding abnormal sample data by calculating the Mahalanobis distance of the average spectrum of the wild jujube kernel samples.
[0046] Each sub-image containing a single spinach kernel in the sample masked image was automatically extracted by region marking and padded to keep the same size of 27 pixels × 27 pixels × 153 wavelengths for all sub-images; the spectrum of each sample pixel in the sub-image was denoised using the Savitzky-Golay smoothing and standard normal variable transformation algorithms; the average spectrum of each spinach kernel was calculated, and the Mahalanobis distance was calculated based on the average spectrum for the spinach kernel samples from each origin, as shown in Figure 2 , and identify and exclude outlier points based on Mahalanobis distance, Figure 2 The upper and lower boundary lines of each rectangle and the horizontal line inside the rectangle represent the upper quartile, lower quartile and median of the Mahalanobis distance of all samples from the corresponding origin. The boundaries of the upper and lower extension lines of the rectangle represent the upper and lower limits, and the points outside the upper and lower limits represent outlier points.
[0047] S3. After excluding the anomalies, all sample data are randomly divided into training set, validation set and test set in a ratio of 3:1:1.
[0048] The remaining sample data after excluding outliers were randomly divided into training set (1474), validation set (491) and test set (490) according to the ratio of 3:1:1, among which the validation set was used for generalization performance evaluation during model training. When divided into training set, validation set and test set, the hyperspectral image of the spinach kernel sample after excluding outliers was randomly divided into training set, validation set and test set for subsequent training and evaluation of the model based on hyperspectral image input, and the average spectrum of the spinach kernel sample after excluding outliers was randomly divided into training set, validation set and test set for subsequent training and evaluation of the model based on average spectrum input.
[0049] S4. Construct the CNN-Resnimag model and the CNN-Shufimag model, input all the sample data of the training set into the CNN-Resnimag model and the CNN-Shufimag model respectively, use cross entropy as the loss function to train the CNN-Shufimag model and the CNN-Shufimag model, and use the sample data of the validation set to evaluate the prediction performance of the CNN-Resnimag model and the CNN-Shufimag model during the training process. The data input to the CNN-Resnimag model and the CNN-Shufimag model are the hyperspectral images of the samples.
[0050] Combination Figure 3, CNN-Resnimag model and CNN-Shufimag model both include a channel compression module, which includes a two-dimensional convolution layer, which includes three convolution kernels of size 1×1, used to process the hyperspectral image of spiny jujube kernel, and transform the modeling input hyperspectral image data into a data structure that matches the input size of subsequent modules. CNN-Resnimag model also includes a Resnet module, which includes a classic residual module (five two-dimensional convolution layers, a maximum pooling layer, an Add layer, and a global average pooling layer). The data processed by the channel compression module enters the Resnet module, first passes through a two-dimensional convolution layer including 28 convolution kernels of size 3x3, then enters the maximum pooling layer after batch normalization and activation function activation, and all data coming out of the maximum pooling layer flows to two branches, one of which is a two-dimensional convolution layer (112 convolution kernels of size 1×1). This branch structure is used to reduce the difficulty of gradient back propagation during model training, reduce the complexity of model training, and improve training efficiency. The other branch is three two-dimensional convolution layers. Secondly, the data passing through the two branches (i.e., three two-dimensional convolution layers and one two-dimensional convolution layer) are batch normalized respectively, and the batch normalized data are added in the Add layer. Finally, the added data is activated by the activation function and enters the global average pooling layer.
[0051] Among them, the data processing process of the three two-dimensional convolutional layers after the maximum pooling layer is as follows: the data processed by the maximum pooling layer enters a two-dimensional convolutional layer including 28 convolution kernels of size 1×1, and then after batch normalization and activation function activation, enters a two-dimensional convolutional layer including 28 convolution kernels of size 3×3, and then after batch normalization and activation function activation, finally enters a two-dimensional convolutional layer including 112 convolution kernels of size 1×1.
[0052] Combination Figure 3,The CNN-Shufimag model also includes a ShuffleNet module, which includes a two-dimensional convolution layer, a maximum pooling layer, two pointwise group convolution layers (Pointwise Group Convolution), a channel shuffle layer (Channel Shuffle), a depth group convolution layer, an average pooling layer, a Concatenate layer and a global average pooling layer. The data processed by the channel compression module enters the ShuffleNet module, first through a two-dimensional convolution layer including 20 convolution kernels of size 3x3, and then after batch normalization and activation function activation, enters the maximum pooling layer. All data coming out of the maximum pooling layer enter a pointwise group convolution layer and an average pooling layer. The pointwise group convolution layer includes two channels, each channel is divided into 10 The data processed by the channel shuffle layer enters a deep group convolution layer, which includes one channel, each channel is divided into 120 groups, each group consists of 12 convolution kernels of size 1×1. The data processed by the deep group convolution layer enters a point-by-point group convolution layer, which includes twelve channels, each channel is divided into 10 groups, each group consists of 12 convolution kernels of size 1×1, and finally undergoes batch normalization. The data that have successively passed through the point-by-point group convolution layer, batch normalization, activation function activation, channel shuffle layer, deep group convolution layer, batch normalization, point-by-point group convolution layer and batch normalization are added to the data pooled in the average pooling layer in the concatenate layer, and the added data are activated by the activation function, and finally enter the global average pooling layer.
[0053] Among them, two point-by-point group convolution layers, a channel shuffle layer, a depth group convolution layer and an average pooling layer replace the ordinary convolution layers in the classic residual block. The point convolution and depth convolution form depth-wise separable convolution, which significantly reduces the computational cost.
[0054] Furthermore, when the preprocessed hyperspectral images of the sour jujube kernel samples were input into the CNN-Resnimag model and the CNN-Shufimag model for training, the Adam optimizer was used with a learning rate of 0.001, a batch size of 60, and an epoch of 500.
[0055] Based on two CNN architectures: CNN-Resnimag and CNN-Shufimag, a network model for identifying the origin of sour jujube kernels was developed; CNN-Resnimag was built based on the classic CNNs network architecture Resnet 50, and CNN-Shufimag was built based on the CNNs network architecture ShuffleNet; Resnet 50 is a classic deep CNN network with the advantages of easy optimization and excellent performance. Its residual learning framework can solve the degradation problem of deep networks; ShuffleNet is a classic lightweight network, mainly used in mobile devices with limited computing power. The pointwise group convolution and channel shuffle in its network structure can reduce the computing cost while maintaining the model accuracy. CNN-Shufimag combines the typical architecture of the classic lightweight network ShuffleNet: pointwise group convolution (Pointwise Group Convolution) and channel shuffle (Channel Shuffle), which has the advantages of fast computing speed and fewer learning parameters.
[0056] During the model training process, data is randomly extracted from the training set for training, then verified, and then trained and verified again until the set epoch is met. The validation set is used to evaluate the generalization performance during the model training process. During the training process, the validation set is continuously applied, and the indicators also change dynamically as the model is continuously trained in a cycle. The generalization performance of the model is evaluated by two indicators, accuracy (the larger the value, the better) and loss (the smaller the value, the better), which change dynamically during the model training process.
[0057] S5. Use the sample data of the training set, validation set, and test set to input into the trained CNN-Resnimag model and CNN-Shufimag model respectively, evaluate and compare the performance of the models, and finally determine the origin identification model of Solanum jujuba seed.
[0058] In order to compare the performance of the developed CNNs model, two classic linear and nonlinear machine learning modeling algorithms, Partial Least Squares Discriminant Analysis (PLSDA) and Support Vector Machine (SVM), were also used for modeling analysis. PLSDA is based on PLS regression to find the latent variable with the largest covariance with the dependent variable y, and then descriptive modeling. The model can be visualized based on the latent variable score and loading coefficient diagram. SVM is a powerful nonlinear classification tool that is good at identifying subtle patterns in complex data sets and creating optimal classification hyperplanes. By simplifying the calculation of nonlinear problems to linear problems in high-dimensional space, the correlation between data is obtained, thereby solving the classification task. The training set sample data after removing abnormal samples is input into the PLSDA model and the SVM model for training. The sample data input into the PLSDA model and the SVM model is the average spectrum.
[0059] The model performance was evaluated and compared using the classification accuracy corresponding to the training set, validation set and test set, the test set prediction time and the number of model parameters. The results are shown in Table 1.
[0060] Table 1: Performance comparison of CNN-Resnimag, CNN-Shufimag, PLSDA and SVM models
[0061]
[0062] The classification accuracy of the CNN-Resnimag model and the CNN-Shufimag model on the three data sets is around 0.9, the classification accuracy of the PLSDA model is around 0.75, and the SVM model has the worst classification performance, with the classification accuracy of the validation set and the test set only around 0.4. The results show that the CNN-Resnimag model and the CNN-Shufimag model have the best classification performance. The CNN-Shufimag model has a shorter prediction time and fewer modeling parameters than the CNN-Resnimag model, so it is more conducive to the application of hardware devices with limited computing power. The CNN-Resnimag model has a higher classification accuracy than the CNN-Shufimag model, and is suitable for detection methods with higher accuracy requirements.
[0063] The CNN-Resnimag model and the CNN-Shufimag model can process hyperspectral image data with higher accuracy.
[0064] The confusion matrix of the CNN-Resnimag model's prediction results for the test set is as follows: Figure 4As shown, the confusion matrix of the CNN-Shufimag model's prediction results for the test set is as follows Figure 5 As shown, the confusion matrix of the PLSDA model is as follows Figure 6 As shown, the confusion matrix of the SVM model's prediction results for the test set is as follows Figure 7 The results show that the two models have satisfactory classification effects on the samples of spiny jujube seeds from five origins.
[0065] Furthermore, it can be seen from the above embodiments of the invention that the PLSDA model and the SVM model process average spectral data, and the CNN-Resnimag model and the CNN-Shufimag model process hyperspectral images. When the CNN-Resnimag model and the CNN-Shufimag model use average spectral data as input, the structures of the CNN-Resnimag model and the CNN-Shufimag model need to be modified to obtain the CNN-Resnspec and CNN-Shufspec model architectures, such as Figure 8 As shown, the feature extraction module replaces the channel compression module. The feature extraction module includes a feature selection layer. The parameter settings of other two-dimensional convolution layers, point-by-point group convolution layers, channel shuffle layers, and depth group convolution layers also change according to the change of input data type.
[0066] In the above scheme, the CNN-Resnimag model and the CNN-Shufimag model use the hyperspectral image of the sour jujube kernel as input, and the PLSDA model and the SVM model use the average spectrum of the sour jujube kernel as input. In order to further ensure the fairness of the model comparison, the CNN-Resnspec model and the CNN-Shufspe model with the average spectrum of the sour jujube kernel as input are used for comparative analysis.
[0067] The main structures of the CNN-Resnspec model and the CNN-Shufspec model with the average spectrum of the spinach kernel as input are as follows: Figure 8As shown, both the CNN-Resnspec model and the CNN-Shufspec model include a feature extraction module, which is composed of a custom feature selection layer. The selection layer outputs the result of element multiplication (i.e., λ·W, where λ represents the wavelength vector and W represents the learnable weight vector) to the next layer. The size of the learnable weight vector of this layer is 1×153. The numerical value of the weight learned after the model training is completed represents the modeling importance of the corresponding wavelength. The Resnet module in the CNN-Resnspec model includes a two-dimensional convolution layer, which includes 112 convolution kernels of size 3x3. The two-dimensional convolution layer processes the data after the feature extraction module, and then enters the maximum pooling layer after batch normalization and activation function activation. All data processed from the maximum pooling layer flows to two branches, one of which is a two-dimensional convolution layer (448 convolution kernels of size 1×1). This branch structure is used to reduce the difficulty of gradient back propagation during model training, reduce the complexity of model training, and improve training efficiency. The other branch is three two-dimensional convolution layers. Secondly, the data passing through the two branches (i.e., three two-dimensional convolution layers and one two-dimensional convolution layer) are batch normalized respectively, and the batch normalized data are added in the Add layer. Finally, the added data is activated by the activation function and enters the global average pooling layer.
[0068] Among them, the data processing process of the three two-dimensional convolutional layers after the maximum pooling layer is as follows: the data processed by the maximum pooling layer enters a two-dimensional convolutional layer including 112 convolution kernels of size 1×1, and then after batch normalization and activation function activation, enters a two-dimensional convolutional layer including 112 convolution kernels of size 3×3, and then after batch normalization and activation function activation, finally enters a two-dimensional convolutional layer with 448 convolution kernels of size 1×1.
[0069] Combination Figure 8In the CNN-Shufspec model, the ShuffleNet module includes a two-dimensional convolution layer, which processes the data processed by the channel compression module, and then enters the maximum pooling layer after batch normalization and activation function activation. All data coming out of the maximum pooling layer enter a point-by-point group convolution layer and an average pooling layer. The point-by-point group convolution layer includes eight channels, each channel is divided into 10 groups, each group has 48 convolution kernels of size 1×1, and the data after the point-by-point group convolution layer is batch normalized and activated by the activation function, and enters the channel shuffle layer. The data processed by the channel shuffle layer enters a deep group convolution layer including one channel, each channel is divided into 480 groups, each group has 1 convolution kernel of size 3×3, and the data processed by the deep group convolution layer enters a point-by-point group convolution layer including forty-eight channels, each channel is divided into 10 groups, each group has 48 convolution kernels of size 1×1, and finally batch normalization is performed. The data that have passed through the point-by-point group convolution layer, batch normalization, activation function activation, channel shuffling layer, depth group convolution layer, batch normalization, point-by-point group convolution layer and batch normalization in sequence are added with the data pooled in the average pooling layer in the concatenate layer, and the added data are activated by the activation function and finally enter the global average pooling layer.
[0070] The average spectrum of the jujube seed samples in the training set was used to train the CNN-Resnspec model and the CNN-Shufspec model. The classification accuracy of the training set, validation set and test set, the prediction time of the test set and the number of model parameters were used to evaluate and compare the model performance. The results are shown in Table 2.
[0071] Table 2: Performance comparison of CNN-Resnspec model, CNN-Shufspec model, PLSDA model and SVM model
[0072]
[0073] Among them, the confusion matrix of the prediction results of the CNN-Resnspec model test set is as follows Fig. 9 As shown, the confusion matrix of the CNN-Shufspec model for the test set prediction results is as follows Fig.10 shown.
[0074] As shown in Table 2, the classification accuracy of the CNN-Resnspec model and the CNN-Shufspec model on the three data sets is around 0.8, the classification accuracy of the PLSDA model is around 0.75, and the SVM model has the worst classification performance, with the classification accuracy of the validation set and the test set only around 0.4. The results show that the CNN-Resnspec model and the CNN-Shufspec model have the best classification performance. Combined with Tables 1 and 2, the CNN-Resnspec model and the CNN-Shufspec model have better classification performance than the CNN-Resnimag model and the CNN-Shufimag model for detecting hyperspectral images.
[0075] The CNN-Resnimag model and the CNN-Shufimag model proposed in the present invention can both accurately classify and identify the spinach seed samples from different origins, with the model classification accuracy reaching 0.9, and can be used for the development of spinach seed identification equipment and instruments from different origins.
[0076] Near Infrared spectroscopy (NIR) can analyze the composition information of materials based on the vibration absorption of chemical bonds. It has the advantages of non-destructive, rapid and online detection. It has been widely used in the field of origin identification of various traditional Chinese medicines, extra virgin olive oil, oolong tea, green coffee beans, etc. Hyperspectral imaging (HSI) technology expands the point average of the near-infrared spectrum to a two-dimensional image with higher spatial resolution, and has stronger detection capabilities in obtaining internal and external information of the object being tested. Hyperspectral imaging will not damage the test sample, and the detection method is simple and the time required is short. The emerging deep learning convolutional neural network (CNNs) is different from the previous machine learning methods that rely on artificial generation of specific task features. It can quickly and reliably extract more discriminative discriminant features from a large amount of spectral image data to achieve identification tasks. Therefore, hyperspectral imaging technology and deep learning convolutional neural networks are of great significance in the field of origin identification of traditional Chinese medicines.
[0077] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any equivalent replacement or change made according to the technical solution and inventive concept of the present invention within the technical scope disclosed by the present invention should be included in the protection scope of the present invention.
Claims
1. A method for constructing a model for identifying the origin of spinach seeds, characterized in that: The following steps are involved: S101. Obtain samples of sour jujube kernels from at least three origins, obtain hyperspectral images of all sour jujube kernel samples using a push-broom line scanning hyperspectral reflectance imaging system, perform preprocessing on the obtained sample hyperspectral images, including removing redundant edge pixels and overexposed wavelength points on the core-shell surface, use a minimum noise separation method combined with an nD visualization tool to select a region of interest for the kernel in the sample hyperspectral images, and construct a mask image of the sour jujube kernel samples from each origin based on the preprocessing; S102, performing processing on all sample masked images, including extracting sub-images of individual seeds of all wild jujube seed samples and filling the sub-images, denoising the spectra of the seed pixel points in the sub-images, calculating the average spectrum of the wild jujube seed samples, and identifying and excluding abnormal sample data by calculating the Mahalanobis distance of the average spectrum of the wild jujube seed samples; S103, randomly dividing all sample data after excluding abnormalities into a training set, a validation set, and a test set in a ratio of 3:1:1; S104, constructing a CNN-Resnimag model, inputting the sample data of the training set into the CNN-Resnimag model and training the model using cross entropy as a loss function, and using the sample data of the validation set to evaluate the prediction performance of the CNN-Resnimag model during the training process; S105. Input the sample data of the training set, validation set and test set into the trained CNN-Resnimag model respectively, and evaluate and compare the performance of the model.
2. The method for constructing the origin identification model of Suanzaorensis seeds according to claim 1, characterized in that: The CNN-Resnimag model in step S104 includes a channel compression module and a Resnet module; the channel compression module includes a two-dimensional convolutional layer; and the Resnet module includes a classic residual module.
3. The method for constructing the origin identification model of Suanzaorensis seeds according to claim 1, characterized in that: When training the CNN-Resnimag model in step S104, the Adam optimizer is used, the learning rate is 0.001, the batch size is 60, and the epoch is 500.
4. The method for constructing the origin identification model of Suanzaorensis seeds according to claim 1, characterized in that: The size of the mask image after filling in step S102 is 27 pixels×27 pixels×153 wavelengths.
5. A method for constructing a model for identifying the origin of spinach seeds, characterized in that: The following steps are involved: S201. Obtain samples of sour jujube kernels from at least three origins, obtain hyperspectral images of all sour jujube kernel samples using a push-broom line scanning hyperspectral reflectance imaging system, perform preprocessing on the obtained sample hyperspectral images, including removing redundant edge pixels and overexposed wavelength points on the core-shell surface, use a minimum noise separation method combined with an nD visualization tool to select a region of interest for the kernel in the sample hyperspectral image, and construct a mask image of the sour jujube kernel samples from each origin based on the preprocessing; S202, performing processing on the masked images of all samples, including extracting sub-images of individual seeds of all wild jujube seed samples and filling the sub-images, denoising the spectra of the seed pixel points in the sub-images, calculating the average spectrum of the wild jujube seed samples, and identifying and excluding abnormal sample data by calculating the Mahalanobis distance of the average spectrum of the wild jujube seed samples; S203, randomly dividing all sample data after excluding abnormalities into a training set, a validation set, and a test set in a ratio of 3:1:1; S204, constructing a CNN-Shufimag model, inputting the sample data of the training set into the CNN-Shufimag model and training the model using cross entropy as a loss function, and using the sample data of the validation set to evaluate the prediction performance of the CNN-Shufimag model during the training process; S205. Input the sample data of the training set, validation set and test set into the trained CNN-Shufimag model respectively, and evaluate and compare the performance of the model.
6. The method for constructing the origin identification model of Suanzaorensis seeds according to claim 5, characterized in that: The CNN-Shufimag model in step S204 includes a channel compression module and a ShuffleNet module; the channel compression module includes a two-dimensional convolution layer; the ShuffleNet module includes a point-by-point group convolution layer, a channel shuffle layer and a depth group convolution layer.
7. The method for constructing the origin identification model of Suanzaorensis seeds according to claim 5, characterized in that: When training the CNN-Shufimag model in step S204, the Adam optimizer is used, the learning rate is 0.001, the batch size is 60, and the epoch is 500.
8. The method for constructing the origin identification model of Suanzaorensis seeds according to claim 5, characterized in that: The size of the mask image after filling in step S202 is 27 pixels×27 pixels×153 wavelengths.