Astragalus membranaceus quality marker rapid detection method and system based on near infrared spectrum

By combining near-infrared spectroscopy with a parallel dual-branch structure of CNNPath and EncoderPath, the problem of rapid and non-destructive detection of Astragalus quality markers is solved, achieving high-precision and rapid Astragalus origin classification, which is suitable for quality control in the medicinal material market and production process.

CN121617495APending Publication Date: 2026-03-06HENAN UNIVERSITY OF TECHNOLOGY
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202511548078.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-28
Publication Date
2026-03-06

AI Technical Summary

Technical Problem

Existing technologies are insufficient for the rapid, non-destructive, and accurate detection of quality markers for Astragalus membranaceus from different origins. Traditional methods are complex and time-consuming, and there is a lack of practical detection methods that combine deep learning and near-infrared spectroscopy.

Method used

A rapid detection method for quality markers of Astragalus membranaceus based on near-infrared spectroscopy is adopted. It utilizes a parallel dual-branch structure of CNNPath and EncoderPath, combined with an ECA channel attention module and a Transformer Encoder to extract local and global features. Through feature fusion and classification modules, rapid and non-destructive detection is achieved.

Benefits of technology

It achieves rapid and non-destructive detection of quality markers in Astragalus membranaceus, with a detection cycle of less than 10 seconds per sample, making it suitable for screening large batches of medicinal materials. The model has small parameters, making it suitable for embedded hardware deployment, and the classification accuracy reaches 98.31%.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121617495A_ABST
    Figure CN121617495A_ABST
Patent Text Reader

Abstract

The invention discloses a method and a system for rapidly detecting a quality marker of astragalus membranaceus based on near infrared spectrum, and relates to the field of food quality control and medicinal material identification, and the method comprises the following steps: collecting near infrared spectrum data of astragalus membranaceus; inputting the near infrared spectrum data into a detection model, and analyzing and outputting the production place information of the astragalus membranaceus by utilizing the detection model; the detection model comprises a local feature extraction branch, a global feature modeling branch and a feature fusion and classification module. The detection method comprises the following steps: inputting near infrared spectrum data into the local feature extraction branch to obtain a local feature vector; inputting the near infrared spectrum data into a global feature modeling branch to obtain a global feature vector; and inputting the local feature vector and the global feature vector into a feature fusion and classification module for feature fusion and classification, and outputting the prediction probability of the production place of the astragalus membranaceus. According to the method, the parallel double-branch structure of CNNPath and EncoderPath is fused with local and global features to realize rapid and nondestructive detection of astragalus membranaceus quality related markers, and astragalus membranaceus samples from different producing areas are accurately distinguished.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of food quality control and medicinal material identification, specifically to a rapid detection method and system for quality markers of Astragalus membranaceus based on near-infrared spectroscopy. Background Technology

[0002] Astragalus membranaceus is a representative medicinal and edible plant in traditional Chinese medicine, possessing various biological activities such as enhancing immunity, antioxidation, and anti-inflammation. However, the medicinal components and quality of Astragalus membranaceus are significantly affected by factors such as the place of origin and cultivation conditions. There are significant differences in the content of effective components among Astragalus membranaceus from different origins; for example, samples from Inner Mongolia have high polysaccharide content, while samples from Shanxi are rich in flavonoids. Therefore, conducting rapid detection research related to the origin and quality of Astragalus membranaceus is of great significance.

[0003] Currently, quality testing of Astragalus membranaceus largely relies on chemical analysis methods such as high-performance liquid chromatography (HPLC), which are complex, time-consuming, and highly destructive, making them unsuitable for rapid, on-site, and high-throughput screening. Near-infrared spectroscopy (NIR), as a non-destructive, high-throughput detection technology, has been widely used in the quality control of food, agricultural products, and traditional Chinese medicine. However, there is currently a lack of a practical, deployable, and rapid detection method that combines deep learning with NIR spectroscopy for the detection of quality markers in Astragalus membranaceus.

[0004] Chinese invention patent application number 202411826516.1 discloses a method for quality assessment of American ginseng based on multi-task deep learning, a computer-readable storage medium, and a computer program product. Specifically, it discloses the detection of ginsenosides and origin information of American ginseng based on near-infrared spectroscopy. However, this patent mainly adopts a single-branch serial structure, and realizes multi-task shared feature extraction through the cascading of "residual + attention module", and multi-task collaboratively improves the prediction performance of origin and saponins. Summary of the Invention

[0005] This invention provides a rapid detection method and system for quality markers of Astragalus membranaceus based on near-infrared spectroscopy. By fusing local and global features through a parallel dual-branch structure of CNNPath and EncoderPath, it achieves rapid and non-destructive detection of quality-related markers of Astragalus membranaceus and accurately distinguishes Astragalus membranaceus samples from different origins.

