Method for rapidly identifying production places of traditional Chinese medicinal materials based on hyperspectral technology and neural network

By combining hyperspectral technology and neural networks, a system that can quickly and accurately identify the origin of Chinese medicinal materials is built, solving the problems of low accuracy and time-consuming identification in the existing technology, and achieving efficient and economical identification results.

CN119810671AActive Publication Date: 2025-04-11HEFEI UNIV OF TECH
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202510103295.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-22
Publication Date
2025-04-11
Estimated Expiration
2045-01-22

AI Technical Summary

Technical Problem

The existing astragalus origin identification methods have low accuracy, time-consuming and labor-intensive, high cost, and the inability to quickly screen a large number of samples. Especially when the spectral characteristics of astragalus in different origins are similar, resulting in inaccurate identification results.

Method used

The rapid identification method of origin of traditional Chinese medicinal materials based on hyperspectral technology and neural network is adopted. The hyperspectral reflectivity samples of traditional Chinese medicinal materials are obtained through the hyperspectral acquisition module, pre-processed using the data processing module, construct a convolutional neural network for training, and deployed to the ZYNQ processing system for rapid identification.

Benefits of technology

It realizes fast, accurate and lossless identification of the origin of traditional Chinese medicinal materials, improves detection efficiency, reduces costs, and ensures high reliability and high accuracy of identification results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119810671A_ABST
    Figure CN119810671A_ABST
Patent Text Reader

Abstract

The invention discloses a traditional Chinese medicinal material production place rapid identification method based on a hyperspectral technology and a neural network, which is applied to a system composed of a hyperspectral acquisition module, a data processing module, a neural network training module and a ZYNQ processing system. The ZYNQ processing system comprises a VDMA module, a CNN module, a clock control module, a data conversion module, a DDR3 storage unit, an HDMI control module, an ARM module and an SD card. Spectrums of traditional Chinese medicinal materials in different producing areas are collected through a hyperspectral camera, weight parameters are obtained through neural network training, a model is integrated into a ZYNQ system, the model is used for achieving prediction of recognition of the traditional Chinese medicinal materials in different producing areas, and a final recognition result is displayed on an HDMI display screen. According to the method, spectral differences of traditional Chinese medicinal materials in different producing areas are represented through a ZYNQ platform by using a deep learning technology, so that prediction results of the traditional Chinese medicinal materials in different producing areas are displayed losslessly, efficiently and quickly.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of hyperspectral intelligent detection of Chinese medicinal material origins, and specifically is a method for quickly identifying Chinese medicinal material origins based on hyperspectral technology and neural networks. Background Art

[0002] As a common traditional medicinal material, Astragalus has significant regional characteristics, especially in Hengshan production areas such as Hunyuan County, Datong City, Shanxi Province, where the simulated wild planting model used by traditional authentic medicinal materials has a history of hundreds of years. Under this model, Astragalus needs to grow in the wild environment for more than 8 years before it can be picked. Shaanxi Province also has a similar simulated wild planting model, which has been planted on a large scale for more than 20 years and usually requires more than 5 years of growth. In contrast, field-grown Astragalus is generally planted through a two-year cycle of seedling cultivation and transplanting (called transplanted Astragalus or fast-growing Astragalus), which is mainly distributed in Inner Mongolia and Gansu, especially in the western and eastern production areas of Inner Mongolia, Longzhong and Longbei in Gansu. Of the annual demand for Astragalus, the output of simulated wild Astragalus accounts for only about 1 / 30. Limited by the planting years and the difficulty of excavation, the price of medicinal materials of the same specifications is about 10 times that of transplanted Astragalus. In addition, there are a large number of reports pointing out that there are very obvious differences in the composition and structure of Astragalus polysaccharides from different origins and different planting patterns. At present, there are a lot of transplanted astragalus in the market, posing as the wild astragalus from Shanxi. Even in the export trade, transplanted astragalus accounts for a large share, which has a great impact and damage on the reputation of authentic medicinal materials. Therefore, it is urgent to establish a rapid identification system for astragalus from different origins.

[0003] Existing methods for identifying the origin of Astragalus include manual identification, chemical analysis, near-infrared spectroscopy, etc. Among them, manual identification is highly dependent on the experience of experts, is greatly affected by subjective factors, and is time-consuming and labor-intensive, increasing the cost of identification, especially in the case of large-scale testing; chemical analysis is complex and costly, and is usually destructive, and is not suitable for rapid screening of a large number of samples; and although near-infrared is a non-destructive and rapid analysis method, Astragalus from different origins may have certain similarities in chemical cost, resulting in relatively close near-infrared spectral characteristics, especially when Astragalus is greatly affected by environmental factors during its growth process, there may be a large overlap in spectral data, affecting accuracy.

