Method, device, equipment and medium for detecting content of ginsenoside in American ginseng
The global spatiotemporal semantic features of American ginseng spectral time series data were extracted through a deep learning-improved 1D convolutional neural network detection model, which solved the problem of low detection efficiency of traditional chemical methods and achieved efficient detection of ginsenoside content in American ginseng.
Patent Information
- Application Number
- CN202511019909.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-23
- Publication Date
- 2025-10-17
AI Technical Summary
Existing methods for detecting ginsenosides in American ginseng rely on traditional chemical methods such as HPLC or TLC, resulting in low detection efficiency and poor real-time performance.
A deep learning-based improved 1D convolutional neural network detection model was used to obtain spectral time series data, extract global spatiotemporal semantic feature maps, and determine the ginsenoside content of American ginseng.
The efficiency of ginsenoside detection in American ginseng has been improved, the inadequacy of detection by traditional chemical methods has been avoided, and a more efficient detection effect has been achieved.
Smart Images

Figure CN120801592A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of medicinal material quality detection, and in particular to a ginsenoside content detection method, device, equipment and medium for Panax quinquefolium. BACKGROUND
[0002] Panax quinquefolium is a food and medicine homologous traditional Chinese medicinal material with important medicinal and health care values, and its main active ingredient is ginsenoside; with the improvement of health consciousness and the expansion of the functional food market, the market demand for Panax quinquefolium and its ginsenoside continues to grow, and in the industrialization application thereof, column chromatography technology is used as a core separation means for separating ginsenoside in Panax quinquefolium.
[0003] In the column chromatography process, the total amount of separated ginsenoside needs to be detected; however, the existing detection is mainly dependent on traditional chemical means such as HPLC or TLC, which not only has a long operation period, but also has problems such as data feedback delay and poor real-time in the detection process, resulting in low efficiency of ginsenoside total amount detection. SUMMARY
[0004] Therefore, the purpose of the present application is to overcome the deficiencies in the prior art, and to provide a ginsenoside content detection method for Panax quinquefolium, which comprises: obtaining spectral time series data of a column chromatography sample of a target Panax quinquefolium; inputting the spectral time series data into a preset detection model, and extracting a global spatiotemporal semantic feature map of the spectral time series data; determining the ginsenoside content of the target Panax quinquefolium according to the global spatiotemporal semantic feature map through the detection model.
[0005] In an embodiment, the step of inputting the spectral time series data into a preset detection model and extracting a global spatiotemporal semantic feature of the spectral time series data comprises: inputting the spectral time series data into a first convolution module in the preset detection model, and extracting a local spectral variation feature map of the spectral time series data; inputting the local spectral variation feature map into a second convolution module in the detection model, and extracting a local spatiotemporal semantic feature map of the spectral time series data; inputting the local spatiotemporal semantic feature map into a third convolution module in the detection model, and extracting a global spatiotemporal semantic feature map of the spectral time series data.
[0006] In an embodiment, the step of inputting the local spatiotemporal semantic feature map into a third convolution module in the detection model and extracting a global spatiotemporal semantic feature map of the spectral time series data comprises: inputting the local spatio-temporal semantic feature map into a convolution layer and a normalization layer of a third convolution module in the detection model, and outputting a normalized local spatio-temporal semantic feature map; based on an attention mechanism module in the third convolution module, extracting a query matrix, a key matrix and a value matrix of the normalized local spatio-temporal semantic feature map, and determining a local spatio-temporal semantic weight feature map based on the query matrix, the key matrix and the value matrix; inputting the local spatio-temporal semantic weight feature map into a max-pooling layer of the third convolution module, and outputting a global spatio-temporal semantic feature map of the spectral time series data.
[0007] In an embodiment, the step of determining the ginsenoside content of the target American ginseng according to the global spatio-temporal semantic feature map by the detection model comprises: inputting the global spatio-temporal semantic feature map into an average pooling layer of the detection model, performing compression processing on the global spatio-temporal semantic feature map in the time dimension to obtain a target feature map; inputting the target feature map into a fully connected layer of the detection model, and outputting the ginsenoside content of the target American ginseng.
[0008] In an embodiment, the step of obtaining the spectral time series data of the column chromatography sample of American ginseng comprises: collecting reference spectral time series data of a column chromatography sample of target American ginseng; preprocessing the reference spectral time series data to remove noise, baseline drift and light scattering in the reference spectral time series data; performing normalization processing on the preprocessed reference spectral time series data to obtain spectral time series data.
[0009] In an embodiment, the method further comprises: obtaining spectral time series training sample data of a column chromatography sample of a sample American ginseng, and training a target neural network based on the spectral time series training sample data to obtain a reference detection model; obtaining spectral time series verification sample data of a column chromatography sample of a sample American ginseng and a preset loss function, verifying the reference detection model based on the spectral time series verification sample data and the loss function until a loss function value meets a first preset requirement, and obtaining the detection model.
[0010] In an embodiment, the method further comprises: obtaining spectral time series test sample data of a column chromatography sample of a sample American ginseng, and testing the detection model based on the spectral time series test sample data to obtain a test prediction result; calculate a correlation coefficient, a root mean square error and a residual prediction bias between the test prediction result and the true ginsenoside content of the American ginseng sample; If the correlation coefficient, the root mean square error or the residual prediction bias does not meet the second preset requirement, the detection model is retrained until the correlation coefficient, the root mean square error or the residual prediction bias all meet the second preset requirement.
[0011] The application also provides an American ginseng ginsenoside content detection device, which comprises: The acquisition module is configured to acquire spectral time series data of a column chromatography sample of a target American ginseng. The extraction module is configured to input the spectral time series data into a preset detection model and extract a global spatio-temporal semantic feature map of the spectral time series data. The determination module is configured to determine the ginsenoside content of the target American ginseng according to the global spatio-temporal semantic feature map by using the detection model.
[0012] The application also provides a computer device, which comprises a processor and a memory. The memory stores a computer program. The processor is configured to execute the computer program to implement the American ginseng ginsenoside content detection method.
[0013] The application also provides a computer readable storage medium, which stores a computer program. The computer program is configured to execute the American ginseng ginsenoside content detection method when running on a processor.
[0014] The application has the following beneficial effects: The application acquires spectral time series data of a column chromatography sample of a target American ginseng, inputs the spectral time series data into a preset detection model, extracts a global spatio-temporal semantic feature map of the spectral time series data, and determines the ginsenoside content of the target American ginseng according to the global spatio-temporal semantic feature map by using the detection model. The method detects the spectral time series data of the American ginseng by using the detection model, extracts a global spatio-temporal semantic feature map, and determines the ginsenoside content of the American ginseng based on the global spatio-temporal semantic feature map, thereby avoiding the use of traditional chemical methods for detection and improving the detection efficiency of the ginsenoside content of the American ginseng. BRIEF DESCRIPTION OF DRAWINGS
[0015] In order to more clearly illustrate the technical solutions of the present application, the following will briefly introduce the drawings needed in the embodiments. It should be understood that the following drawings only show some embodiments of the present application, and therefore should not be regarded as limiting the scope of protection of the present application. For those skilled in the art, other related drawings can also be obtained without creative labor on the basis of these drawings.
[0016] Figure 1 The flowchart of the first embodiment of the ginsenoside content detection method of American ginseng provided in the present application is shown in the figure. Figure 2 The flowchart of the second embodiment of the ginsenoside content detection method of American ginseng provided in the present application is shown in the figure. Figure 3 The structural diagram of the detection model provided in the present application is shown in the figure. Figure 4 The flowchart of the third embodiment of the ginsenoside content detection method of American ginseng provided in the present application is shown in the figure. Figure 5 The flowchart of the fourth embodiment of the ginsenoside content detection method of American ginseng provided in the present application is shown in the figure. Figure 6 The flowchart of the fifth embodiment of the ginsenoside content detection method of American ginseng provided in the present application is shown in the figure. Figure 7 The structural diagram of the ginsenoside content detection device of American ginseng provided in the present application is shown in the figure. DETAILED DESCRIPTION
[0017] The technical solutions in the embodiments of the present application will be described clearly and completely below in combination with the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments of the present application.
[0018] The components of the embodiments of the present application generally described and shown in the drawings herein can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the claimed present application, but only represents selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.
[0019] Hereinafter, the terms "include", "have", and their conjugations, used in the various embodiments of the present application, merely indicate the presence of the features, numbers, steps, operations, elements, components, or combinations thereof, and do not exclude the possibility of the presence or addition of one or more other features, numbers, steps, operations, elements, components, or combinations thereof.
[0020] In addition, the terms "first", "second", "third", and the like are used only to distinguish descriptions, and cannot be understood as indicating or implying relative importance.
[0021] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which the various embodiments of the present application belong. The terms (such as those defined in commonly used dictionaries) will be interpreted as having a meaning that is the same as the contextual meaning in the relevant technical field and will not be interpreted in an idealized or overly formal sense, unless clearly defined in the various embodiments of the present application.
[0022] It can be understood that the method of the present application is applied to a detection device, which can be a smart terminal, a PC terminal, a mobile terminal, etc., without limitation.
[0023] Some embodiments of the present application will be described in detail below with reference to the accompanying drawings. The following embodiments and features in the embodiments can be combined with each other without conflict.
[0024] Please refer to Figure 1 , Figure 1 The first embodiment of the method for detecting ginsenoside content of Panax quinquefolium provided by the present application is shown in the flowchart, and the method comprises: Step S101, obtaining spectral time series data of a column chromatography sample of a target Panax quinquefolium.
[0025] In the present embodiment, the detection device obtains spectral time series data of a column chromatography sample of a target Panax quinquefolium. The target Panax quinquefolium is a sample whose ginsenoside content needs to be detected, and the column chromatography sample is generated when the target Panax quinquefolium is subjected to column chromatography.
[0026] In an embodiment, the Panax quinquefolium sample used by the present application is from Wendeng area in Shandong, and is identified by experts in the pharmacy department of a traditional Chinese medicine hospital. All sample slices are stored in a drug cool cabinet at 4℃ to ensure sample consistency during hyperspectral analysis.
[0027] In an embodiment, the detection device is equipped with a near-infrared spectrometer and a high-performance liquid chromatograph. The near-infrared image of the column chromatography sample is captured by the spectrometer, and the near-infrared image is analyzed by the high-performance liquid chromatograph to obtain reference spectral time series data of the column chromatography sample of the target American ginseng. The reference spectral time series data is preprocessed to obtain preprocessed spectral time series data.
[0028] In step S102, the spectral time series data is input into a preset detection model to extract a global spatiotemporal semantic feature map of the spectral time series data.
[0029] In this embodiment, after the detection device obtains the spectral time series data, the spectral time series data is input into a preset detection model to extract a global spatiotemporal semantic feature map of the spectral time series data.
[0030] In an embodiment, the preset detection model is obtained by training an improved 1D convolutional neural network based on deep learning. The detection model integrates a convolution layer (Conv1D), a batch normalization (BatchNorm), a self-attention mechanism (SelfAttention), a global average pooling (GAP), and a fully connected layer (Dense), and is used to predict the ginsenoside content in American ginseng from the spectral time series data.
[0031] In an embodiment, the global spatiotemporal semantic feature map in the spectral time series data includes shallow features, middle features, and high features of the spectral time series data extracted by the detection model.
[0032] In step S103, the detection model determines the ginsenoside content of the target American ginseng according to the global spatiotemporal semantic feature map.
[0033] In this embodiment, after the detection device extracts the global spatiotemporal semantic feature map of the spectral time series data by the detection model, the detection model determines the ginsenoside content of the target American ginseng according to the global spatiotemporal semantic feature map.
[0034] In an embodiment, the detection model uses a global average pooling layer (Global Average Pooling) to compress features in all time dimensions of the global spatiotemporal semantic feature map, thereby further unifying the feature dimensions and significantly reducing the parameters. Then, the compressed global spatiotemporal semantic feature map is sent to a fully connected layer for nonlinear mapping, and finally, the prediction value is output by the fully connected layer of the output neuron. The prediction value is a real number, which is used to represent the ginsenoside content of the target American ginseng.
[0035] The detection equipment of the embodiment acquires spectral time series data of a column chromatography sample of target American ginseng; inputs the spectral time series data into a preset detection model to extract a global space-time semantic feature map of the spectral time series data; and determines the ginsenoside content of the target American ginseng according to the global space-time semantic feature map through the detection model. The spectral time series data of the American ginseng is detected through the detection model, the global space-time semantic feature map is extracted, and the ginsenoside content of the American ginseng is determined based on the global space-time semantic feature map, thereby avoiding detection by using traditional chemical methods and improving the detection efficiency of the ginsenoside content of the American ginseng.
[0036] Please refer to Figure 2 , Figure 2 The flowchart of the second embodiment of the ginsenoside content detection method of American ginseng provided in the application is different from the first embodiment in that the step of inputting the spectral time series data into a preset detection model to extract a global space-time semantic feature in the spectral time series data includes: Step S201: inputting the spectral time series data into a first convolution module in the preset detection model to extract a local spectral change feature map of the spectral time series data.
[0037] In the embodiment, the detection equipment inputs the spectral time series data into a first convolution module in the preset detection model to extract a local spectral change feature map of the spectral time series data. The features in the local spectral change feature map are basic physical properties of the spectral time series data, and the feature performances include: spectral peak position (such as the absorption peak and emission peak at a wavelength of 1100 nm in near-infrared spectroscopy), peak intensity, peak width; spectral slope change (such as the water absorption band slope near a wavelength of 1450 nm in near-infrared spectroscopy); intensity fluctuation in a local wavelength interval (such as baseline drift in a wavelength of 900-1000 nm in near-infrared spectroscopy), etc.
[0038] Step S202: inputting the local spectral change feature map into a second convolution module in the detection model to extract a local space-time semantic feature map of the spectral time series data.
[0039] In the embodiment, after obtaining the local spectral change feature map output by the first convolution module, the detection equipment inputs the local spectral change feature map into a second convolution module in the detection model to extract a local space-time semantic feature map of the spectral time series data. The features in the local space-time semantic feature map are structural and pattern features of the spectral time series data, and the feature performances include: combination mode of characteristic peaks (such as the combined absorption peaks of CH2 and CH2 in near-infrared spectroscopy); correlation of spectral bands (such as the correlation of 900-1000 nm -1 and 1000-1500 nm -1peak-shaped correlation); intensity ratio of characteristic regions (such as the intensity ratio of 700-800 nm wavelength to 900-1000 nm wavelength in the near-infrared spectrum).
[0040] Step S203: input the local spatiotemporal semantic feature map into the third convolution module in the detection model to extract the global spatiotemporal semantic feature map of the spectral time series data.
[0041] In this embodiment, after obtaining the local spatiotemporal semantic feature map output by the second convolution module, the detection device inputs the local spatiotemporal semantic feature map into the third convolution module in the detection model to extract the global spatiotemporal semantic feature map of the spectral time series data. The features in the global spatiotemporal semantic feature map are the semantic and classification features of the spectrum. These features include: discriminant features of substance type (e.g., the spectral feature differences between ginsenosides Rg1 and Rb1 in American ginseng); implicit features of sample state (e.g., spectral degradation patterns of fresh and aged samples); and associated features of component concentrations (e.g., near-infrared spectral feature vectors corresponding to the concentrations of ginsenosides Rg1, Re, Rb1, Rc, Rb2, and Rd in American ginseng).
[0042] For example, Figure 3 As shown, Figure 3 It is a structural diagram of the detection model; the detection model includes a first convolution module, a second convolution module and a third convolution module. Among them, the first convolution module includes: a 1D convolution layer (Conv1D layer (32 filters)) containing 32 convolution kernels, followed by a batch normalization layer (BatchNorm 1d (32)) to improve training stability, and a self-attention mechanism module (Self-Attention (32)) to enhance the dependency between features, and finally a layer of maximum pooling layer (MaxPooling 1d) to achieve downsampling operation; the second convolution module includes a 1D convolution layer (Conv1D layer (64 filters)) containing 64 convolution kernels, followed by a batch normalization layer (BatchNorm 1d (64)) to improve training stability, and a self-attention mechanism module (Self-Attention (64)) to enhance the dependency between features, and finally a layer of maximum pooling layer (MaxPooling 1d) to achieve downsampling operation; the third convolution module includes a 1D convolution layer (Conv1D layer (128 filters)), followed by a batch normalization layer (BatchNorm 1d (128)) to improve training stability, and a self-attention mechanism module (Self-Attention (128)) to enhance the dependency between features, and finally a maximum pooling layer (MaxPooling 1d) to achieve downsampling operation.
[0043] The detection device of this embodiment, through the three-layer convolution module of the detection module, sequentially extracts the local spectral change feature map, local spatiotemporal semantic feature map, and global spatiotemporal semantic feature map of the spectral time series data. Through the multi-level feature extraction method, the detection model can accurately identify the key information in the spectral time series data at multiple scales, which helps to achieve accurate prediction of ginsenoside content.
[0044] In one embodiment, the step of inputting the local spatiotemporal semantic feature map into the third convolution module in the detection model to extract the global spatiotemporal semantic feature map of the spectral time series data includes: Step S2031: input the local spatiotemporal semantic feature map into the convolution layer and normalization layer of the third convolution module in the detection model, and output a normalized local spatiotemporal semantic feature map.
[0045] In this embodiment, after the detection device outputs the local spatiotemporal semantic feature map through the second convolution module of the detection model, the local spatiotemporal semantic feature map is input into the convolution layer and normalization layer of the third convolution module in the detection model, and outputs the normalized local spatiotemporal semantic feature map.
[0046] In one embodiment, the formula for calculating the normalized local spatiotemporal semantic feature map is:
[0047] Among them, h3 is the normalized local spatiotemporal semantic feature map, ReLU is the convolution operation, and BN is the normalization operation. is the local spatiotemporal semantic feature map, W3 is the normalized weight value, and b3 is the normalized bias value. The formula for the convolution operation is: , is the i-th feature in the feature map, K is the convolution kernel size, For the The k-th weight of the convolutional layer, is the number of convolutional layers, x i+k-1 is the data of k consecutive wavelength points taken by the convolution kernel in the spectral time series data or the features of k consecutive pixels extracted in the feature map, b (l) It is The bias term of the convolutional layer.
[0048] Step S2032: Based on the attention mechanism module in the third convolution module, the query matrix, key matrix and value matrix of the normalized local spatiotemporal semantic feature map are extracted, and the local spatiotemporal semantic weight feature map is determined based on the query matrix, the key matrix and the value matrix.
[0049] In this embodiment, the detection device extracts the query matrix, the key matrix and the value matrix of the normalized local spatio-temporal semantic feature map based on the attention mechanism module in the third convolution module, and determines the local spatio-temporal semantic weight feature map based on the query matrix, the key matrix and the value matrix.
[0050] In an embodiment, the formula for calculating the local spatio-temporal semantic weight feature map is:
[0051] wherein h3 is the normalized local spatio-temporal semantic feature map, is the local spatio-temporal semantic weight feature map, and Attention is the attention mechanism. Wherein, , Q is the query matrix, K is the key matrix, V is the value matrix, H is the feature map, d k is the dimension of the key matrix, is used to scale the score to avoid gradient disappearance, T is the matrix transpose, and softmax() is the normalized attention weight.
[0052] In step S2033, the local spatio-temporal semantic weight feature map is input into the max-pooling layer of the third convolution module, and the global spatio-temporal semantic feature map of the spectral time series data is output.
[0053] In this embodiment, the detection device inputs the local spatio-temporal semantic weight feature map into the max-pooling layer of the third convolution module, and outputs the global spatio-temporal semantic feature map of the spectral time series data.
[0054] In an embodiment, the formula for calculating the global spatio-temporal semantic feature map is:
[0055] wherein, is the local spatio-temporal semantic weight feature map, and MaxPool is the max-pooling, is the global spatio-temporal semantic feature map.
[0056] It should be noted that the working principle of the first convolution module and the second convolution module is similar to that of the third convolution module, and will not be repeated here.
[0057] The detection device of this embodiment performs convolution, normalization, attention mechanism, and max-pooling layer operations on the feature map obtained in advance through the convolution module in the detection model, improves the stability of the output feature map and enhances the dependency relationship between features, which helps to realize accurate prediction of ginsenoside content.
[0058] Please refer to Figure 4 , Figure 4A flowchart of a third embodiment of the method for detecting the ginsenoside content of American ginseng provided in the present application is shown in FIG. 3. The third embodiment differs from the first embodiment to the second embodiment in that the step of determining the ginsenoside content of the target American ginseng based on the global spatio-temporal semantic feature map using the detection model comprises: In step S301, the global spatio-temporal semantic feature map is input into the average pooling layer of the detection model to perform compression processing in the time dimension to obtain a target feature map.
[0059] In this embodiment, after obtaining the global spatio-temporal semantic feature map based on the detection model, the detection device inputs the global spatio-temporal semantic feature map into the average pooling layer of the detection model to perform compression processing in the time dimension to obtain a target feature map.
[0060] In an embodiment, the formula for calculating the target feature map is:
[0061] wherein z i is the target feature map, T represents the number of time steps of the spectral time series data or the spatial size of the feature map, h i (t) represents the feature value of the kth channel of the feature map at the tth time step or spatial position.
[0062] In step S302, the target feature map is input into the fully connected layer of the detection model to output the ginsenoside content of the target American ginseng.
[0063] In this embodiment, after obtaining the target feature map based on the detection model, the detection device inputs the target feature map into the fully connected layer of the detection model to output the ginsenoside content of the target American ginseng. Specifically, the fully connected layer performs nonlinear mapping on the target feature map, and finally outputs the predicted value through a fully connected layer of an output neuron.
[0064] In an embodiment, the formula for calculating the ginsenoside content of the target American ginseng is:
[0065] wherein y is the ginsenoside content of the target American ginseng; σ is a nonlinear activation function (such as ReLU, sigmoid, tanh, softmax, etc.) used to introduce nonlinearity to enable the model to have stronger expression ability; W f is the weight matrix of the fully connected layer, and b f is the bias term of the fully connected layer.
[0066] For example, Figure 3As shown, after the detection model obtains the global spatio-temporal semantic feature map, the detection model uses a global average pooling layer to compress the features in all time dimensions in the global spatio-temporal semantic feature map, realizes further unification of feature dimensions and significant reduction of parameters, and obtains a target feature map. Next, the target feature map is sent to a fully connected layer for nonlinear mapping, and finally an output neuron of the fully connected layer outputs a prediction value. The output value is a real number, which is used to represent the ginsenoside content of the target American ginseng.
[0067] The detection device of the present embodiment compresses the features in all time dimensions in the global spatio-temporal semantic feature map based on the global average pooling layer in the detection model to obtain a target feature map, and then outputs a prediction value based on the target feature map based on the fully connected layer, thereby improving the output efficiency of the model.
[0068] Reference is made to Figure 5 , Figure 5 The flowchart of the fourth embodiment of the ginsenoside content detection method of American ginseng provided in the present application is provided. The fourth embodiment is different from the first embodiment to the third embodiment in that the step of obtaining the spectral time series data of the column chromatography sample of American ginseng comprises: Step S401: Collecting reference spectral time series data of a column chromatography sample of target American ginseng.
[0069] In the present embodiment, the detection device is equipped with a near-infrared spectrometer and a high-performance liquid chromatograph. The near-infrared image of the column chromatography sample of target American ginseng is photographed by the spectrometer, and the near-infrared image is analyzed by the high-performance liquid chromatograph to obtain the reference spectral time series data of the column chromatography sample of target American ginseng.
[0070] Step S402: Preprocessing the reference spectral time series data to remove noise, baseline drift and light scattering in the reference spectral time series data.
[0071] In the present embodiment, the detection device preprocesses the collected reference spectral time series data to remove noise, baseline drift and light scattering in the reference spectral time series data. In an embodiment, the detection device uses a wavelet transform-based signal processing algorithm (WD), spectral baseline correction (SBC) and standard normalized scatter correction (SNV) method to remove noise, baseline drift and light scattering in the reference spectral data.
[0072] Step S403: Normalizing the preprocessed reference spectral time series data to obtain spectral time series data.
[0073] In the embodiment, the detection device normalizes the preprocessed reference spectral time series data to obtain spectral time series data. In an embodiment, the detection device normalizes the preprocessed reference spectral time series data by using a maximum-minimum normalization (MMN) operation to obtain spectral time series data, where the spectral time series data is a one-dimensional spectral vector, and the one-dimensional spectral vector is a time-ordered spectral sequence, and the sequence represents spectral data collected at different time points.
[0074] In the embodiment, the detection device preprocesses the collected reference spectral time series data to remove noise, baseline drift, and light scattering in the reference spectral time series data, and normalizes the preprocessed reference spectral time series data to obtain spectral time series data. This can reduce interference terms in the spectral time series data, which helps to accurately predict the content of ginsenosides.
[0075] Please refer to Figure 6 , Figure 6 The fifth embodiment of the method for detecting the content of ginsenosides in American ginseng provided in the present application is shown in the flowchart. The fifth embodiment is different from the first to fourth embodiments in that the method further comprises: In the embodiment, the detection device obtains spectral time series training sample data of column chromatography samples of sample American ginseng, and trains a target neural network based on the spectral time series training sample data to obtain a reference detection model. In the embodiment, the detection device obtains spectral time series training sample data of column chromatography samples of sample American ginseng before detecting the content of ginsenosides in American ginseng, and trains a target neural network based on the spectral time series training sample data to obtain a reference detection model. In an embodiment, the detection device uses the Kennard-Stone method to ensure that the spectral time series training sample data is uniformly distributed, and divides all batches of spectral time series training sample data into training samples, validation samples, and test samples in a ratio of 7:2:1. The training set is expanded by 10 times using an unsupervised spectral data enhancement method.
[0076] In the embodiment, the detection device obtains spectral time series training sample data of column chromatography samples of sample American ginseng, and trains a target neural network based on the spectral time series training sample data to obtain a reference detection model.
[0077] In the embodiment, in the process of each round of training, the detection device obtains spectral time series validation sample data of column chromatography samples of sample American ginseng and a preset loss function, and validates the reference detection model based on the spectral time series validation sample data and the loss function until the loss function value meets the first preset requirement, and obtains the detection model.
[0078] In an embodiment, the detection device uses Mean Squared Error (MSE) as a loss function during the model training process, and uses He initialization method to initialize the weight to accelerate the network convergence. The optimizer is selected as Adam, the batch size is set to 64, the learning rate is 0.001, and the number of training epochs is set to 500. By optimizing the hybrid loss function through back propagation, the performance of the model in the content prediction task can be effectively improved.
[0079] The mean square error loss function is:
[0080] Wherein, is the true value, is the predicted value, and N is the number of samples.
[0081] In an embodiment, the method further comprises: Step S503, obtaining spectral time sequence test sample data of the column chromatography sample of the sample American ginseng, and testing the detection model based on the spectral time sequence test sample data to obtain a test prediction result; In this embodiment, after obtaining the trained detection model, the detection device obtains spectral time sequence test sample data of the column chromatography sample of the sample American ginseng, and tests the detection model based on the spectral time sequence test sample data to obtain a test prediction result.
[0082] Step S504, calculating the correlation coefficient, root mean square error and residual prediction deviation between the test prediction result and the true ginsenoside content of the sample American ginseng; In this embodiment, the detection device calculates the correlation coefficient, root mean square error and residual prediction deviation between the test prediction result and the true ginsenoside content of the sample American ginseng.
[0083] The formula for calculating the correlation coefficient is:
[0084] The correlation coefficient R2 is used to measure the explanatory power of the model to the variation of the true data, and the closer the correlation coefficient is to 1, the better the model fitting is. i is the true ginsenoside content, is the test prediction result, is the mean value of the true ginsenoside content corresponding to the spectral time sequence test sample data, and n is the number of test samples. The formula for calculating the root mean square error is:
[0085] wherein, the RMSE measures the deviation between the predicted value and the true value, the unit is consistent with the target variable, and the smaller the value is, the smaller the prediction error is, y i is the true ginsenoside content, is the test prediction result, and n is the number of test samples. wherein, the formula for calculating the residual prediction deviation is:
[0086] wherein, the RPD is used to represent the robustness and generalization ability of the model, and the SD represents the standard deviation of the true ginsenoside content corresponding to the spectral time series test sample data. The larger the RPD is, the stronger the prediction ability of the model is. Generally: RPD<1.5 indicates that the prediction ability of the model is poor; 1.5≤RPD<2 indicates that the model can be used for rough prediction RPD≥2 indicates that the model has good prediction ability.
[0087] Step S505, if the correlation coefficient, the root mean square error or the residual prediction deviation does not meet the second preset requirement, the detection model is retrained until the correlation coefficient, the root mean square error or the residual prediction deviation meets the second preset requirement.
[0088] In this embodiment, after the detection device tests the detection model, if it is determined that the correlation coefficient, the root mean square error or the residual prediction deviation of the detection model does not meet the second preset requirement, the detection model is retrained until the correlation coefficient, the root mean square error or the residual prediction deviation of the detection model meets the second preset requirement, and the final detection model is obtained. Exemplarily, the second preset requirement is that the correlation coefficient is greater than 0.9, the root mean square error is less than 0.1, and the residual prediction deviation is greater than or equal to 2.
[0089] The detection device of this embodiment trains the detection model so that the detection model meets the requirement of the loss function, and tests the correlation coefficient, the root mean square error and the residual prediction deviation of the detection model. Only when the detection model meets the training requirement and the test requirement at the same time, can it be applied to the prediction of the ginsenoside content of American ginseng, which is conducive to realizing accurate prediction of the ginsenoside content.
[0090] Reference Figure 7 , Figure 7 is a structural schematic diagram of an American ginseng ginsenoside content detection device provided by the present application. The American ginseng ginsenoside content detection device comprises: The acquisition module 10 is configured to acquire spectral time series data of a column chromatography sample of a target American ginseng; The extraction module 20 is configured to input the spectral time series data into a preset detection model and extract a global spatiotemporal semantic feature map of the spectral time series data. A determination module 30 is configured to determine the ginsenoside content of the target American ginseng according to the global spatio-temporal semantic feature map by using the detection model.
[0091] It can be understood that the ginsenoside content detection device of American ginseng in the embodiment corresponds to the ginsenoside content detection method of American ginseng in the above-mentioned embodiment, and the optional items in the above-mentioned embodiment are also applicable to the present embodiment, and thus will not be described again here.
[0092] The present application also provides a computer device, which exemplarily comprises a processor and a memory, wherein the memory stores a computer program, and the processor executes the computer program to enable the computer device to perform the functions of the ginsenoside content detection method of American ginseng or each module in the ginsenoside content detection device of American ginseng.
[0093] The processor can be an integrated circuit chip with a signal processing capability. The processor can be a general-purpose processor, including a central processing unit (CPU), a graphics processing unit (GPU), and a network processor (NP), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or combinations thereof. The general-purpose processor can be a microprocessor, or the processor can also be any conventional processor, etc., which can implement or execute the disclosed methods, steps, and logic block diagrams in the embodiments of the present application.
[0094] The memory can be, but is not limited to, a random access memory (RAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), and the like. The memory is used to store a computer program, and the processor can execute the computer program after receiving an execution instruction.
[0095] The application further provides a computer storage medium for storing the computer program used in the computer device.
[0096] In several embodiments provided in the application, it should be understood that the disclosed apparatus and method can also be implemented by other manners. The apparatus embodiments described above are only illustrative, for example, the flowcharts and structural diagrams in the drawings show the possible implementation architecture, function and operation of the apparatus, method and computer program product according to the embodiments of the application. In this regard, each block in the flowchart or block diagram can represent a module, a program segment or a part of code, which contains one or more executable instructions for implementing the specified logic function. It should also be noted that in the alternative implementation, the functions annotated in the block can also occur in the order different from that annotated in the drawings. For example, two consecutive blocks can actually be executed substantially in parallel, and sometimes they can be executed in reverse order, depending on the functions involved. It should also be noted that each block in the structural diagram and / or flowchart, and the combination of blocks in the structural diagram and / or flowchart, can be implemented by a dedicated hardware-based system for executing the specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.
[0097] In addition, each functional module or unit in the embodiments of the application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0098] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a readable storage medium. Based on this understanding, the technical solutions of the application can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for causing a computer device (which can be a smart phone, a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the embodiments of the application.
[0099] The above merely provides the specific implementation of the present application, but the protection scope of the present application is not limited to this. Any person skilled in the art can easily think of the changes or replacements within the technical range disclosed by the present application, which should be covered in the protection scope of the present application.
Claims
1. A method for detecting ginsenoside content in American ginseng, characterized in that: The method comprises: Acquire spectral time series data of a column chromatography sample of target American ginseng; Inputting the spectral time series data into a preset detection model to extract a global spatiotemporal semantic feature map of the spectral time series data; The detection model is used to determine the ginsenoside content of the target American ginseng according to the global spatiotemporal semantic feature map.
2. The method for detecting ginsenoside content in American ginseng according to claim 1, wherein The step of inputting the spectral time series data into a preset detection model and extracting global spatiotemporal semantic features from the spectral time series data includes: Inputting the spectral time series data into a first convolution module in a preset detection model to extract a local spectral change characteristic graph of the spectral time series data; Inputting the local spectral change feature map into the second convolution module in the detection model to extract the local spatiotemporal semantic feature map of the spectral time series data; The local spatiotemporal semantic feature map is input into the third convolution module in the detection model to extract the global spatiotemporal semantic feature map of the spectral time series data.
3. The method for detecting ginsenoside content in American ginseng according to claim 2, wherein: The step of inputting the local spatiotemporal semantic feature map into the third convolution module in the detection model to extract the global spatiotemporal semantic feature map of the spectral time series data includes: Inputting the local spatiotemporal semantic feature map into the convolution layer and normalization layer of the third convolution module in the detection model, and outputting a normalized local spatiotemporal semantic feature map; Extracting a query matrix, a key matrix, and a value matrix of the normalized local spatiotemporal semantic feature map based on the attention mechanism module in the third convolution module, and determining a local spatiotemporal semantic weight feature map based on the query matrix, the key matrix, and the value matrix; The local spatiotemporal semantic weight feature map is input into the maximum pooling layer of the third convolution module, and the global spatiotemporal semantic feature map of the spectral time series data is output.
4. The method for detecting ginsenoside content in American ginseng according to claim 1, wherein: The step of determining the ginsenoside content of the target American ginseng by using the detection model according to the global spatiotemporal semantic feature map comprises: Inputting the global spatiotemporal semantic feature map into the average pooling layer of the detection model, performing time dimension compression processing on the global spatiotemporal semantic feature map to obtain a target feature map; The target feature map is input into the fully connected layer of the detection model, and the ginsenoside content of the target American ginseng is output.
5. The method for detecting ginsenoside content of American ginseng according to any one of claims 1 to 4, characterized in that: The step of obtaining spectral time series data of the column chromatography sample of American ginseng includes: Collecting reference spectral time series data of the column chromatography sample of target American ginseng; Preprocessing the reference spectrum time series data to remove noise, baseline drift and light scattering in the reference spectrum time series data; The pre-processed reference spectrum time series data is normalized to obtain spectrum time series data.
6. The method for detecting ginsenoside content of American ginseng according to any one of claims 1 to 4, characterized in that: The method further comprises: Obtaining spectral time series training sample data of a column chromatography sample of American ginseng, and training a target neural network based on the spectral time series training sample data to obtain a reference detection model; Obtain spectral time series verification sample data and a preset loss function of the column chromatography sample of American ginseng, and verify the reference detection model based on the spectral time series verification sample data and the loss function until the loss function value meets the first preset requirement, thereby obtaining the detection model.
7. The method for detecting ginsenoside content in American ginseng according to claim 6, wherein: The method further comprises: Acquire spectral time series test sample data of a column chromatography sample of American ginseng, and test the detection model based on the spectral time series test sample data to obtain a test prediction result; Calculating the correlation coefficient, root mean square error, and residual prediction deviation between the test prediction result and the actual ginsenoside content of the American ginseng sample; If the correlation coefficient, the root mean square error or the residual prediction deviation does not meet the second preset requirement, the detection model is retrained until the correlation coefficient, the root mean square error or the residual prediction deviation all meet the second preset requirement.
8. A device for detecting ginsenoside content in American ginseng, characterized in that: The ginsenoside content detection device of American ginseng comprises: An acquisition module, used for acquiring spectral time series data of a column chromatography sample of a target American ginseng; An extraction module, configured to input the spectral time series data into a preset detection model and extract a global spatiotemporal semantic feature map of the spectral time series data; A determination module is used to determine the ginsenoside content of the target American ginseng according to the global spatiotemporal semantic feature map through the detection model.
9. A computer device, characterized in that: The computer device includes a processor and a memory, the memory stores a computer program, and the processor is configured to execute the computer program to implement the method for detecting the ginsenoside content of American ginseng according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is run on a processor, the method for detecting the ginsenoside content of American ginseng according to any one of claims 1 to 7 is executed.