[0006] To achieve the above objectives, the specific solution adopted by the present invention is as follows: a rapid detection method for quality markers of Astragalus membranaceus based on near-infrared spectroscopy, comprising: Near-infrared spectral data of Astragalus membranaceus were collected; Near-infrared spectral data is input into the detection model, and the detection model is used to analyze and output information on the origin of Astragalus membranaceus. The detection model includes a local feature extraction branch, a global feature modeling branch, and a feature fusion and classification module. The detection method is as follows: Near-infrared spectral data is input into the local feature extraction branch to obtain local feature vectors; Near-infrared spectral data is input into the global feature modeling branch to obtain the global feature vector; The local and global feature vectors are input into the feature fusion and classification module for feature fusion and classification, and the predicted probability of the origin of Astragalus membranaceus is output.

[0007] As a further optimization of the above technical solution: the local feature extraction branch includes an ECA channel attention module and three convolution modules. The method for the local feature extraction branch to obtain local feature vectors is as follows: the convolution module performs local convolution operations on the input near-infrared spectral data to extract detailed features in adjacent wavelength ranges; the ECA channel attention module assigns weights to the feature channels, focuses on the preset absorption band, and outputs a 64-dimensional local feature vector.

[0008] As a further optimization of the above technical solution: the preset absorption bands are 1140 nm, 1210 nm, and 1340 nm.

[0009] As a further optimization of the above technical solution: the global feature modeling branch includes a spectral block embedding layer, a position encoding layer, and a three-layer Transformer Encoder. Each Transformer Encoder layer includes a multi-head self-attention module, a one-dimensional convolution module, and a residual connection and layer normalization module. The method for obtaining the global feature vector in the global feature modeling branch is as follows: the spectral block embedding layer decomposes the wavelength dimension of the near-infrared spectral data into discrete semantic patch units to obtain multiple spectral patch sequences; the position encoding layer adds a learnable position code to each spectral patch sequence; the Transformer Encoder uses the multi-head self-attention module to calculate the dependencies between each band and identify long-range features; the one-dimensional convolution module supplements local information, enhances the spectral continuity expression of the network, and outputs a 64-dimensional global feature vector.

[0010] As a further optimization of the above technical solution: the block embedding layer includes 62 patches, each patch contains 4 wavelength points; each patch is mapped to a 64-dimensional embedding vector.

[0011] As a further optimization of the above technical solution: the feature fusion and classification module includes a feature concatenation layer, a multi-head self-attention module, and two fully connected layers. The feature concatenation layer concatenates local and global feature vectors, and the multi-head self-attention module performs feature interaction and adaptive fusion to enhance global expressive power. The two fully connected layers, together with the ReLU activation function and dropout regularization, realize multi-class task classification and finally output the predicted probability of the place of origin.

[0012] As a further optimization of the above technical solution: the wavelength of the near-infrared spectral data is 900–1700 nm.

[0013] As a further optimization of the above technical solution: near-infrared spectral data is denoised by DWT, normalized by SNV, and abnormal samples are removed by PCA + Mahalanobis distance before being input into the detection model.

[0014] As a further optimization of the above technical solution, the method for establishing the detection model is as follows: Astragalus samples were collected from multiple production areas; Near-infrared spectral data of Astragalus membranaceus samples were collected; A detection model is formed by constructing a local feature extraction branch, a global feature modeling branch, and a feature fusion and classification module. Cross-entropy loss was used as the loss function, and Adam was used as the optimizer to train the detection model. After training, the model was deployed on the Python 3.9 + PyTorch platform with 0.165M parameters.

[0015] A rapid detection system for quality markers of Astragalus membranaceus based on near-infrared spectroscopy is provided to implement the aforementioned detection method. The system includes a data acquisition module and a model execution module. The data acquisition module collects near-infrared spectral data of Astragalus membranaceus, and the model execution module runs the detection model. The detection model includes a local feature extraction branch, a global feature modeling branch, and a feature fusion and classification module. The local feature extraction branch extracts local feature vectors from the near-infrared spectral data, the global feature modeling branch extracts global feature vectors from the near-infrared spectral data, and the feature fusion and classification module fuses the local and global feature vectors to output the predicted probability of the Astragalus membranaceus's place of origin.

[0016] Compared with the prior art, the present invention has the following beneficial effects: 1. This invention introduces the ConvNeXt architecture, a modern convolutional network structure originating from the field of 3D image recognition, into one-dimensional near-infrared spectral data modeling for the first time, and proposes a 1DConvNeXt model architecture suitable for the multi-origin classification of Astragalus spectra.

[0017] 2. This invention combines self-attention and channel attention (ECA) mechanisms to further enhance the model's ability to model global spectral band dependencies based on local fine-grained feature extraction, and significantly improves the ability to identify key bands.

[0018] 3. Compared with traditional analytical methods such as HPLC and GC-MS, this invention does not require complex sample pretreatment, and the detection cycle is less than 10 seconds per sample, enabling online screening of large batches of medicinal materials.

[0019] 4. The model parameters of this invention are small (<0.2M), and the computational resource consumption is low. It supports embedded hardware deployment and is suitable for deployment and use in medicinal material markets, production bases, and warehousing and distribution links. Attached Figure Description

