A traditional Chinese medicinal material origin rapid identification method based on hyperspectral technology and neural network
By combining hyperspectral technology and convolutional neural networks, the problems of time-consuming, labor-intensive, costly, and inaccurate identification of Astragalus membranaceus origin have been solved, achieving rapid, accurate, and non-destructive identification of Chinese medicinal materials origin, thus improving detection efficiency and accuracy.
Patent Information
- Application Number
- CN202510103295.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-22
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2045-01-22
AI Technical Summary
Existing methods for identifying the origin of Astragalus membranaceus are time-consuming, labor-intensive, costly, and have low accuracy. In particular, traditional manual identification and chemical analysis methods are not very accurate under the influence of environmental factors, making it difficult to quickly and accurately distinguish Astragalus membranaceus from different origins.
By combining hyperspectral technology with convolutional neural networks, spectral data of Chinese medicinal materials are acquired through a hyperspectral acquisition module. The YOLO target detection algorithm is used for ROI extraction. Combined with noise smoothing and bias elimination processing, a five-layer convolutional neural network is constructed for training and deployed into the ZYNQ processing system to achieve rapid identification.
It enables rapid, accurate, and non-destructive identification of the origin of Chinese medicinal materials, improves testing efficiency, reduces costs, and ensures high reliability and accuracy of identification results.
Smart Images