[0004] Through patent search, it was found that the publication number CN116630675A discloses a method for identifying the origin of Astragalus based on ultraviolet spectroscopy and convolutional neural network, including obtaining ultraviolet spectral data of Astragalus from different origins to be detected and collecting Raman spectral data corresponding to Astragalus from different origins for training, and iterating the ultraviolet spectral data of Astragalus from different origins to be detected into the trained one-dimensional convolutional neural network for detection. The present invention proposes a method for rapid identification of the origin of Chinese herbal medicine based on hyperspectral technology and neural network, which can obtain continuous spectral data in a wider spectral range and provide higher resolution spectral information, so as to more effectively distinguish samples from different origins; at the same time, based on the ZYNQ platform, the hardware acceleration of the neural network is realized, thereby improving the overall computing efficiency and rapid identification capabilities. Summary of the invention

[0005] The present invention aims to solve the deficiencies of the above-mentioned prior art and proposes a method for rapid identification of the origin of Chinese medicinal materials based on hyperspectral technology and neural networks, in order to overcome the limitations of traditional methods through the combination of hyperspectral data and neural network models, thereby achieving rapid, accurate and non-destructive identification of the origin of Chinese medicinal materials, improving detection efficiency, reducing costs, and ensuring high reliability and high precision of identification results.

[0006] In order to achieve the above-mentioned purpose, the present invention adopts the following technical scheme:

[0007] The invention discloses a method for quickly identifying the origin of Chinese medicinal materials based on hyperspectral technology and neural network, which is applied to a system composed of a hyperspectral acquisition module, a data processing module, a neural network training module, and a ZYNQ processing system, wherein the ZYNQ processing system includes: a VDMA module, a CNN module, a clock control module, a data conversion module, a DDR3 storage unit, an HDMI control module, an ARM module, and an SD card; the method for quickly identifying the origin of Chinese medicinal materials is carried out according to the following steps:

[0008] S1, the hyperspectral acquisition module acquires Hyperspectral reflectance sample sets of Chinese medicinal materials from different origins ,in, Indicates hyperspectral band reflectance samples, and , express In the The reflectance value corresponding to each band is , , represents the number of samples, represents the total number of bands; let The real origin category label is recorded as ,and ∈[1,…,t,…,M], t represents the serial number of any category;

[0009] S2, using the data processing module Preprocessing is performed to obtain a preprocessed Chinese herbal medicine hyperspectral reflectance sample set ,in, After preprocessing, hyperspectral band reflectance samples, and , express In the The reflectance value corresponding to each band;

[0010] S3, build a convolutional neural network with a neural network backbone architecture, and use The convolutional neural network is trained to obtain a trained model for rapid identification of origin of Chinese herbal medicines;

[0011] S4. Deploy the rapid identification model of the origin of Chinese medicinal materials into the ZYNQ processing system to realize the identification of the origin of Chinese medicinal materials.

[0012] The method for rapid identification of origin of Chinese herbal medicine based on hyperspectral technology and neural network of the present invention is also characterized in that S2 comprises:

[0013] S2.1, use YOLO target detection algorithm Automatically extract ROI to obtain the target ROI data set ,in, express The target ROI area in , express Middle The reflectance value corresponding to each band;

[0014] S2.2, using formula (1) After noise smoothing, we get No. The smoothed reflectivity corresponding to each band , thus obtaining the smoothed target ROI data set , and then obtain the smoothed target ROI data set :

[0015] (1)

[0016] In formula (1), yes Middle The reflectance value corresponding to each band is is the kth coefficient of the smoothing window, is the half-width of the smoothing window;

[0017] S2.3, using formula (2) After eliminating the deviation, we get No. The reflectivity after eliminating the deviation of each band , thus obtaining a data set after eliminating bias , and then get the final preprocessed data set :

[0018] (2)

[0019] In formula (2), Indicates The mean of the total band reflectance values ​​of the hyperspectral band reflectance samples, and , Indicates The standard deviation of the total band reflectance values ​​of the hyperspectral band reflectance samples, .

[0020] Furthermore, S3 includes:

[0021] S3.1, constructing the convolutional neural network including: five layers of convolutional units and a classifier;

[0022] S3.1.1, the first convolutional unit, including: convolutional layer, batch normalization layer, activation layer and pooling layer;

[0023] S3.1.1.1. The convolutional layer in the first convolutional unit uses formula (3) to Perform convolution calculation and get The first hyperspectral band reflectance sample The convolution result corresponding to each band , so the dimension is No. Convolutional layer output dataset of hyperspectral band reflectance samples ,in, Represents the number of convolution kernels in the first layer of convolutional units:

[0024] (3)

[0025] In formula (3), express In the +n bands corresponding to the reflectivity value, represents the convolution kernel corresponding to the nth position, Indicates the size of the convolution kernel;

[0026] S3.1.1.2, the batch normalization layer in the first convolutional unit uses equations (4) and (5) to Process it and get The first hyperspectral band reflectance sample The batch results corresponding to the bands , so the dimension is No. Batch normalized output dataset of hyperspectral band reflectance samples :

[0027] (4)

[0028] (5)

[0029] In formula (4) and formula (5), Indicates The first hyperspectral band reflectance sample The normalized reflectance value corresponding to each band is Represents the reflectance sample of the i-th hyperspectral band The mean of , Represents the reflectance sample of the i-th hyperspectral band The variance of , Represents a parameter used to prevent division by zero; , Respectively The scaling factor and A translation factor;