[0020] Figure 1 The schematic diagram of the detection model of the present invention shows that (a) CNNPath: local band feature extraction; (b) EncoderPath: global sequence dependency modeling; and (c) FusionClassifier: multi-head attention fusion module. Detailed Implementation

[0021] The technical solution of the present invention will be further described in detail below with reference to specific embodiments. Parts not described or disclosed in detail in the following embodiments of the present invention should be understood as prior art known or should be known by those skilled in the art.

[0022] This invention discloses a rapid detection method for quality markers of Astragalus membranaceus based on near-infrared spectroscopy, comprising the following steps: Near-infrared spectral data of Astragalus membranaceus were collected. Specifically, a DA7250 NIR spectrometer (spectral range 900–1700 nm, resolution 1 nm) was used to collect the near-infrared spectral data of Astragalus membranaceus. Before collection, the spectrometer was preheated, and the Astragalus membranaceus was placed at room temperature for equilibration for 5 hours (controlling the sample moisture content to approximately 10%). During collection, the Astragalus membranaceus samples (washed, 2 mm sliced, and dried) were placed on a rotating platform. Each sample was measured three times, and the average value was taken. Multi-angle spectral acquisition was achieved by using a rotating platform to avoid spectral deviations caused by sample inhomogeneity.

[0023] The acquired near-infrared spectral data were preprocessed, and the preprocessing steps included: Discrete wavelet transform (DWT) denoising: Removes high-frequency noise (such as ambient light interference and instrument electronic noise) from the spectrum while retaining feature information related to quality markers; Standard normal variable (SNV) standardization: eliminates spectral baseline drift caused by differences in sample particle size and packing density, and enhances the consistency of spectral data; Outlier removal: PCA (Principal Component Analysis) combined with Mahalanobis distance is used to calculate the Mahalanobis distance of each sample, and outlier samples are removed to ensure the reliability of the dataset.

[0024] The preprocessed near-infrared spectral data is input into the detection model, and the detection model is used to analyze and output the origin information of Astragalus membranaceus. The detection model used is a dual-branch convolutional-encoder fusion network (Dual-TCNet). This model includes a local feature extraction branch (CNNPath), a global feature modeling branch (EncoderPath), and a feature fusion and classification module (FusionClassifier). The detection method is as follows: Near-infrared spectral data is input into the local feature extraction branch to obtain local feature vectors; Near-infrared spectral data is input into the global feature modeling branch to obtain the global feature vector; The local and global feature vectors are input into the feature fusion and classification module for feature fusion and classification, and the predicted probability of the origin of Astragalus membranaceus is output.

[0025] The local feature extraction branch includes an ECA channel attention module and three convolutional modules. Each convolutional module contains a 1D convolutional layer, batch normalization (BatchNorm), ReLU activation function, and max pooling layer. The local feature extraction branch obtains local feature vectors by: performing local convolution operations on the input near-infrared spectral data through the convolutional modules to extract detailed features in adjacent wavelength ranges, such as local absorption peaks of quality markers; and weighting the feature channels through the ECA channel attention module to focus on preset absorption bands, outputting a 64-dimensional local feature vector. The preset absorption bands are 1140 nm (corresponding to the C–O stretching vibration of polysaccharides), 1210 nm (corresponding to the O–H stretching combination vibration of polysaccharides), 1340 nm (corresponding to the C–H bending vibration of flavonoids), and the 1200–1300 nm range (corresponding to the C–H and O–H combination bands of triterpenoid saponins).

[0026] The global feature modeling branch includes a spectral block embedding layer, a positional encoding layer, and a three-layer Transformer Encoder. Each Transformer Encoder includes a multi-head self-attention module, a one-dimensional convolution module, and a residual connection and layer normalization module. The global feature modeling branch obtains the global feature vector as follows: the spectral block embedding layer decomposes the wavelength dimension of the near-infrared spectral data into discrete semantic patch units, resulting in multiple spectral patch sequences. The block embedding layer includes 62 patches, each containing 4 wavelength points. Each patch is mapped to a 64-dimensional embedding vector. In this invention, the spectral block embedding layer decomposes the spectral data of 900–1700 nm into 62 discrete semantic patch units (each patch containing 4 wavelength points) and maps each patch to a 64-dimensional embedding vector.

[0027] The position coding layer adds learnable position codes to each spectral patch sequence, preserving the temporal information of the wavelengths.

[0028] The Transformer Encoder utilizes a multi-head self-attention module to calculate the dependencies between bands and identify long-range features. The Transformer Encoder includes a multi-head self-attention module, a one-dimensional convolution module, and a residual connection and layer normalization module. The multi-head self-attention module calculates the dependencies between bands to identify long-range spectral features (such as the correlation between absorption bands of different quality markers). The one-dimensional convolution module supplements local information to enhance the expression of spectral continuity, and finally outputs a 64-dimensional global feature vector.