Figure CN119810671B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the field of intelligent detection of traditional Chinese medicinal materials, and in particular to a method for rapid identification of traditional Chinese medicinal materials based on hyperspectral technology and neural networks. BACKGROUND
[0002] As a common traditional medicinal material, Huangqi has significant regional characteristics, especially in the Hengshan production area of Hunyuan County, Datong City, Shanxi Province. The traditional and native medicinal material has adopted a wild-like planting mode for hundreds of years. Under this mode, Huangqi needs to grow in the wild environment for more than 8 years before being picked. Shaanxi Province also has a similar wild-like planting mode, and the large-scale planting has been carried out for more than 20 years, usually requiring a growth period of more than 5 years. In comparison, Huangqi planted in the field is generally planted through a two-year cycle of seedling and transplanting (referred to as transplanted Huangqi or fast-growing Huangqi), mainly distributed in Inner Mongolia and Gansu Province, especially in the western and eastern production areas of Inner Mongolia, and Longzhong and Longbei of Gansu. Among the annual demand for Huangqi, the output of wild-like Huangqi accounts for only about 1 / 30, and due to the planting period and the difficulty of digging, the price of medicinal materials of the same specification is about 10 times that of transplanted Huangqi. And there are a large number of reports that the composition and structure of Huangqi polysaccharides without the place of origin and different planting modes also have very obvious differences. At present, a large number of transplanted Huangqi is appearing on the market to pretend to be Shanxi wild-like Huangqi, and even transplanted Huangqi accounts for a large proportion in export trade, which has a great impact and harm on the reputation of native medicinal materials. Therefore, it is urgent to establish a rapid identification system for Huangqi medicinal materials from different production areas.
[0003] Existing methods for identifying the production area of Huangqi include artificial identification, chemical analysis, near-infrared spectroscopy analysis, etc. Among them, artificial 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 detection; chemical analysis is complex and costly, and is usually destructive, which is not suitable for rapid screening of a large number of samples; and near-infrared spectroscopy is a non-destructive and rapid analysis method, but Huangqi from different production areas may have certain similarities in chemical cost, resulting in similar near-infrared spectroscopy characteristics, especially when Huangqi is greatly affected by environmental factors during growth, the spectral data may have large overlap, affecting accuracy.
[0004] A patent search revealed that publication number CN116630675A discloses a method for identifying the origin of Astragalus membranaceus based on ultraviolet spectroscopy and convolutional neural networks. This method includes acquiring ultraviolet spectral data of Astragalus membranaceus from different origins and collecting corresponding Raman spectral data for training. The ultraviolet spectral data of Astragalus membranaceus from different origins is then iteratively fed into a pre-trained one-dimensional convolutional neural network for detection. This invention proposes a rapid method for identifying the origin of Chinese medicinal materials based on hyperspectral technology and neural networks. It can acquire continuous spectral data over a wider spectral range, providing higher resolution spectral information, thereby more effectively distinguishing samples from different origins. Simultaneously, based on the ZYNQ platform, hardware acceleration of the neural network is achieved, thereby improving overall computational efficiency and rapid identification capabilities. Summary of the Invention
[0005] This invention aims to address the shortcomings of existing technologies by proposing a rapid identification method for the origin of Chinese medicinal materials based on hyperspectral technology and neural networks. The goal is to overcome the limitations of traditional methods by combining 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 accuracy of the identification results.
[0006] To achieve the above-mentioned objectives, the present invention adopts the following technical solution:
[0007] The present invention discloses a rapid identification method for the origin of Chinese medicinal materials based on hyperspectral technology and neural networks. The method is characterized by its application in a system comprised of a hyperspectral acquisition module, a data processing module, a neural network training module, and a ZYNQ processing system. 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 rapid identification method for the origin of Chinese medicinal materials is performed according to the following steps:
[0008] S1, the hyperspectral acquisition module acquires... Hyperspectral reflectance sample set of Chinese medicinal materials from different origins ,in, Indicates the first A hyperspectral band reflectance sample, and , express In the The reflectance values corresponding to each band. , , Indicates the number of samples. Indicates the total number of bands; let The true country of origin category label is recorded as ,and ∈[1,…,t,…,M], where t represents the index of any category;
[0009] S2. Using the data processing module to... Preprocessing was performed to obtain a preprocessed hyperspectral reflectance sample set of Chinese medicinal materials. ,in, Indicates the first preprocessed step A hyperspectral band reflectance sample, and , express In the The reflectance values corresponding to each band;
[0010] S3. Construct a convolutional neural network with a neural network backbone architecture, and use... A convolutional neural network was trained to obtain a rapid identification model for the origin of Chinese medicinal materials.
[0011] S4. Deploy the rapid identification model of Chinese medicinal material origins into the ZYNQ processing system to realize the identification of the origins of Chinese medicinal materials.
[0012] The method for rapid identification of the origin of Chinese medicinal materials based on hyperspectral technology and neural networks described in this invention is also characterized in that S2 includes:
[0013] S2.1 Using the YOLO object detection algorithm to... Perform automatic ROI extraction to obtain the target ROI dataset. ,in, express The target ROI region in the middle, and , express The Middle The reflectance values corresponding to each band;
[0014] S2.2, Using formula (1) Noise smoothing is performed to obtain No. Smoothed reflectance corresponding to each band This yields the smoothed target ROI dataset. This leads to the smoothed target ROI dataset. :
[0015] (1)
[0016] In equation (1), yes The Middle The reflectance values corresponding to each band. It is the k-th coefficient of the smoothing window. It is half the width of the smooth window;
[0017] S2.3, Using formula (2) Perform deviation elimination processing to obtain No. The reflectance after bias correction for each band Thus, the dataset after bias elimination is obtained. This leads to the final preprocessed dataset. :
[0018] (2)
[0019] In equation (2), Indicates the first The mean of the total band reflectance values of each hyperspectral band reflectance sample, and , Indicates the first The standard deviation of the total band reflectance values of a hyperspectral band reflectance sample .
[0020] Furthermore, S3 includes:
[0021] S3.1 The convolutional neural network consists of five layers of convolutional units and one classifier;
[0022] S3.1.1 The first convolutional unit includes: a convolutional layer, a batch normalization layer, an activation layer, and a pooling layer;
[0023] S3.1.1.1, The convolutional layer in the first convolutional unit uses equation (3) to... Perform convolution calculation to obtain the first... The first hyperspectral band reflectance sample The convolution result corresponding to each band Thus, the dimension is The Convolutional layer output dataset of hyperspectral band reflectance samples ,in, This indicates the number of convolutional kernels in the first convolutional unit:
[0024] (3)
[0025] In equation (3), express In the +n bands corresponding to reflectance values This represents the convolution kernel corresponding to the nth position. Indicates the size of the convolution kernel;
[0026] S3.1.1.2, The batch normalization of the first layer convolutional unit is performed using equations (4) and (5). Processing yields the first... The first hyperspectral band reflectance sample Batch results for each band Thus, the dimension is The Batch normalized output dataset of hyperspectral band reflectance samples :
[0027] (4)
[0028] (5)
[0029] In equations (4) and (5), Indicates the first The first hyperspectral band reflectance sample The standardized reflectance values corresponding to each band. Represents the reflectance sample of the i-th hyperspectral band. The mean, and , Represents the reflectance sample of the i-th hyperspectral band. The variance, and , This indicates a parameter used to prevent division by zero; , The first The scaling factor and the first One translation factor;
[0030] S3.1.1.3, The activation layer in the first convolutional unit utilizes equation (6) to... The reflectivity of the activated layer is obtained through processing. Thus, the dimension is The Activated reflectance dataset of hyperspectral band reflectance samples :
[0031] (6)
[0032] In equation (6), ReLU represents the activation function;
[0033] S3.1.1.4, The pooling layer in the first convolutional unit utilizes equation (7) for... The reflectivity after pooling is obtained through processing. Thus, the dimension is The Pooled reflectance dataset of hyperspectral band reflectance samples This leads to the first convolutional unit outputting a sample set of hyperspectral reflectance of Chinese medicinal materials. ,in, express The characteristic length, and , Indicates a pooled window:
[0034] (7)
[0035] In equation (7), Indicates the first The first hyperspectral band reflectance sample arrive Reflectivity within the specified spectral range;
[0036] S3.1.2 The second convolutional unit is processed sequentially according to steps S3.1.1.1 to S3.1.1.4. After processing, the hyperspectral reflectance sample set of Chinese medicinal materials output by the second convolutional unit is obtained. ,in, This indicates that the output dimension of the second convolutional unit is . The A pooled reflectance dataset of hyperspectral band reflectance samples, and , express After pooling, the first Reflectivity of each band This indicates the number of convolutional kernels in the second convolutional unit. express The characteristic length, and ;
[0037] S3.1.3 The third convolutional unit is processed sequentially according to steps S3.1.1.1 to S3.1.1.4. After processing, the hyperspectral reflectance sample set of Chinese medicinal materials output by the third convolutional unit is obtained. ,in, This indicates that the dimension of the output of the third convolutional unit is... The A pooled reflectance dataset of hyperspectral band reflectance samples, and , express After pooling, the first Reflectance values for each band, This indicates the number of convolutional kernels in the third convolutional unit. express The characteristic length, and ;
[0038] S3.1.4 The fourth convolutional unit is processed sequentially according to steps S3.1.1.1 to S3.1.1.4. After processing, the hyperspectral reflectance sample set of Chinese medicinal materials output by the fourth convolutional unit is obtained. ,in, This indicates that the output dimension of the fourth convolutional unit is... The A pooled reflectance dataset of hyperspectral band reflectance samples, and , express After pooling, the first Reflectance values for each band, This indicates the number of convolutional kernels in the fourth convolutional unit. express The characteristic length, and ;
[0039] S3.1.5, The fifth convolutional unit is processed sequentially according to steps S3.1.1.1 to S3.1.1.4. After processing, the hyperspectral reflectance sample set of Chinese medicinal materials output by the fifth convolutional unit is obtained. ,in, This indicates that the output dimension of the fifth convolutional unit is... The first A pooled reflectance dataset of hyperspectral band reflectance samples, and , express After pooling, the first Reflectance values for each band, This indicates the number of convolutional kernels in the fifth convolutional unit. express The characteristic length, and ; ;
[0040] S3.1.6 The classifier includes: a fully connected layer and a Softmax layer;
[0041] Will After flattening, the dimensions become A high-spectral reflectance sample set of Chinese medicinal herbs is obtained and input into the fully connected layer for processing to obtain a dimension of [missing information]. score vector ,in, express In the The corresponding score values for each category;
[0042] The Softmax layer utilizes equation (8) to... Calculations were performed to obtain Belongs to the The probability of each category The category corresponding to the highest probability is used as the predicted origin category label:
[0043] (8)
[0044] S3.2. Construct a cross-entropy loss function based on the real origin category label and the predicted origin category label. Use this function to train and test the convolutional neural network to update the network parameters until the cross-entropy loss function converges. This will give you the optimal parameters for the fast identification model of Chinese medicinal materials origin and save the weight parameters with the highest test accuracy.
[0045] Furthermore, S4 includes:
[0046] S4.1. The Chinese medicinal material origin rapid identification model is written using the HLS hardware description language and encapsulated into an IP core and then deployed 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 corresponding Astragalus membranaceus images from the SD card and sends them to the DDR3 storage unit for storage; at the same time, it sends the spectral data to be tested 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 membranaceus image into an AXI-stream format Astragalus membranaceus image and sends it to the CNN module;
[0049] S4.4 Under the drive of the clock control module, the VDMA module reads the spectral data to be tested and its predicted origin category label through the AXI protocol and stores it in the DDR3 memory unit;
[0050] S4.5 After the CNN module matches the predicted origin category label with the corresponding Astragalus membranaceus image, it sends it to the VDMA module. Then, driven by the clock control module, the VDMA module sends the predicted origin category label and its matching Astragalus membranaceus image to the HDMI control module, so that the HDMI control module can display the predicted origin category label and its matching Astragalus membranaceus image on the HDMI display screen.
[0051] The present invention provides an electronic device, comprising a memory and a processor, wherein the memory is used to store a program that supports the processor in executing the rapid identification system for the origin of Chinese medicinal materials based on hyperspectral technology and neural networks, and the processor is configured to execute the program stored in the memory.
[0052] The present invention discloses a computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium, and the computer program is executed by a processor to perform the steps of the rapid identification system for the origin of Chinese medicinal materials based on hyperspectral technology and neural networks.
[0053] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0054] 1. This invention uses hyperspectral imaging technology. Compared with traditional manual identification, chemical analysis and near-infrared spectroscopy, 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, thus enabling more accurate differentiation and analysis of complex samples.
[0055] 2. Compared with traditional classification algorithms, the convolutional neural network used in this invention can automatically learn and extract effective features from the original data, and can always achieve higher classification accuracy.
[0056] 3. Considering real-time processing and rapid recognition, this invention selects ZYNQ as the hardware platform for implementing convolutional neural networks, providing high parallel computing capabilities, as well as low power consumption and high efficiency. Attached Figure Description
[0057] Figure 1 This is a schematic diagram of the structure of the rapid identification method for the origin of Chinese medicinal materials based on hyperspectral technology and neural networks according to the present invention;
[0058] Figure 2 This is a schematic diagram of the data acquisition system in an embodiment of the present invention;
[0059] Figure 3 The above are the average spectra of Astragalus membranaceus from seven different origins after pretreatment in this embodiment of the invention.
[0060] Figure 4 This is an architecture diagram of the ZYNQ processing system in an embodiment of the present invention. Detailed Implementation
[0061] To further understand the technical solution of the present invention, a detailed description is provided below in conjunction with the accompanying drawings.
[0062] In this embodiment, as Figure 1As shown, a method for rapid identification of the origin of Chinese medicinal materials based on hyperspectral technology and neural networks is presented. The method includes the following steps:
[0063] S1, Hyperspectral Acquisition Module Acquisition Hyperspectral reflectance sample set of Chinese medicinal materials from different origins ,in, Indicates the first A hyperspectral band reflectance sample, and , express In the The reflectance values corresponding to each band. , , Indicates the number of samples. Indicates the total number of bands; let The true country of origin category label is recorded as ,and ∈[1,…,t,…,M], where t represents the t-th category; specifically, in this embodiment, a high-spectral reflectance sample set of Astragalus membranaceus from seven different origins was collected, containing spectral information of 204 bands.
[0064] S1.1, such as Figure 2 As shown, hyperspectral reflectance data of Chinese medicinal materials and hyperspectral reflectance data of white board were collected using a hyperspectral camera. The hyperspectral reflectance data of Chinese medicinal materials were calibrated using the white board reflectance data information, and the calibrated hyperspectral reflectance data of Chinese medicinal materials were converted into .csv format to form a hyperspectral reflectance sample set A of Chinese medicinal materials.
[0065] S1.2, label the sample set A of hyperspectral reflectance of Chinese medicinal materials.
[0066] S2, Use the data processing module to... Preprocessing was performed to obtain a preprocessed hyperspectral reflectance sample set of Chinese medicinal materials. ,in, Indicates the first preprocessed step A hyperspectral band reflectance sample, and , express In the The reflectance values corresponding to each band; specifically, the preprocessing includes ROI extraction and spectral preprocessing; ROI extraction includes using the software ENVI for region of interest extraction; spectral preprocessing includes SG smoothing and multivariate scattering correction (MSC) to reduce noise interference and eliminate spectral differences;
[0067] S2.1 Using the YOLO object detection algorithm to... Perform automatic ROI extraction to obtain the target ROI dataset. ,in, express The target ROI region in the middle, and , express The Middle The reflectance values corresponding to each band.
[0068] S2.2, Using formula (1) Noise smoothing is performed to obtain No. Smoothed reflectance corresponding to each band This yields the smoothed target ROI dataset. This leads to the smoothed target ROI dataset. :
[0069] (1)
[0070] In equation (1), yes The Middle The reflectance values corresponding to each band. It is the k-th coefficient of the smoothing window. It is half the width of the smooth window.
[0071] S2.3, Using formula (2) Perform deviation elimination processing to obtain No. The reflectance after bias correction for each band Thus, the dataset after bias elimination is obtained. This leads to the final preprocessed dataset. :
[0072] (2)
[0073] In equation (2), Indicates the first The mean of the total band reflectance values of each hyperspectral band reflectance sample, and , Indicates the first The standard deviation of the total band reflectance values of a hyperspectral band reflectance sample .
[0074] In practice, before training the neural network, when preprocessing the dataset using SG smoothing and multivariate scattering correction, the window size for SG smoothing is set to 5, and the polynomial order is set to 2; for example... Figure 3 As shown, the average spectra of Astragalus membranaceus from seven different origins after pretreatment were obtained.
[0075] S3. Construct a convolutional neural network with a neural network backbone architecture, and use... A convolutional neural network was trained to obtain a rapid identification model for the origin of Chinese medicinal materials.
[0076] S3.1 In order to balance the requirements of model deployment and classification accuracy, one-dimensional convolution is used to learn the spectral features of D, and a convolutional neural network is constructed including five layers of convolutional units and a classifier.
[0077] S3.1.1 The first convolutional unit includes: a convolutional layer, a batch normalization layer, an activation layer, and a pooling layer;
[0078] S3.1.1.1, The convolutional layer in the first convolutional unit uses equation (3) to... Perform convolution calculation to obtain the first... The first hyperspectral band reflectance sample The convolution result corresponding to each band Thus, the dimension is The Convolutional layer output dataset of hyperspectral band reflectance samples ,in, This indicates the number of convolutional kernels in the first convolutional unit:
[0079] (3)
[0080] In equation (3), express In the +n bands corresponding to reflectance values This represents the convolution kernel corresponding to the nth position. This indicates the size of the convolution kernel.
[0081] S3.1.1.2, Batch normalization in the first layer convolutional unit utilizes equations (4) and (5) Processing yields the first... The first hyperspectral band reflectance sample Batch results for each band Thus, the dimension is The Batch normalized output dataset of hyperspectral band reflectance samples :
[0082] (4)
[0083] (5)
[0084] In equations (4) and (5), Indicates the first The first hyperspectral band reflectance sample The standardized reflectance values corresponding to each band. Represents the reflectance sample of the i-th hyperspectral band. The mean, and , Represents the reflectance sample of the i-th hyperspectral band. The variance, and , This indicates a parameter used to prevent division by zero; , The first The scaling factor and the first One translation factor.
[0085] S3.1.1.3, The activation layer in the first convolutional unit uses equation (6) to... The reflectivity of the activated layer is obtained through processing. Thus, the dimension is The Activated reflectance dataset of hyperspectral band reflectance samples :
[0086] (6)
[0087] In equation (6), ReLU represents the activation function.
[0088] S3.1.1.4, The pooling layer in the first convolutional unit utilizes equation (7) for... The reflectivity after pooling is obtained through processing. Thus, the dimension is The Pooled reflectance dataset of hyperspectral band reflectance samples This leads to the first convolutional unit outputting a sample set of hyperspectral reflectance of Chinese medicinal materials. ,in, express The characteristic length, and , Indicates a pooled window:
[0089] (7)
[0090] In equation (7), Indicates the first Pooling range of reflectance samples in each hyperspectral band Indicates the first The first hyperspectral band reflectance sample arrive Band.
[0091] S3.1.2 The second convolutional unit is processed sequentially according to steps S3.1.1.1 to S3.1.1.4. After processing, the hyperspectral reflectance sample set of Chinese medicinal materials output by the second convolutional unit is obtained. ,in, This indicates that the output dimension of the second convolutional unit is . The A pooled reflectance dataset of hyperspectral band reflectance samples, and , express After pooling, the first Reflectivity of each band This indicates the number of convolutional kernels in the second convolutional unit. express The characteristic length, and .
[0092] S3.1.3 The third convolutional unit is processed sequentially according to steps S3.1.1.1 to S3.1.1.4. After processing, the hyperspectral reflectance sample set of Chinese medicinal materials output by the third convolutional unit is obtained. ,in, This indicates that the dimension of the output of the third convolutional unit is... The A pooled reflectance dataset of hyperspectral band reflectance samples, and , express After pooling, the first Reflectance values for each band, This indicates the number of convolutional kernels in the third convolutional unit. express The characteristic length, and .
[0093] S3.1.4 The fourth convolutional unit is processed sequentially according to steps S3.1.1.1 to S3.1.1.4. After processing, the hyperspectral reflectance sample set of Chinese medicinal materials output by the fourth convolutional unit is obtained. ,in, This indicates that the output dimension of the fourth convolutional unit is... The A pooled reflectance dataset of hyperspectral band reflectance samples, and , express After pooling, the first Reflectance values for each band, This indicates the number of convolutional kernels in the fourth convolutional unit. express The characteristic length, and .
[0094] S3.1.5, The fifth convolutional unit is processed sequentially according to steps S3.1.1.1 to S3.1.1.4. After processing, the hyperspectral reflectance sample set of Chinese medicinal materials output by the fifth convolutional unit is obtained. ,in, This indicates that the output dimension of the fifth convolutional unit is... The first A pooled reflectance dataset of hyperspectral band reflectance samples, and , express After pooling, the first Reflectance values for each band, This indicates the number of convolutional kernels in the fifth convolutional unit. express The characteristic length, and ; .
[0095] S3.1.6 The classifier includes: a fully connected layer and a Softmax layer;
[0096] Will After flattening, the dimensions become A high-spectral reflectance sample set of Chinese medicinal herbs was obtained and processed in a fully connected layer to obtain a dimension of [missing information]. score vector ,in, express In the The corresponding score value for each category.
[0097] The Softmax layer utilizes equation (8) to... Calculations were performed to obtain Belongs to the The probability of each category The category corresponding to the highest probability is used as the predicted origin category label:
[0098] (8)
[0099] S3.2. Construct a cross-entropy loss function based on the real origin category label and the predicted origin category label, and use it to train the convolutional neural network to update the network parameters until the cross-entropy loss function converges, thereby obtaining the fast identification model of Chinese medicinal material origin corresponding to the optimal parameters.
[0100] In this embodiment, the preprocessed dataset D is divided into a training set and a test set in an 8:2 ratio. The network parameters are set as follows: the batch size is set to 32, the cross-entropy loss function is used, the Adam optimizer is selected, the number of training iterations is 300, the learning rate is set to 0.001, and the learning rate is reduced by 10% every 100 iterations.
[0101] After training, the best-performing 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 Chinese medicinal material origins into the ZYNQ processing system to realize the identification of the origins of Chinese medicinal materials.
[0103] In this embodiment, as Figure 4 As shown, 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;
[0104] S4.1 A rapid identification model for the origin of Chinese medicinal herbs was developed using the HLS hardware description language and encapsulated into an IP core before being deployed to the CNN module of the ZYNQ processing system. Specifically, the rapid identification model for the origin of Chinese medicinal herbs in the CNN module was decomposed into multiple independent and synthesizable modules such as convolutional layers, pooling layers, and activation layers. Each module was implemented using C language combined with specific instructions in HLS. The most important aspect was implementing the convolution operation in the convolutional layers, using a loop structure to iterate through the input spectral data kernels.
[0105] Simultaneously, the input / output interfaces of each module are defined to guide the HLS tool in correctly handling data transmission and interaction when synthesizing C code into hardware circuits, specifying:
[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] In this context, `#pragma HLS INTERFACE` specifies the communication method between the function interface and the hardware in the HLS design. `s_axilite` indicates the AXI Lite protocol used for controlling registers, `m_axi` indicates the master-slave AXI protocol used for high bandwidth, `port` specifies the name of the interface, `port=return` indicates the interface related to the function's return value, `port=data_in` and `port=data_out` represent input and output interfaces, respectively, used to transfer data from the outside to the hardware module or from the hardware module to the outside, `depth=7` and `depth=204` indicate that the FIFO buffer depth of the interface is 7 or 204, respectively, `offset=slave` indicates that this is a slave device port, and `bundle=CONTROL`, `bundle=OUT`, and `bundle=IN` indicate that the interface `port` is bound to an interface named `IN`, `OUT`, and `CONTROL`, respectively.
[0110] Furthermore, a test platform is built in the HLS environment, and the same prediction data as in Python is placed in the test environment. The output results are compared with the output results in Python layer by layer. Based on the correct functionality, 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, thereby speeding up the data processing speed.
[0111] Furthermore, synthesis is performed using the HLS tool, and the synthesis report shows reasonable resource usage. After synthesis, the IP core file for the neural network is generated. A project is created in Vivado, the generated IP core is added to the project, and necessary modules such as the ZYNQ system main module and clock reset module are added. After connection, configuration, placement and routing are performed, and finally, a bitstream file is generated and deployed on the ZYNQ platform.
[0112] S4.2 Under the drive of the clock control module, the ARM module reads the spectral data to be tested and the corresponding Astragalus membranaceus images from the SD card and sends them to the DDR3 storage unit for storage; at the same time, it sends the spectral data to be tested 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 membranaceus image into an AXI-stream format Astragalus membranaceus image and sends it to the CNN module;
[0114] S4.4 Under the drive of the clock control module, the VDMA module reads the spectral data to be tested and its predicted origin category label through the AXI protocol and stores it in the DDR3 memory unit;
[0115] S4.5 The CNN module matches the predicted origin category label with the corresponding Astragalus membranaceus image and sends it to the VDMA module. Driven by the clock control module, the VDMA module sends the predicted origin category label and its matching Astragalus membranaceus image to the HDMI control module, so that the HDMI control module can display the predicted origin category label and its matching Astragalus membranaceus image on the HDMI display screen.
[0116] In this embodiment, an electronic device includes a memory and a processor. The memory stores a program that supports the processor in executing the above-described 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, which is executed by a processor to perform the steps of the above method.
[0118] In summary, the present invention provides a rapid identification method for the origin of Chinese medicinal materials based on hyperspectral technology and neural networks. This method achieves rapid identification of Astragalus membranaceus from different origins through hyperspectral technology and neural networks, enabling the non-destructive and real-time acquisition of richer spectral data from complex samples while ensuring higher classification accuracy. This invention organically combines hyperspectral technology with neural networks and applies it to the field of Chinese medicinal material origin identification, overcoming the limitations of traditional technologies and providing a new and efficient identification path.
Claims
1. A method for rapid identification of the origin of Chinese medicinal materials based on hyperspectral technology and neural networks, characterized in that, This method 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 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 rapid identification method for the origin of Chinese medicinal materials is performed according to the following steps: S1, the hyperspectral acquisition module acquires... Hyperspectral reflectance sample set of Chinese medicinal materials from different origins ,in, Indicates the first A hyperspectral band reflectance sample, and , express In the The reflectance values corresponding to each band. , , Indicates the number of samples. Indicates the total number of bands; let The true country of origin category label is recorded as ,and ∈[1,…,t,…,M], where t represents the index of any category; S2. Using the data processing module to... Preprocessing was performed to obtain a preprocessed hyperspectral reflectance sample set of Chinese medicinal materials. ,in, Indicates the first preprocessed step A hyperspectral band reflectance sample, and , express In the The reflectance values corresponding to each band; S3. Construct a convolutional neural network with a neural network backbone architecture, and use... A convolutional neural network was trained to obtain a rapid identification model for the origin of Chinese medicinal materials. S4. Deploy the rapid identification model of Chinese medicinal material origin to the ZYNQ processing system to realize the identification of the origin of Chinese medicinal materials; S4.
1. The Chinese medicinal material origin rapid identification model is written using the HLS hardware description language and encapsulated into an IP core and then deployed 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 corresponding Astragalus membranaceus images from the SD card and sends them to the DDR3 storage unit for storage; at the same time, it sends the spectral data to be tested 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 membranaceus image into an AXI-stream format Astragalus membranaceus image and sends it to the CNN module; S4.4 Under the drive of the clock control module, the VDMA module reads the spectral data to be tested and its predicted origin category label through the AXI protocol and stores it in the DDR3 memory unit; S4.5 After the CNN module matches the predicted origin category label with the corresponding Astragalus membranaceus image, it sends it to the VDMA module. Then, driven by the clock control module, the VDMA module sends the predicted origin category label and its matching Astragalus membranaceus image to the HDMI control module, so that the HDMI control module can display the predicted origin category label and its matching Astragalus membranaceus image on the HDMI display screen.
2. The method for rapid identification of the origin of Chinese medicinal materials based on hyperspectral technology and neural networks according to claim 1, characterized in that, S2 include: S2.1 Using the YOLO object detection algorithm to... Perform automatic ROI extraction to obtain the target ROI dataset. ,in, express The target ROI region in the middle, and , express The Middle The reflectance values corresponding to each band; S2.2, Using formula (1) Noise smoothing is performed to obtain No. Smoothed reflectance corresponding to each band This yields the smoothed target ROI dataset. This leads to the smoothed target ROI dataset. : (1) In equation (1), yes The Middle The reflectance values corresponding to each band. It is the k-th coefficient of the smoothing window. It is half the width of the smooth window; S2.3, Using formula (2) Perform deviation elimination processing to obtain No. The reflectance after bias correction for each band Thus, the dataset after bias elimination is obtained. This leads to the final preprocessed dataset. : (2) In equation (2), Indicates the first The mean of the total band reflectance values of each hyperspectral band reflectance sample, and , Indicates the first The standard deviation of the total band reflectance values of a hyperspectral band reflectance sample .
3. The method for rapid identification of the origin of Chinese medicinal materials based on hyperspectral technology and neural networks according to claim 1, characterized in that, S3 includes: S3.1 The convolutional neural network consists of five layers of convolutional units and one classifier; S3.1.1 The first convolutional unit includes: a convolutional layer, a batch normalization layer, an activation layer, and a pooling layer; S3.1.1.1, The convolutional layer in the first convolutional unit uses equation (3) to... Perform convolution calculation to obtain the first... The first hyperspectral band reflectance sample The convolution result corresponding to each band Thus, the dimension is The Convolutional layer output dataset of hyperspectral band reflectance samples ,in, This indicates the number of convolutional kernels in the first convolutional unit: (3) In equation (3), express In the +n bands corresponding to reflectance values This represents the convolution kernel corresponding to the nth position. Indicates the size of the convolution kernel; S3.1.1.2, The batch normalization of the first layer convolutional unit is performed using equations (4) and (5). Processing yields the first... The first hyperspectral band reflectance sample Batch results for each band Thus, the dimension is The Batch normalized output dataset of hyperspectral band reflectance samples : (4) (5) In equations (4) and (5), Indicates the first The first hyperspectral band reflectance sample The standardized reflectance values corresponding to each band. Represents the reflectance sample of the i-th hyperspectral band. The mean, and , Represents the reflectance sample of the i-th hyperspectral band. The variance, and , This indicates a parameter used to prevent division by zero; , The first The scaling factor and the first One translation factor; S3.1.1.3, The activation layer in the first convolutional unit utilizes equation (6) to... The reflectivity of the activated layer is obtained through processing. Thus, the dimension is The Activated reflectance dataset of hyperspectral band reflectance samples : (6) In equation (6), ReLU represents the activation function; S3.1.1.4, The pooling layer in the first convolutional unit utilizes equation (7) for... The reflectivity after pooling is obtained through processing. Thus, the dimension is The Pooled reflectance dataset of hyperspectral band reflectance samples This leads to the first convolutional unit outputting a sample set of hyperspectral reflectance of Chinese medicinal materials. ,in, express The characteristic length, and , Indicates a pooled window: (7) In equation (7), Indicates the first The first hyperspectral band reflectance sample arrive Reflectivity within the specified spectral range; S3.1.2 The second convolutional unit is processed sequentially according to steps S3.1.1.1 to S3.1.1.
4. After processing, the hyperspectral reflectance sample set of Chinese medicinal materials output by the second convolutional unit is obtained. ,in, This indicates that the output dimension of the second convolutional unit is . The A pooled reflectance dataset of hyperspectral band reflectance samples, and , express After pooling, the first Reflectivity of each band This indicates the number of convolutional kernels in the second convolutional unit. express The characteristic length, and ; S3.1.3 The third convolutional unit is processed sequentially according to steps S3.1.1.1 to S3.1.1.
4. After processing, the hyperspectral reflectance sample set of Chinese medicinal materials output by the third convolutional unit is obtained. ,in, This indicates that the dimension of the output of the third convolutional unit is... The A pooled reflectance dataset of hyperspectral band reflectance samples, and , express After pooling, the first Reflectance values for each band, This indicates the number of convolutional kernels in the third convolutional unit. express The characteristic length, and ; S3.1.4 The fourth convolutional unit is processed sequentially according to steps S3.1.1.1 to S3.1.1.
4. After processing, the hyperspectral reflectance sample set of Chinese medicinal materials output by the fourth convolutional unit is obtained. ,in, This indicates that the output dimension of the fourth convolutional unit is... The A pooled reflectance dataset of hyperspectral band reflectance samples, and , express After pooling, the first Reflectance values for each band, This indicates the number of convolutional kernels in the fourth convolutional unit. express The characteristic length, and ; S3.1.5, The fifth convolutional unit is processed sequentially according to steps S3.1.1.1 to S3.1.1.
4. After processing, the hyperspectral reflectance sample set of Chinese medicinal materials output by the fifth convolutional unit is obtained. ,in, This indicates that the output dimension of the fifth convolutional unit is... The first A pooled reflectance dataset of hyperspectral band reflectance samples, and , express After pooling, the first Reflectance values for each band, This indicates the number of convolutional kernels in the fifth convolutional unit. express The characteristic length, and ; ; S3.1.6 The classifier includes: a fully connected layer and a Softmax layer; Will After flattening, the dimensions become A high-spectral reflectance sample set of Chinese medicinal herbs is obtained and input into the fully connected layer for processing to obtain a dimension of [missing information]. score vector ,in, express In the The corresponding score values for each category; The Softmax layer utilizes equation (8) to... Calculations were performed to obtain Belongs to the The probability of each category The category corresponding to the highest probability is used as the predicted origin category label: (8) S3.
2. Construct a cross-entropy loss function based on the real origin category label and the predicted origin category label. Use this function to train and test the convolutional neural network to update the network parameters until the cross-entropy loss function converges. This will give you the optimal parameters for the fast identification model of Chinese medicinal materials origin and save the weight parameters with the highest test accuracy.
4. An electronic device, comprising a memory and a processor, characterized in that, The memory is used to store programs that support the processor in executing the rapid identification system for the origin of Chinese medicinal materials based on hyperspectral technology and neural networks as described in any of claims 1-3, and the processor is configured to execute the programs stored in the memory.
5. A computer-readable storage medium storing a computer program thereon, characterized in that, When the computer program is run by the processor, it performs the steps of the rapid identification system for the origin of Chinese medicinal materials based on hyperspectral technology and neural networks as described in any of claims 1-3.
Citation Information
Patent Citations
Method for identifying producing area of astragalus membranaceus based on ultraviolet spectrum and convolutional neural network
CN116630675A
Method for discriminating producing area of angelica dahurica by using hyperspectral imaging technology
CN116543176A
Method and system for constructing traditional Chinese medicinal material identification model based on hyperspectral image processing
CN117935056A