[0030] S3.1.1.3, the activation layer in the first convolutional unit uses formula (6) Processing is performed to obtain the reflectivity of the activation layer after activation , so the dimension is No. Activated reflectance dataset with reflectance samples in hyperspectral bands :

[0031] (6)

[0032] In formula (6), ReLU represents the activation function;

[0033] S3.1.1.4, the pooling layer in the first convolutional unit uses formula (7) Processing is performed to obtain the reflectivity after pooling , so the dimension is No. Pooled reflectance dataset of hyperspectral band reflectance samples , and then obtain the high-spectral reflectance sample set of Chinese medicinal materials output by the first convolution unit ,in, express The characteristic length of , Represents a pooling window:

[0034] (7)

[0035] In formula (7), Indicates The first hyperspectral band reflectance sample arrive Reflectivity within the band range;

[0036] S3.1.2, the second convolution unit performs steps S3.1.1.1 to S3.1.1.4 in sequence After processing, the high-spectral reflectance sample set of Chinese medicinal materials output by the second convolution unit is obtained. ,in, The dimension of the output of the second convolution unit is No. A pooled reflectance dataset of hyperspectral band reflectance samples, and , express After pooling The reflectivity of each band, Represents the number of convolution kernels in the second layer of convolutional units, express The characteristic length of ;

[0037] S3.1.3, the third convolution unit performs steps S3.1.1.1 to S3.1.1.4 in sequence After processing, the hyperspectral reflectance sample set of Chinese medicinal materials output by the third convolution unit is obtained. ,in, The dimension of the output of the third convolution unit is No. A pooled reflectance dataset of hyperspectral band reflectance samples, and , express After pooling The reflectance value of each band, Represents the number of convolution kernels in the third layer of convolutional units, express The characteristic length of ;

[0038] S3.1.4, the fourth convolution unit performs steps S3.1.1.1 to S3.1.1.4 in sequence After processing, the hyperspectral reflectance sample set of Chinese medicinal materials output by the fourth convolution unit is obtained. ,in, The output dimension of the fourth convolution unit is No. A pooled reflectance dataset of hyperspectral band reflectance samples, and , express After pooling The reflectance value of each band, Represents the number of convolution kernels in the fourth layer convolution unit, express The characteristic length of ;

[0039] S3.1.5, the fifth convolution unit performs steps S3.1.1.1 to S3.1.1.4 in sequence After processing, the high-spectral reflectance sample set of Chinese medicinal materials output by the fifth convolution unit is obtained. ,in, The dimension of the output of the fifth convolutional unit is The A pooled reflectance dataset of hyperspectral band reflectance samples, and , express After pooling The reflectance value of each band, Represents the number of convolution kernels in the fifth layer of convolutional units, express The characteristic length of ; ;

[0040] S3.1.6, the classifier comprises: a fully connected layer and a Softmax layer;

[0041] Will After flattening, the dimensions become The sample set of Chinese medicinal materials with high spectral reflectance is input into the fully connected layer for processing, and the dimension is The score vector ,in, express In the The corresponding score value for each category;

[0042] The Softmax layer uses formula (8) to Calculate and get Belong to The probability of the categories , and take the category corresponding to the maximum probability as the predicted origin category label:

[0043] (8)

[0044] S3.2. Construct a cross-entropy loss function based on the real origin category labels and predicted origin category labels, which is used to train and test the convolutional neural network to update the network parameters until the cross-entropy loss function converges, thereby obtaining a rapid identification model of the origin of Chinese medicinal materials corresponding to the optimal parameters and saving the weight parameters with the highest test accuracy.

[0045] Furthermore, S4 includes:

[0046] S4.1. Use the HLS hardware description language to write the Chinese medicinal materials origin rapid identification model and encapsulate it into an IP core and then deploy it to the CNN module of the ZYNQ processing system;

[0047] S4.2. Under the drive of the clock control module, the ARM module reads the spectral data to be tested and the Astragalus pictures of the corresponding origin stored in the SD card, and sends them to the DDR3 storage unit for storage; at the same time, the spectral data to be tested is sent to the IP core in the CNN module for processing to obtain the predicted origin category label of the spectral data to be tested;

[0048] S4.3, under the drive of the clock control module, the data conversion module converts the astragalus picture into an astragalus picture in AXI-stream format and sends it to the CNN module;

[0049] S4.4. Under the drive of the clock control module, the VDMA module reads the spectrum data to be measured and its predicted origin category label through the AXI protocol and stores them in the DDR3 storage unit;

[0050] S4.5. After the CNN module matches the predicted origin category label with the Astragalus picture of its corresponding origin, it sends it to the VDMA module. Then, under the drive of the clock control module, the VDMA module sends the predicted origin category label and its matching Astragalus picture to the HDMI control module, so that the HDMI control module uses the HDMI display to display the predicted origin category label and its matching Astragalus picture.