[0029] The feature fusion and classification module includes a feature concatenation layer, a multi-head self-attention module, and two fully connected layers. The feature concatenation layer concatenates local and global feature vectors, and the multi-head self-attention module performs feature interaction and adaptive fusion to enhance global expressive power. The two fully connected layers, together with the ReLU activation function and dropout regularization, achieve multi-class task classification and finally output the predicted probability of the place of origin.

[0030] The rules for determining the country of origin are as follows: Based on the origin prediction probability output by the detection model, if the origin corresponding to the highest probability is consistent with the origin marked on the sample, and the confidence level (highest probability value) is ≥0.9, it is judged as "consistent origin", that is, the quality marker characteristics of the sample conform to the typical characteristics of Astragalus membranaceus from that origin. If the confidence level is less than 0.6, or the predicted origin does not match the labeled origin, it is judged as "significant deviation of predicted probability", and the sample needs to be tested again or further verified by combining other methods.

[0031] This invention discloses a rapid detection system for quality markers of Astragalus membranaceus based on near-infrared spectroscopy, used to implement the aforementioned detection method. The system includes a data acquisition module and a model execution module. The data acquisition module collects near-infrared spectral data of Astragalus membranaceus using a DA7250 NIR spectrometer (spectral range 900–1700 nm, resolution 1 nm), equipped with a rotating platform and sample pretreatment devices (washing, slicing, and drying components). The data acquisition module collects near-infrared spectral data of Astragalus membranaceus samples, performing multi-angle spectral measurements and data averaging during acquisition. Before acquisition, the system automatically completes instrument preheating and sample equilibrium monitoring.

[0032] The model execution module is used to run the detection model. The retrieval model is the aforementioned dual-branch convolutional-encoder fusion network (Dual-TCNet), deployed on the Python 3.9 + PyTorch platform. The model has 0.165M parameters and achieves a classification accuracy of 98.31%. The detection model includes a local feature extraction branch, a global feature modeling branch, and a feature fusion and classification module. The local feature extraction branch extracts local feature vectors from the near-infrared spectral data, the global feature modeling branch extracts global feature vectors from the near-infrared spectral data, and the feature fusion and classification module fuses the local and global feature vectors to output the predicted probability of the origin category of Astragalus membranaceus.

[0033] The training process for the detection model includes the following steps: Sample set construction: Samples were collected from five major Astragalus membranaceus producing areas: Shanxi, Gansu, Inner Mongolia, Sichuan, and Jilin. One hundred representative samples were collected from each region, totaling 500 samples. All samples were cleaned, sliced ​​into 2mm sections, dried at 60℃ (with moisture content controlled to approximately 10%), and then stored at 4℃ in the dark to ensure stable sample quality. Near-infrared spectral acquisition: A DA7250 NIR spectrometer (900–1700 nm, 1 nm resolution) was used. Each sample was measured three times and the average was taken. Data was collected from multiple angles using a rotating platform. Before spectral acquisition, the instrument should be preheated and the sample equilibrated to ensure data consistency. Peak feature extraction and preprocessing: Discrete wavelet transform (DWT) denoising + standard normal variable (SNV) normalization are used to remove high-frequency noise and scattering effects; Outlier samples were removed using PCA and Mahalanobis distance. Spectral characteristic regions such as 1140 nm, 1210 nm, and 1340 nm were extracted, corresponding to the NIR absorption bands of active ingredients such as polysaccharides, flavonoids, and saponins in Astragalus membranaceus.

[0034] Step 4: Dual-TCNet Model (Dual-Branch Convolutional-Encoder Fusion Network) This invention adopts the Dual-TCNet deep learning architecture, and its core technical solution includes: 1. Dual-branch structure: Local features are extracted by 1D-CNN, and global features are extracted by Transformer Encoder; 2. The ECA channel attention mechanism enhances key band channels; 3. Multi-head self-attention mechanism enables cross-domain fusion of features from CNN and Encoder; 4. The classification accuracy reaches 98.31%, which is better than traditional methods (SVM, PLS-DA, RF, 1D-CNN).

[0035] The model is deployed on the Python 3.9 + PyTorch platform, with only 0.165M parameters, making it suitable for embedded and portable devices and possessing practical promotional value.

[0036] I. Classification Algorithm Comparison of classification results using three machine learning algorithms: (1) Random forest is based on ensemble learning of multiple decision trees, and outputs the result RF through voting: Parameters: n_estimators=500, max_depth=100 (2) SVM handles nonlinear problems by finding the maximum margin hyperplane to separate the data or constructing a regression hyperplane.

[0037] Parameters: kernel='rbf', C=1.0, gamma='scale' (3) KNN is based on the distance between samples and predicts the result using the majority class or average of the nearest K neighbors.

[0038] Parameter: n_neighbors=5 II. Deep Learning Models 1. Introduction to Model Architecture To improve the feature extraction capability and classification accuracy of near-infrared spectroscopy, this invention introduces a dual-branch convolutional-encoder fusion network (Dual-TCNet), the structure of which is as follows: Figure 1 As shown.

[0039] The overall architecture of the model is divided into three main parts, as shown in Table 1: Table 1 Module Name Module composition Main functions 1️ CNNPath Branch (Local Feature Extraction Branch) It consists of three convolutional modules (Conv1D + BN + ReLU + MaxPooling) and an ECA channel attention mechanism. It is responsible for extracting local fine-grained features of the spectrum, namely the short-range dependence between adjacent wavelengths, and identifying local absorption peak information. 2️ EncoderPath branch (global feature modeling branch) It consists of a spectral block embedding layer, a position coding layer, and a 3-layer Transformer Encoder. Responsible for capturing global spectral dependencies, establishing long-range correlations between different bands, and avoiding being limited to local features. 3. FusionClassifier module (feature fusion and classification module) It consists of a multi-head self-attention mechanism and two fully connected layers (FC). The system is responsible for fusing the multi-scale features of the two branches to enhance global expressive power and ultimately complete the sample classification output. 2. The structure and function of each module The NIR spectral data has a dimension of B × 1 × 248 (B is the batch size), and after being input into the model, it is processed through two feature extraction branches: (1) CNNPath branch (local feature extraction branch), its structure is as follows: There are three convolutional modules (ConvBlock1–3), each containing: 1D convolutional layers, batch normalization, ReLU activation, and max pooling. The local feature extraction branch performs local convolution operations on the input near-infrared spectral data to extract detailed features in adjacent wavelength ranges; By weighting the feature channels using the ECA module, the model can focus on key absorption bands (such as 1140nm, 1210nm, and 1340nm) and suppress irrelevant or noisy signals. Output a set of 64-dimensional local feature vectors, representing the short-range feature patterns of the spectrum.

[0040] The changes in the number of channels and feature dimensions for each layer are as follows: Table 2. Changes in data shape within the network hierarchy Number of channels × Number of features enter 1×248 Block1 16×124 Block2 32×62 Block 3 64×31 The final output is mapped to a 64-dimensional feature vector through a fully connected layer.

[0041] (2) The EncoderPath branch (global feature modeling branch) has the following structure: Spectral patch embedding layer (62 patches × 4 wavelength points); Learnable location encoding; A 3-layer Transformer Encoder, each layer containing: Multi-head self-attention; One-dimensional convolution (Conv1D); Residual connectivity and layer normalization (LayerNorm).

[0042] The global feature modeling branch is used to divide the spectral sequence into several "segments" to form a semantic sequence; the multi-head self-attention mechanism is used to calculate the dependencies between each band and identify long-range features; one-dimensional convolution supplements local information and enhances the spectral continuity expression of the network; and a set of 64-dimensional global feature vectors is output to represent the overall structural features of the spectrum.

[0043] (3) The FusionClassifier module (feature fusion and classification module) has the following structure: Feature splicing layer; Multi-head self-attention mechanism; Two fully connected layers; Activation function ReLU and dropout regularization.

[0044] The feature fusion and classification module concatenates the features output by CNNPath and EncoderPath; Feature interaction and adaptive fusion are achieved through a multi-head self-attention mechanism; a fully connected layer is used to implement multi-class classification tasks; and the predicted probabilities of five origin categories (Shanxi, Gansu, Inner Mongolia, Sichuan, and Jilin) ​​are output.

[0045] 3. For ease of understanding, the complete workflow of the model (data flow + processing logic + output results) is briefly described below: Step 1: Input Data Preparation Input data: Near-infrared spectral data after DWT denoising and SNV normalization; Spectral range: 900–1700 nm; Sampling interval: 1 nm; Each sample contains 248 wavelength points; Input tensor dimension: B × 1 × 248 (B is the number of samples in the batch).

[0046] Step 2: Local Feature Extraction (CNNPath) Input: Near-infrared spectral sequence X (1×248); deal with: Local absorption peak features are extracted using three convolutional modules (Conv1D+BN+ReLU+Pooling); The channel weight w_i is calculated by the ECA channel attention module; Output the local feature matrix F_local (64×31); Intermediate results obtained: A = Local spectral feature representation (F_local) Step 3: Global Feature Extraction (EncoderPath) Input: The same spectral sequence X (1×248); deal with: The block embedding consists of 62 patches, each containing 4 wavelength points; Each patch is mapped to a 64-dimensional embedding vector; The overlay positional encoding is then input into a three-layer Transformer Encoder; Each layer calculates the global dependencies between bands using multi-head self-attention and one-dimensional convolution; Output the global feature matrix F_global (62×64); Intermediate results obtained: B = Global spectral feature representation (F_global) Step 4: Feature Fusion and Classification (FusionClassifier) Input: A and B; deal with: Concatenate F_local and F_global along the feature dimension; Feature fusion is performed using a multi-head self-attention mechanism; Five-class classification is performed using a two-layer fully connected network. Use Softmax to output the probability distribution; Output result: C = The origin category of the sample (e.g., Shanxi, Inner Mongolia, etc.) and the prediction confidence level.

[0047] Step 5: Result Evaluation Model training and validation employ cross-entropy loss. The optimizer is Adam; The model achieved an accuracy of 98.31% on the test set.