[0051] The electronic device of the present invention includes a memory and a processor, wherein the memory is used to store a program that supports the processor to execute the rapid identification system of the origin of traditional Chinese medicine based on hyperspectral technology and neural network, and the processor is configured to execute the program stored in the memory.

[0052] The present invention provides a computer-readable storage medium, and the computer-readable storage medium stores a computer program, wherein the computer program is executed by a processor to execute the steps of the rapid identification system of the origin of traditional Chinese medicine based on hyperspectral technology and neural network.

[0053] Compared with the prior art, the present invention has the following beneficial effects:

[0054] 1. The present invention uses hyperspectral imaging technology. Compared with traditional manual identification, chemical analysis and near-infrared spectral analysis technology, hyperspectral technology has a wider spectral range and higher spectral resolution. It can obtain richer spectral data and use more complex algorithms for data processing, so it can more accurately distinguish and analyze complex samples.

[0055] 2. Compared with traditional classification algorithms, the convolutional neural network used in the present invention can automatically learn and extract effective features from raw data, and can always achieve a higher classification accuracy;

[0056] 3. The present invention takes into account real-time processing and rapid recognition, and selects ZYNQ as the platform for hardware implementation of convolutional neural networks, which provides a high degree of parallel computing capabilities, low power consumption and high efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] Figure 1 It is a schematic diagram of the structure of the method for rapid identification of origin of Chinese herbal medicine based on hyperspectral technology and neural network of the present invention;

[0058] Figure 2 A schematic diagram of a collection system in an embodiment of the present invention;

[0059] Figure 3 The average spectrum of seven kinds of astragalus from different origins after pretreatment in the embodiment of the present invention;

[0060] Figure 4 Schematic diagram of the ZYNQ processing system in an embodiment of the present invention. DETAILED DESCRIPTION

[0061] In order to further understand the technical solution of the present invention, it is described in detail below with reference to the accompanying drawings.

[0062] In this embodiment, if Figure 1As shown, a method for quickly identifying the origin of Chinese medicinal materials based on hyperspectral technology and neural network includes the following steps:

[0063] S1. Hyperspectral acquisition module acquisition Hyperspectral reflectance sample sets of Chinese medicinal materials from different origins ,in, Indicates hyperspectral band reflectance samples, and , express In the The reflectance value corresponding to each band is , , represents the number of samples, represents the total number of bands; let The real origin category label is recorded as ,and ∈[1,…,t,…,M], t represents the tth category; specifically, in this embodiment, a hyperspectral reflectance sample set of Astragalus from seven different origins was collected, which contains spectral information of 204 bands.

[0064] S1.1, if Figure 2 As shown, a hyperspectral camera is used to collect hyperspectral reflectance data of Chinese medicinal materials and hyperspectral reflectance data of a whiteboard, the hyperspectral reflectance data of the Chinese medicinal materials are calibrated using the whiteboard reflectance data information, and the calibrated hyperspectral reflectance data of the Chinese medicinal materials are converted into a .csv format to form a hyperspectral reflectance sample set A of the Chinese medicinal materials;

[0065] S1.2. Label the hyperspectral reflectance sample set A of traditional Chinese medicine.

[0066] S2, using the data processing module Preprocessing is performed to obtain a preprocessed Chinese herbal medicine hyperspectral reflectance sample set ,in, After preprocessing, hyperspectral band reflectance samples, and , express In the The reflectance value corresponding to each band; specifically, the preprocessing includes ROI extraction and spectral preprocessing; ROI extraction includes using the software ENVI to extract the region of interest; spectral preprocessing includes SG smoothing and multivariate scatter correction (MSC) to reduce noise interference and eliminate spectral differences;

[0067] S2.1, use YOLO target detection algorithm Automatically extract ROI to obtain the target ROI data set ,in, express The target ROI area in , express Middle The reflectance value corresponding to each band.

[0068] S2.2, using formula (1) After noise smoothing, we get No. The smoothed reflectivity corresponding to each band , thus obtaining the smoothed target ROI data set , and then obtain the smoothed target ROI data set :

[0069] (1)

[0070] In formula (1), yes Middle The reflectance value corresponding to each band is is the kth coefficient of the smoothing window, is the half-width of the smoothing window.

[0071] S2.3, using formula (2) After eliminating the deviation, we get No. The reflectivity after eliminating the deviation of each band , thus obtaining a data set after eliminating bias , and then get the final preprocessed data set :

[0072] (2)

[0073] In formula (2), Indicates The mean of the total band reflectance values ​​of the hyperspectral band reflectance samples, and , Indicates The standard deviation of the total band reflectance values ​​of the hyperspectral band reflectance samples, .

[0074] In the specific implementation, before the neural network training, when SG smoothing and multivariate scatter correction are used to preprocess the data set, the window size is set to 5 and the polynomial order is set to 2 during the SG smoothing operation; Figure 3 As shown, the average spectra of Astragalus membranaceus from seven different origins after pretreatment were obtained.

[0075] S3, build a convolutional neural network with a neural network backbone architecture, and use The convolutional neural network is trained to obtain a trained model for rapid identification of origin of Chinese herbal medicines;

[0076] S3.1. In order to take into account the requirements of model deployment and classification accuracy, one-dimensional convolution is used to learn the spectral features of D. The convolutional neural network is constructed including: five layers of convolution units and a classifier;

[0077] S3.1.1, the first convolutional unit, including: convolutional layer, batch normalization layer, activation layer and pooling layer;

[0078] S3.1.1.1. The convolutional layer in the first convolutional unit uses formula (3) to Perform convolution calculation and get The first hyperspectral band reflectance sample The convolution result corresponding to each band , so the dimension is No. Convolutional layer output dataset of hyperspectral band reflectance samples ,in, Indicates the number of convolution kernels in the first layer of convolutional units:

[0079] (3)

[0080] In formula (3), express In the +n bands corresponding to the reflectivity value, represents the convolution kernel corresponding to the nth position, Indicates the size of the convolution kernel.

[0081] S3.1.1.2, the batch normalization layer in the first convolutional unit uses equations (4) and (5) to Process it and get The first hyperspectral band reflectance sample The batch results corresponding to the bands , so the dimension is No. Batch normalized output dataset of hyperspectral band reflectance samples :

[0082] (4)

[0083] (5)

[0084] In formula (4) and formula (5), Indicates The first hyperspectral band reflectance sample The normalized reflectance value corresponding to each band is Represents the reflectance sample of the i-th hyperspectral band The mean of , Represents the reflectance sample of the i-th hyperspectral band The variance of , Represents a parameter used to prevent division by zero; , Respectively The scaling factor and A translation factor.

[0085] S3.1.1.3, the activation layer in the first convolutional unit uses formula (6) Processing is performed to obtain the reflectivity of the activation layer after activation , so the dimension is No. Activated reflectance dataset with reflectance samples in hyperspectral bands :

[0086] (6)

[0087] In formula (6), ReLU represents the activation function.

[0088] S3.1.1.4. The pooling layer in the first convolutional unit uses formula (7) to Processing is performed to obtain the reflectivity after pooling , so the dimension is No. Pooled reflectance dataset of hyperspectral band reflectance samples , and then obtain the high-spectral reflectance sample set of Chinese medicinal materials output by the first convolution unit ,in, express The characteristic length of , Represents a pooling window:

[0089] (7)

[0090] In formula (7), Indicates The pooling range of hyperspectral band reflectance samples, Indicates The first hyperspectral band reflectance sample arrive Band.

[0091] S3.1.2, the second convolution unit performs steps S3.1.1.1 to S3.1.1.4 in sequence After processing, the high-spectral reflectance sample set of Chinese medicinal materials output by the second convolution unit is obtained. ,in, The dimension of the output of the second convolution unit is No. A pooled reflectance dataset of hyperspectral band reflectance samples, and , express After pooling The reflectivity of each band, Represents the number of convolution kernels in the second layer of convolutional units, express The characteristic length of .

[0092] S3.1.3, the third convolution unit performs steps S3.1.1.1 to S3.1.1.4 in sequence After processing, the hyperspectral reflectance sample set of Chinese medicinal materials output by the third convolution unit is obtained. ,in, The dimension of the output of the third convolution unit is No. A pooled reflectance dataset of hyperspectral band reflectance samples, and , express After pooling The reflectance value of each band, Represents the number of convolution kernels in the third layer of convolutional units, express The characteristic length of .

[0093] S3.1.4, the fourth convolution unit performs steps S3.1.1.1 to S3.1.1.4 in sequence After processing, the hyperspectral reflectance sample set of Chinese medicinal materials output by the fourth convolution unit is obtained. ,in, The output dimension of the fourth convolution unit is No. A pooled reflectance dataset of hyperspectral band reflectance samples, and , express After pooling The reflectance value of each band, Represents the number of convolution kernels in the fourth layer convolution unit, express The characteristic length of .

[0094] S3.1.5, the fifth convolution unit performs steps S3.1.1.1 to S3.1.1.4 in sequence After processing, the high-spectral reflectance sample set of Chinese medicinal materials output by the fifth convolution unit is obtained. ,in, The dimension of the output of the fifth convolutional unit is The A pooled reflectance dataset of hyperspectral band reflectance samples, and , express After pooling The reflectance value of each band, Represents the number of convolution kernels in the fifth layer of convolutional units, express The characteristic length of ; .

[0095] S3.1.6, the classifier includes: a fully connected layer and a Softmax layer;

[0096] Will After flattening, the dimensions become The sample set of Chinese medicinal materials with high spectral reflectance is input into the fully connected layer for processing, and the dimension is The score vector ,in, express In the The corresponding score value for each category.

[0097] The Softmax layer uses formula (8) to Calculate and get Belong to The probability of the categories , and take the category corresponding to the maximum probability as the predicted origin category label:

[0098] (8)

[0099] S3.2. A cross-entropy loss function is constructed based on the real origin category labels and the predicted origin category labels, which is used to train the convolutional neural network to update the network parameters until the cross-entropy loss function converges, thereby obtaining a rapid identification model for the origin of Chinese medicinal materials corresponding to the optimal parameters.