[0048] 4. The Role of Three Machine Learning Algorithms Although the final classification was performed by the Dual-TCNet model, in this invention, traditional machine learning algorithms (SVM, RF, KNN) were used for the three aspects shown in Table 3 below: Table 3 algorithm Phase of action Function Description Random Forest (RF) Model performance comparison Used to compare performance with deep learning models and verify the improved accuracy and robustness of Dual-TCNet. Support Vector Machine (SVM) Feature benchmarking Using features obtained from spectral preprocessing for traditional linear / nonlinear classification provides a benchmark performance for deep models. K-Nearest Neighbors (KNN) algorithm Data quality verification Used to verify the similarity and clustering distribution of spectra among samples from different origins, ensuring the rationality of sample labeling. 5. Experiment and Analysis (1) Comparison of deep learning models A systematic comparative analysis was conducted between the Dual-TCNet model and the traditional 1D-CNN, comparing key metrics such as convergence speed, training stability, and classification accuracy. Table 4 Comparison of Dual-TCNet and 1D-CNN (NIR spectroscopy, five-class classification task) Model Accuracy (%) Accuracy (%) Recall rate (%) F1 score Number of convergence rounds Number of parameters (M) FLOPs 1D-CNN 94.94 95.27 95.66 95.35 57 0.12 0.03 Dual-TCNet 98.31 98.39 98.31 98.32 27 0.165 0.01 Note: Dual-TCNet reached convergence after only 27 training rounds, demonstrating its stronger feature capture and optimization capabilities for small sample spectral data.

[0049] (2) Performance comparison between Dual-TCNet and machine learning models Table 5 Comparison of Dual-TCNet and traditional classifiers Model type Accuracy (%) Accuracy (%) Recall rate (%) F1 score SVM 91.42 90.88 90.67 90.79 RF 93.51 92.82 92.64 92.71 KNN 90.65 89.53 88.93 89.19 1D-CNN 94.94 95.27 95.66 95.35 Dual-TCNet 98.31 98.39 98.31 98.32 Conclusion: The Dual-TCNet model outperforms traditional machine learning and deep learning models on all metrics, especially showing a significant advantage in easily confused origin samples.

[0050] (3) Model visualization and interpretive analysis Attention heatmap analysis: CNNPath primarily focuses on the 1140nm and 1340nm wavelength bands; EncoderPath, on the other hand, assigns higher weights to the 900nm and 1210nm ranges. The two are highly complementary. t-SNE dimensionality reduction visualization shows that after Dual-TCNet feature extraction, samples from different origins are clearly separated in the feature space, the category boundaries are clear, and the model has good discriminative ability.

[0051] (4) Conclusion Dual-TCNet, a deep learning architecture that integrates local convolution and global Transformer feature modeling, has shown the following advantages in the classification of origin and identification of quality markers for Astragalus membranaceus, which is both a food and a medicinal herb: Fast convergence and high accuracy: Adaptable to small-sample NIR tasks, reducing convergence rounds by 53%; Strong feature representation capability: Channel attention + self-attention mechanism enhances multi-scale feature fusion; The model is lightweight and easy to deploy: the number of parameters is <0.2M, making it suitable for portable NIR detection equipment; High stability and generalization ability: suitable for analysis of samples from different years and origins.

[0052] In summary, Dual-TCNet is an efficient, stable, and easy-to-deploy solution for NIR medicinal material quality testing, with broad engineering application prospects.

[0053] It should be noted that this invention employs a detection logic of "spectral features → deep learning → quality marker association." Essentially, it is a non-destructive, feature-mapping detection method.

[0054] (1) Spectral acquisition stage Near-infrared spectra were collected in the range of 900–1700 nm; Each quality marker (polysaccharide, flavonoid, saponin) has absorption characteristics in specific wavelength bands; After DWT denoising and SNV normalization, a clean spectral signal matrix X (1×248) is obtained.

[0055] (2) Feature extraction stage (Dual-TCNet model) The CNNPath branch extracts local features (corresponding to specific wavelengths, such as 1140 nm and 1340 nm). The EncoderPath branch models global relationships between bands using Transformer; The model's attention weight distribution (Attention Map) reveals its "sensitivity" to different wavelengths; The visualization analysis revealed the following: The CNN branch focuses on 1140 nm and 1340 nm → corresponding to the absorption peaks of polysaccharides and flavonoids; The Encoder branch focuses on 1210 nm and 1250 nm → corresponding to the saponin characteristic bands.

[0056] (3) Model learning mechanism The model does not directly output "component concentration," but during the training process... By learning the spectra of samples from different origins, key wavelengths that can distinguish the origins were automatically captured. These key bands are precisely the bands where the content of quality markers varies the most in samples from different origins. Therefore, the discriminative features learned by the model actually reflect the content difference patterns of quality markers.

[0057] The method for detecting quality markers in Astragalus membranaceus is to establish a feature mapping model by using the absorption characteristic regions related to polysaccharides, flavonoids, and saponins in the near-infrared spectrum, thereby achieving rapid and non-destructive indirect detection of quality markers.