[0100] In this embodiment, the preprocessed data set D is divided into a training set and a test set at a ratio of 8:2; the network parameters are set as follows: the training batch batch_size is set to 32, the loss function adopts the cross entropy loss function, the Adam optimizer is selected, the number of training times is 300, the learning rate is set to 0.001, and the learning rate is reduced by 10% on the original basis every 100 times.

[0101] After training, the best weight parameters are saved in best_model.pth, and the bias and weight of each layer are output separately. The final accuracy of the training set is 100%, and the accuracy of the test set is 97.4%.

[0102] S4. Deploy the rapid identification model of the origin of Chinese medicinal materials into the ZYNQ processing system to realize the identification of the origin of Chinese medicinal materials.

[0103] In this embodiment, if Figure 4 As shown, the ZYNQ processing system includes: VDMA module, CNN module, clock control module, data conversion module, DDR3 storage unit and HDMI control module, ARM module, SD card;

[0104] S4.1. Use HLS hardware description language to write a model for rapid identification of the origin of Chinese herbal medicines and encapsulate it into an IP core and deploy it in the CNN module of the ZYNQ processing system. Specifically, decompose the model for rapid identification of the origin of Chinese herbal medicines in the CNN module into multiple independent and synthesizable modules such as convolution layer, pooling layer, activation layer, etc., and use C language combined with specific instructions in HLS to implement each module. Among them, the most important thing is to implement the convolution operation in the convolution layer, and use a loop structure to traverse the input spectral data kernel convolution kernel;

[0105] At the same time, define the input and output interfaces of each module to guide the HLS tool to correctly handle data transmission and interaction when synthesizing the C language code into hardware circuits. Let:

[0106] #pragma HLS INTERFACE s_axilite port=return bundle=CONTROL

[0107] #pragma HLS INTERFACE m_axi depth=7 port=data_out offset=slave bundle=OUT

[0108] #pragma HLS INTERFACE m_axi depth=204 port=data_in offset=slavebundle=IN

[0109] Among them, #pragma HLS INTERFACE is used to specify the communication method between the function interface and the hardware in the HLS design, s_axilite indicates the AXI Lite protocol for controlling registers, m_axi indicates the master-slave AXI protocol for high bandwidth, port indicates the name used to specify the interface, port=return indicates the interface related to the return value of the function, port=data_in and port=data_out respectively indicate the input and output interfaces, which are used to transmit data from the outside to the hardware module or from the hardware module to the outside, depth=7 and depth=204 respectively indicate that the FIFO buffer depth of the interface is 7 or 204, offset=slave indicates that this is a slave device port, bundle=CONTROL, bundle=OUT and bundle=IN respectively indicate that the interface port is bundled with the interfaces named IN, OUT and CONTROL.