[0058] The geographical differences in the origin of Astragalus membranaceus directly lead to differences in the content of its quality markers (polysaccharides, flavonoids, saponins, etc.), forming characteristic patterns that can be identified by spectroscopy, as shown in Table 6: Origin Characteristic chemical components Spectral performance Feature responses learned by the model Inner Mongolia High in polysaccharides 1140 nm absorption enhancement CNNPath high response Shanxi High in flavonoids 1340 nm absorption enhancement EncoderPath high response Gansu Polysaccharides, saponins, etc. 1210–1250 nm equilibrium response Smoothing of attention distribution Sichuan and Jilin Low content The absorption peaks are generally weak. Features are relatively dispersed The model logic is as follows: 1. The model receives spectral signals; 2. Identify spectral peaks related to quality markers using a feature extraction network; 3. By integrating the characteristics of each band, a "mass marker content distribution vector" is formed; 4. Input the vector into the classification layer; 5. Output the origin category with the highest probability.

[0059] Therefore, the "origin" result output by the model is essentially a discriminative model result based on the differences in the distribution characteristics of quality markers of Astragalus membranaceus from different origins. It realizes the entire chain logic from "spectrum → quality marker pattern → origin classification".

[0060] The quality markers detected in Astragalus membranaceus in this invention include polysaccharides, flavonoids, and triterpenoid saponins. The detection method is based on the absorption band response characteristics of near-infrared spectroscopy, and uses the Dual-TCNet model to extract spectral features associated with these components. The ECA and Transformer modules in the model automatically focus on these key bands, realizing indirect and non-destructive detection of the markers. The origin discrimination results are based on the spectral patterns of differences in the content distribution of quality markers. Therefore, this scheme is not only an "origin classification model" but also a comprehensive and rapid quality identification method based on the spectral differences of quality markers.

[0061] Application Experiment 1: Quality Sampling and Verification Process of Medicinal Herbs Market 1. Sample source and labeled place of origin In a traditional Chinese medicine wholesale market in a central province, five stalls (numbered A–E) were randomly selected, and six Astragalus membranaceus samples were collected from each stall, for a total of 30 samples. The stall owners labeled the origin of each sample as follows: Booth A: Hunyuan County, Shanxi Province; Booth B: Longxi County, Gansu Province; Booth C: Chifeng City, Inner Mongolia; Booth D: Tonghua City, Jilin Province; Booth E: Liangshan Prefecture, Sichuan Province.

[0062] Each sample was subjected to standard cleaning, slicing (2 mm thick), drying (60 °C to approximately 10% moisture content), and stored in the dark at 4 °C.

[0063] 2. Near-infrared spectral acquisition and preprocessing Instrument model: DA7250 NIR spectrometer (900–1700 nm, resolution 1 nm); Each sample was randomly rotated three times, and the average was taken. Preprocessing method: Discrete wavelet transform (DWT) denoising + standard normal variable (SNV) normalization; The resulting spectral matrix has a dimension of 30 × 248.

[0064] 3. Model Input and Prediction The preprocessed spectral data is input into the Dual-TCNet model (Dual-branch CNN–EncoderNetwork). The model has been pre-trained using 588 samples from five major production areas (Shanxi, Gansu, Inner Mongolia, Jilin, and Sichuan). The model output is a predicted probability vector P = [p1, p2, p3, p4, p5] for each sample corresponding to five origin categories; Where p1–p5 represent the probabilities of belonging to Shanxi, Gansu, Inner Mongolia, Jilin, and Sichuan, respectively; Judgment rules: If the place of origin corresponding to the highest probability is consistent with the place of origin labeled on the sample, and the confidence level is ≥ 0.9, it is judged as consistent; If the confidence level is less than 0.6 or the highest probability origin predicted by the model does not match the labeled origin, it is judged as "significant deviation of predicted probability".

[0065] The prediction results are shown in Table 7: Sample number Place of origin Model predicts origin Highest prediction probability Judgment Result A-3 Shanxi Inner Mongolia 0.42 Significant deviation C-5 Inner Mongolia Gansu 0.37 Significant deviation D-2 Jilin Sichuan 0.44 Significant deviation The remaining 27 copies — Consistent 0.91–0.98 Consistent The overall accuracy of the model was 90% (27 / 30), with 3 samples showing a significantly different predicted probability from their labeled origin.

[0066] Application Experiment 2: Real-time Quality Control Application in Production Base This invention was applied to the pre-harvest quality control process at an Astragalus membranaceus planting base in Inner Mongolia. Fifteen samples were taken from each batch of Astragalus membranaceus before harvest, and all samples were uniformly dried to a moisture content of 10%. Laboratory-grade NIR equipment was used to collect the spectral data of the samples, which was then input into a pre-trained Dual-TCNet model in real time.