[0110] Furthermore, a test platform is built in the HLS environment, and a piece of prediction data identical to that in Python is placed in the test environment, and the output results are compared with those in Python layer by layer; on the basis of correct functions, the performance of the neural network is optimized. In this embodiment, hardware parallelism (#pragma HLS PIPELINE) is adopted to increase the number of parallel processing units under the premise of reasonable resources to speed up data processing;

[0111] Furthermore, the HLS tool is used for synthesis, and the resource usage in the synthesis report is reasonable. After the synthesis is completed, the IP core file of the neural network is generated. A project is created in Vivado, and the generated IP core is added to the project. After adding the necessary modules such as the ZYNQ system main module and the clock reset module, the connection and configuration, layout and routing are performed, and finally the bitstream file is generated and deployed on the ZYNQ platform.

[0112] S4.2. Driven by the clock control module, the ARM module reads the spectral data to be tested and the Astragalus pictures of the corresponding origin stored in the SD card, and sends them to the DDR3 storage unit for storage; at the same time, the spectral data to be tested is sent to the IP core in the CNN module for processing to obtain the predicted origin category label of the spectral data to be tested;

[0113] S4.3, under the drive of the clock control module, the data conversion module converts the astragalus image into an astragalus image in AXI-stream format and sends it to the CNN module;

[0114] S4.4. Under the drive of the clock control module, the VDMA module reads the spectrum data to be measured and its predicted origin category label through the AXI protocol and stores them in the DDR3 storage unit;

[0115] S4.5, after the CNN module matches the predicted origin category label with the Astragalus picture of its corresponding origin, it sends it to the VDMA module. Then, under the drive of the clock control module, the VDMA module sends the predicted origin category label and its matching Astragalus picture to the HDMI control module, so that the HDMI control module uses the HDMI display to display the predicted origin category label and its matching Astragalus picture.

[0116] In this embodiment, an electronic device includes a memory and a processor, wherein the memory is used to store a program that supports the processor to execute the above method, and the processor is configured to execute the program stored in the memory.

[0117] In this embodiment, a computer-readable storage medium stores a computer program on the computer-readable storage medium, and the computer program executes the steps of the above method when executed by a processor.

[0118] In summary, the method for rapid identification of origin of Chinese herbal medicine based on hyperspectral technology and neural network of the present invention realizes rapid identification of astragalus from different origins through hyperspectral technology and neural network, which can not only obtain more abundant spectral data of complex samples in a non-destructive and instant manner, but also ensure a higher classification accuracy. The present invention organically combines hyperspectral technology with neural network and applies it to the field of identification of origin of Chinese herbal medicine, which is not subject to the limitations of traditional technology and provides a new and efficient identification path.

Claims

1. A method for rapid identification of origin of Chinese herbal medicine based on hyperspectral technology and neural network, characterized in that: It is applied to a system composed of a hyperspectral acquisition module, a data processing module, a neural network training module, and a ZYNQ processing system, wherein the ZYNQ processing system includes: a VDMA module, a CNN module, a clock control module, a data conversion module, a DDR3 storage unit and an HDMI control module, an ARM module, and an SD card; the method for quickly identifying the origin of Chinese medicinal materials is carried out in the following steps: S1, the hyperspectral acquisition module acquires Hyperspectral reflectance sample sets of Chinese medicinal materials from different origins ,in, Indicates hyperspectral band reflectance samples, and , express In the The reflectance value corresponding to each band is , , represents the number of samples, represents the total number of bands; let The real origin category label is recorded as ,and ∈[1,…,t,…,M], t represents the serial number of any category; S2, using the data processing module Preprocessing is performed to obtain a preprocessed Chinese herbal medicine hyperspectral reflectance sample set ,in, After preprocessing, hyperspectral band reflectance samples, and , express In the The reflectance value corresponding to each band; S3, build a convolutional neural network with a neural network backbone architecture, and use The convolutional neural network is trained to obtain a trained model for rapid identification of origin of Chinese medicinal materials; S4. Deploy the rapid identification model of the origin of Chinese medicinal materials into the ZYNQ processing system to realize the identification of the origin of Chinese medicinal materials.

2. The method for rapid identification of origin of Chinese herbal medicine based on hyperspectral technology and neural network according to claim 1, characterized in that S2 include: S2.1, use YOLO target detection algorithm Automatically extract ROI to obtain the target ROI data set ,in, express The target ROI area in , express Middle The reflectance value corresponding to each band; S2.2, using formula (1) After noise smoothing, we get No. The smoothed reflectivity corresponding to each band , thus obtaining the smoothed target ROI data set , and then obtain the smoothed target ROI data set : (1) In formula (1), yes Middle The reflectance value corresponding to each band is is the kth coefficient of the smoothing window, is the half-width of the smoothing window; S2.3, using formula (2) After eliminating the deviation, we get No. The reflectivity after eliminating the deviation of each band , thus obtaining a data set after eliminating bias , and then get the final preprocessed data set : (2) In formula (2), Indicates The mean of the total band reflectance values ​​of the hyperspectral band reflectance samples, and , Indicates The standard deviation of the total band reflectance values ​​of the hyperspectral band reflectance samples, .

3. The method for rapid identification of origin of Chinese herbal medicine based on hyperspectral technology and neural network according to claim 1 is characterized in that: S3 includes: S3.1, constructing the convolutional neural network including: five layers of convolutional units and a classifier; S3.1.1, the first convolutional unit, including: convolutional layer, batch normalization layer, activation layer and pooling layer; S3.1.1.

1. The convolutional layer in the first convolutional unit uses formula (3) to Perform convolution calculation and get The first hyperspectral band reflectance sample The convolution result corresponding to each band , so the dimension is No. Convolutional layer output dataset of hyperspectral band reflectance samples ,in, Represents the number of convolution kernels in the first layer of convolutional units: (3) In formula (3), express In the +n bands corresponding to the reflectivity value, represents the convolution kernel corresponding to the nth position, Indicates the size of the convolution kernel; S3.1.1.2, the batch normalization layer in the first convolutional unit uses equations (4) and (5) to Process it and get The first hyperspectral band reflectance sample The batch results corresponding to the bands , so the dimension is No. Batch normalized output dataset of hyperspectral band reflectance samples : (4) (5) In formula (4) and formula (5), Indicates The first hyperspectral band reflectance sample The normalized reflectance value corresponding to each band is Represents the reflectance sample of the i-th hyperspectral band The mean of , Represents the reflectance sample of the i-th hyperspectral band The variance of , Represents a parameter used to prevent division by zero; , Respectively The scaling factor and A translation factor; S3.1.1.3, the activation layer in the first convolutional unit uses formula (6) Processing is performed to obtain the reflectivity of the activation layer after activation , so the dimension is No. Activated reflectance dataset with reflectance samples in hyperspectral bands : (6) In formula (6), ReLU represents the activation function; S3.1.1.4, the pooling layer in the first convolutional unit uses formula (7) Processing is performed to obtain the reflectivity after pooling , so the dimension is No. Pooled reflectance dataset of hyperspectral band reflectance samples , and then obtain the high-spectral reflectance sample set of Chinese medicinal materials output by the first convolution unit ,in, express The characteristic length of , Represents a pooling window: (7) In formula (7), Indicates The first hyperspectral band reflectance sample arrive Reflectivity within the band range; S3.1.2, the second convolution unit performs steps S3.1.1.1 to S3.1.1.4 in sequence After processing, the high-spectral reflectance sample set of Chinese medicinal materials output by the second convolution unit is obtained. ,in, The dimension of the output of the second convolution unit is No. A pooled reflectance dataset of hyperspectral band reflectance samples, and , express After pooling The reflectivity of each band, Represents the number of convolution kernels in the second layer of convolutional units, express The characteristic length of ; S3.1.3, the third convolution unit performs steps S3.1.1.1 to S3.1.1.4 in sequence After processing, the hyperspectral reflectance sample set of Chinese medicinal materials output by the third convolution unit is obtained. ,in, The dimension of the output of the third convolution unit is No. A pooled reflectance dataset of hyperspectral band reflectance samples, and , express After pooling The reflectance value of each band, Represents the number of convolution kernels in the third layer of convolutional units, express The characteristic length of ; S3.1.4, the fourth convolution unit performs steps S3.1.1.1 to S3.1.1.4 in sequence After processing, the hyperspectral reflectance sample set of Chinese medicinal materials output by the fourth convolution unit is obtained. ,in, The output dimension of the fourth convolution unit is No. A pooled reflectance dataset of hyperspectral band reflectance samples, and , express After pooling The reflectance value of each band, Represents the number of convolution kernels in the fourth layer convolution unit, express The characteristic length of ; S3.1.5, the fifth convolution unit performs steps S3.1.1.1 to S3.1.1.4 in sequence After processing, the high-spectral reflectance sample set of Chinese medicinal materials output by the fifth convolution unit is obtained. ,in, The dimension of the output of the fifth convolutional unit is The A pooled reflectance dataset of hyperspectral band reflectance samples, and , express After pooling The reflectance value of each band, Represents the number of convolution kernels in the fifth layer of convolutional units, express The characteristic length of ; ; S3.1.6, the classifier comprises: a fully connected layer and a Softmax layer; Will After flattening, the dimensions become The sample set of Chinese medicinal materials with high spectral reflectance is input into the fully connected layer for processing, and the dimension is The score vector ,in, express In the The corresponding score value for each category; The Softmax layer uses formula (8) to Calculate and get Belong to The probability of the categories , and take the category corresponding to the maximum probability as the predicted origin category label: (8) S3.

2. Construct a cross-entropy loss function based on the real origin category labels and predicted origin category labels, which is used to train and test the convolutional neural network to update the network parameters until the cross-entropy loss function converges, thereby obtaining a rapid identification model of the origin of Chinese medicinal materials corresponding to the optimal parameters and saving the weight parameters with the highest test accuracy.

4. The method for rapid identification of origin of Chinese herbal medicine based on hyperspectral technology and neural network according to claim 1, characterized in that S4 include: S4.

1. Use the HLS hardware description language to write the Chinese medicinal materials origin rapid identification model and encapsulate it into an IP core and then deploy it to the CNN module of the ZYNQ processing system; S4.

2. Under the drive of the clock control module, the ARM module reads the spectral data to be tested and the Astragalus pictures of the corresponding origin stored in the SD card, and sends them to the DDR3 storage unit for storage; at the same time, the spectral data to be tested is sent to the IP core in the CNN module for processing to obtain the predicted origin category label of the spectral data to be tested; S4.3, under the drive of the clock control module, the data conversion module converts the astragalus picture into an astragalus picture in AXI-stream format and sends it to the CNN module; S4.

4. Under the drive of the clock control module, the VDMA module reads the spectrum data to be measured and its predicted origin category label through the AXI protocol and stores them in the DDR3 storage unit; S4.

5. After the CNN module matches the predicted origin category label with the Astragalus picture of its corresponding origin, it sends it to the VDMA module. Then, under the drive of the clock control module, the VDMA module sends the predicted origin category label and its matching Astragalus picture to the HDMI control module, so that the HDMI control module uses the HDMI display to display the predicted origin category label and its matching Astragalus picture.

5. An electronic device, comprising a memory and a processor, characterized in that: The memory is used to store a program that supports the processor to execute the rapid identification system of the origin of traditional Chinese medicine based on hyperspectral technology and neural network as described in any one of claims 1-4, and the processor is configured to execute the program stored in the memory.

6. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the rapid identification system of the origin of traditional Chinese medicine based on hyperspectral technology and neural network described in any one of claims 1 to 4 are executed.

Citation Information

Patent Citations

  • Method for discriminating producing area of angelica dahurica by using hyperspectral imaging technology

    CN116543176A

  • Neural network model for identifying production place of traditional Chinese medicinal material pseudo-ginseng

    CN116629317A

  • Method for identifying producing area of astragalus membranaceus based on ultraviolet spectrum and convolutional neural network

    CN116630675A

  • FPGA-based full-pipeline medical hyperspectral image neural network classification method

    CN116662593A

  • Method and system for constructing traditional Chinese medicinal material identification model based on hyperspectral image processing

    CN117935056A