[0067] In actual testing, this method quickly identified a batch of Astragalus membranaceus samples affected by early frost, whose spectral absorption characteristics in the 1210nm and 1340nm range significantly deviated from other samples. Based on the model's judgment results, the base personnel promptly rejected this batch, preventing substandard products from entering the market.

[0068] This embodiment demonstrates that the method can serve as a quality control "outpost" before the harvesting stage, significantly improving the overall product qualification rate of the production chain.

[0069] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A rapid detection method for quality markers of Astragalus based on near-infrared spectroscopy, characterized in that, The application relates to a method for detecting the origin of Astragalus membranaceus, comprising the following steps: Collecting near-infrared spectrum data of Astragalus membranaceus; Inputting the near-infrared spectrum data into a detection model, and analyzing and outputting the origin information of Astragalus membranaceus by using the detection model; The detection model comprises a local feature extraction branch, a global feature modeling branch and a feature fusion and classification module, and the detection method is as follows: Inputting the near-infrared spectrum data into the local feature extraction branch to obtain a local feature vector; Inputting the near-infrared spectrum data into the global feature modeling branch to obtain a global feature vector; Inputting the local feature vector and the global feature vector into the feature fusion and classification module for feature fusion and classification, and outputting the prediction probability of the origin of Astragalus membranaceus.

2. The method according to claim 1, wherein the method is characterized by: The local feature extraction branch comprises an ECA channel attention module and three convolution modules, and the method for obtaining the local feature vector by the local feature extraction branch is as follows: performing local convolution operation on the input near-infrared spectrum data by the convolution module to extract the detail features of adjacent wavelength intervals; and weighting the feature channels by the ECA channel attention module, focusing on the preset absorption wavelength band, and outputting a 64-dimensional local feature vector.

3. The method according to claim 2, wherein the method is characterized by: The preset absorption wavelength band is 1140 nm, 1210 nm and 1340 nm.

4. The method according to claim 1, wherein the method is characterized by: The global feature modeling branch comprises a spectrum block embedding layer, a position encoding layer and three-layer Transformer Encoder encoders, each of which comprises a multi-head self-attention module, a one-dimensional convolution module, a residual connection and a layer normalization module; The method for obtaining the global feature vector by the global feature modeling branch is as follows: the spectrum block embedding layer decomposes the wavelength dimension of the near-infrared spectrum data into discrete semantic patch units to obtain a plurality of spectrum patch sequences; the position encoding layer adds learnable position encoding to each spectrum patch sequence; the Transformer Encoder encoder calculates the dependency between the wavelength bands by using the multi-head self-attention module to identify long-range features; and the one-dimensional convolution module supplements local information and enhances the spectral continuity expression of the network to output a 64-dimensional global feature vector.

5. The method according to claim 4, wherein the method is characterized by: The block embedding layer comprises 62 patches, each of which contains 4 wavelength points; and each patch is mapped into a 64-dimensional embedding vector.

6. The method according to claim 1, wherein the method is characterized by: The feature fusion and classification module comprises a feature splicing layer, a multi-head self-attention module and two-layer full connection layers, the local feature vector and the global feature vector are spliced by the feature splicing layer, then the feature splicing layer is subjected to feature interaction and adaptive fusion by the multi-head self-attention module, the global expression capability is enhanced, the two-layer full connection layers are combined with a ReLU activation function and a dropout regularization to realize multi-class task classification, and finally the prediction probability of the origin is output.

7. The method according to claim 1, wherein the method is characterized by: The wavelength of the near-infrared spectrum data is 900-1700 nm.

8. The method according to claim 1, wherein the method is characterized by: The near-infrared spectrum data is input into the detection model after being denoised by DWT, being standardized by SNV and being removed of abnormal samples by the PCA+Mahalanobis distance method.

9. The method according to claim 1, wherein the method is characterized by: The method for establishing the detection model is as follows: Collecting Astragalus membranaceus samples from multiple production areas; Collecting the near-infrared spectrum data of the Astragalus membranaceus samples; Constructing the local feature extraction branch, the global feature modeling branch and the feature fusion and classification module to form the detection model; The detection model is trained by using cross-entropy loss as a loss function and Adam as an optimizer, and is deployed on a Python 3.9+PyTorch platform after training, with a parameter quantity of 0.165M.

10. A rapid detection system for quality markers of Astragalus based on near infrared spectroscopy, characterized in that, The method comprises a data acquisition module and a model running module, the data acquisition module is used for acquiring the near-infrared spectrum data of the Huangqi, and the model running module is used for running the detection model, the detection model comprises a local feature extraction branch, a global feature modeling branch and a feature fusion and classification module, the local feature extraction branch is used for extracting a local feature vector of the near-infrared spectrum data, the global feature modeling branch is used for extracting a global feature vector of the near-infrared spectrum data, and the feature fusion and classification module is used for fusing the local feature vector and the global feature vector, and outputting a prediction probability of a producing area category to which the Huangqi belongs.

Citation Information

Patent Citations

  • American ginseng quality evaluation method based on multi-task deep learning, computer readable storage medium and computer program product

    CN119622520A