Fritillaria powder layering adulteration detection method based on hyperspectral imaging
By using hyperspectral imaging technology and the DLSM-CNN model, adaptive feature band screening and qualitative and quantitative collaborative detection of adulteration in fritillaria powder were achieved. This solved the problems of unstable feature band selection and uninterpretable deep learning models in the detection of adulteration in fritillaria powder, and achieved efficient and reliable adulteration detection.
Patent Information
- Application Number
- CN202610034057.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-12
- Publication Date
- 2026-05-05
AI Technical Summary
Existing technologies for detecting adulteration in fritillaria powder suffer from a lack of adaptability and chemical robustness in characteristic band selection, susceptibility to environmental noise interference, a disconnect between qualitative and quantitative analysis, and a lack of interpretability in deep learning models, making it difficult to meet the traceability requirements of food and drug regulation.
A layered adulteration detection method for fritillaria powder based on hyperspectral imaging is adopted. Through sample preparation and hyperspectral data acquisition, spectral data preprocessing and DLSM-CNN model construction, combined with a learnable spectral mask module, a layered one-dimensional convolutional backbone network and a dual-task prediction head, end-to-end adaptive feature band screening and qualitative and quantitative collaborative detection are achieved.
It enables large-scale, rapid, and non-destructive stratified adulteration detection of fritillaria powder, improves the interpretability and accuracy of test results, meets the traceability requirements of food and drug supervision, achieves a classification accuracy of 100%, a quantitative regression accuracy of 0.9038, and a root mean square error as low as 0.0913.
Smart Images

Figure CN121978055A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of adulteration detection methods, and in particular to a layered adulteration detection method for fritillaria powder based on hyperspectral imaging. Background Technology
[0002] Fritillaria is an important traditional Chinese medicine with antitussive, expectorant, anti-inflammatory, and analgesic effects. Sichuan Fritillaria, in particular, is highly effective and commands a significantly higher market price than other varieties, leading to frequent adulteration and counterfeiting in the market. Common adulteration methods include mixing in foreign substances such as organic starch and inorganic talc, or using closely related species of the same genus, such as Fritillaria thunbergii and Fritillaria cirrhosa, which have highly similar chemical compositions. Since Fritillaria is often circulated in powder form, the visual characteristics of adulterated products are similar, making conventional morphological identification ineffective. Traditional physicochemical identification methods (such as microscopic examination and chromatographic mass spectrometry) are accurate, but they are destructive, time-consuming, and labor-intensive, failing to meet the needs of large-scale, rapid, and non-destructive on-site testing.
[0003] To address this issue, non-contact non-destructive testing techniques based on hyperspectral imaging (HSI) have become a research hotspot. Existing techniques often combine chemometric methods (such as partial least squares (PLS) and support vector machines (SVM)) or conventional deep learning models (such as one-dimensional convolutional neural networks (1D-CNN) and long short-term memory networks (LSTM), and select feature wavelengths through competitive adaptive reweighted sampling (CARS) and continuous projection algorithm (SPA).
[0004] However, existing technologies have significant drawbacks: First, the feature band selection method lacks adaptability and chemical robustness, is easily affected by environmental noise, and tends to select moisture-related bands rather than the chemical fingerprint bands of the substance's essence, causing the model to fail when the environmental humidity or sample water content changes; second, conventional deep learning models have a "black box" problem, and the detection results lack interpretability, making it difficult to meet the traceability requirements of food and drug supervision; third, the qualitative identification and quantitative analysis are modeled separately, ignoring the inherent relationship between the two, resulting in insufficient detection accuracy in complex-level adulteration scenarios and making it impossible to build a unified comprehensive detection model. Summary of the Invention
[0005] To address the technical problems mentioned in the background section, this invention provides a method for detecting adulteration in fritillaria powder based on hyperspectral imaging.
[0006] The technical solution adopted in this invention is: a method for detecting adulteration in fritillaria powder based on hyperspectral imaging, specifically including the following steps: Step 1, Sample preparation and hyperspectral data acquisition, specifically includes sample preparation, hyperspectral image acquisition, black and white plate calibration, and spectral extraction; Step 2, spectral data preprocessing, specifically includes noise suppression, baseline correction, and feature enhancement; Step 3, DLSM-CNN model construction and training: Construct a dual-task learnable spectral mask convolutional neural network. This network is an end-to-end deep learning framework, consisting of three cascaded functional modules, and uses a joint loss function to optimize model training. Step 4, Model Inference and Evaluation, specifically includes dataset partitioning, comparative experiment setup, and evaluation metric setting.
[0007] In one embodiment, step 1 is specifically as follows: Sample preparation: Prepare genuine Fritillaria cirrhosa powder and common adulterants, including foreign matter adulteration and adulteration with closely related species of the same genus; All samples were crushed and sieved, and mixed powder samples were prepared according to the mass ratio of 0% pure product to 100% pure adulterant. Hyperspectral Image Acquisition: Raw hyperspectral images of powder samples were acquired using a near-infrared hyperspectral imaging system. ; Blackboard correction: Reflectance correction of the original image. ; in, The corrected spectral reflectance image, after eliminating interference, can truly reflect the spectral characteristics of the sample; The raw hyperspectral image acquired by the hyperspectral camera contains the spectral information of the sample but is affected by dark current and uneven illumination. The dark current reference image acquired with the lens cap closed represents 0% reflectivity and is used to subtract the device's own dark current noise. Reference image of the whiteboard taken from a standard polytetrafluoroethylene whiteboard; Spectral extraction: Randomly select a region of interest from the center of the corrected image, calculate the average spectrum of all pixels in that region, and use it as the representative spectral data of the sample.
[0008] In one embodiment, step 2 is specifically as follows: Noise suppression processing: Input the corrected original spectral data into a Gaussian filter and set the standard deviation parameter. Smooth the spectral curve; Baseline correction and feature enhancement: The smoothed spectral data is used as input, and Savitzky-Golay first derivative transformation is performed. The filter window size is set to 15, and the polynomial fitting order is 3.
[0009] In one embodiment, step 3 is specifically as follows: A dual-task learnable spectral mask convolutional neural network is constructed. This network is an end-to-end deep learning framework consisting of three cascaded functional modules. A joint loss function is used to optimize model training, as follows: Module A: Learnable spectral mask module, which achieves automatic feature band selection through a "soft gating" mechanism. The specific calculation logic is as follows: First, define a learnable weight vector with the same dimension as the input spectrum. ; Input spectrum Upon entering this layer, a mask is generated using the Sigmoid activation function. The formula is: ; in, This represents the Sigmoid activation function, whose function is to activate the weight vector. The value of is constrained to the interval (0,1), so that the mask... The element values are between 0 and 1; Then, element-wise multiplication is performed to obtain the weighted spectrum. The formula is: ; in, To input spectral data, The mask generated for the Sigmoid function. This indicates element-wise multiplication. The core function of this module is to automatically reduce the mask weights corresponding to background noise bands with no information to 0 during network training, while increasing the weights of bands containing key chemical fingerprints to 1, thereby achieving end-to-end adaptive feature band selection. Module B: Weighted spectrum of a hierarchical one-dimensional convolutional backbone network The backbone network is used to extract features. The network contains three stacked convolutional blocks with a pyramidal kernel design. Each convolutional block consists of a convolutional layer, a batch normalization layer, a ReLU activation layer, and a max pooling layer. Convolutional layers: These layers perform convolution operations on spectral data using kernels of different sizes to capture local texture features at different scales. Batch normalization layer: Normalizes the output of the convolutional layer to accelerate model training convergence; ReLU activation layer: Introduces nonlinear transformation; Max pooling layer: Downsamples convolutional features, retaining key features while reducing data dimensionality and computational cost; Module C: The deep features extracted by the dual-task prediction head backbone network are flattened and then distributed to two independent task heads to achieve coordinated qualitative and quantitative detection. Classification Head: Used for qualitative identification. It maps deep features through a fully connected layer and uses the Softmax function to output the probability that the sample belongs to "genuine", "foreign substance adulteration" or "closely related species adulteration", thus completing the adulteration type judgment. Regression head: Used for quantitative analysis, it maps deep features through a fully connected layer and uses the Sigmoid function to output the adulteration ratio, thus achieving accurate calculation of adulteration content.
[0010] Model Training and Optimization: A joint loss function is designed to achieve collaborative optimization of the two tasks and sparsity constraints in feature selection. The loss function formula is as follows: ; in, Cross-entropy loss is used to optimize classification tasks, minimize the difference between the classification prediction result and the true label, and improve the accuracy of qualitative identification. : Smoothing L1 loss is used to optimize regression tasks, reduce the error between quantitative predictions and the actual adulteration ratio, and improve the accuracy of quantitative analysis; Regularization coefficient, used to balance the weights of the regularization term and other loss terms; LSM weight vector The L1 regularization term forces... It became sparse.
[0011] In one embodiment, step 4 is specifically as follows: Dataset partitioning: Multiple independent spectral samples were collected for the experiment, including datasets adulterated with foreign substances and datasets adulterated with closely related species; all samples were randomly partitioned into training and testing sets in an 8:2 ratio. Comparative experimental setup: The DLSM-CNN model is compared with traditional partial least squares, support vector regression, standard one-dimensional convolutional neural network without LSM module, bidirectional long short-term memory network, and random forest.
[0012] Evaluation metrics: Classification accuracy is used to evaluate qualitative discrimination performance, and coefficient of determination and root mean square error are used to evaluate quantitative analysis performance.
[0013] The beneficial effects of this invention are as follows: Compared with existing technologies, this invention provides sample preparation that closely matches real-world market adulteration scenarios. Hyperspectral acquisition combined with black-and-white plate correction and spectral extraction yields high-quality, interference-free raw data. Preprocessing steps including noise suppression, baseline correction, and feature enhancement eliminate interference from equipment noise and light scattering, highlighting the essential spectral differences of the samples and overcoming the identification difficulties caused by poor data quality in traditional detection methods. The learnable spectral mask module of the DLSM-CNN model enables adaptive feature selection, avoiding the susceptibility of traditional feature selection methods to environmental interference. The dual-task architecture integrates qualitative and quantitative analysis, solving the drawbacks of separate modeling. The joint loss function ensures model performance and sparsity, breaking the "black box" dilemma of deep learning and improving the interpretability of results. The scientific design of the model inference and evaluation stages ensures the reliability and superiority of the detection results, meeting the traceability requirements of food and drug supervision. The overall process achieves large-scale, rapid, and non-destructive layered adulteration detection of fritillaria powder. Attached Figure Description
[0014] Figure 1 This is a flowchart of the system workflow proposed in this invention; Figure 2 This is a spectral characteristic diagram of the experimental sample in this invention; Figure 3 This is a scatter plot showing the predicted adulteration rate and the actual adulteration rate on the test set using different models in this invention: Figure 4 This is a comprehensive performance evaluation diagram of the framework and baseline model developed in this invention; Figure 5 This is a visualization of the learnable spectral mask (LSM) mechanism in this invention; Figure 6 In this invention, the saliency map visualizes the species-specific spectral map learned by the LSM module. Detailed Implementation
[0015] In the description of this invention, it should be noted that the terms "front", "up", "down", "left", "right", "vertical", "horizontal", etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this invention.
[0016] To address the problems existing in the background technology, this application proposes the following technical solution: a method for detecting adulteration of fritillaria powder based on hyperspectral imaging, specifically including the following steps: Step 1: Sample preparation and hyperspectral data acquisition; Sample preparation: Prepare genuine Fritillaria cirrhosa powder and common adulterants, including foreign matter adulteration (starch, talc) and adulteration with closely related species (F. ussuriensis, F. pallidiflora, F. thunbergii, etc.). All samples were crushed and sieved, and mixed powder samples were prepared in a mass ratio of 0% (pure genuine product) to 100% (pure adulterant) to simulate the adulteration situation in the real market.
[0017] Hyperspectral Image Acquisition: Raw hyperspectral images of powder samples were acquired using a near-infrared hyperspectral imaging system (wavelength range 900-1700 nm). .
[0018] Black and white board correction: To eliminate interference from dark current and uneven illumination in the equipment, the reflectance of the original image is corrected using the following formula: ; in, The corrected spectral reflectance image, after eliminating interference, can truly reflect the spectral characteristics of the sample; The raw hyperspectral image acquired by the hyperspectral camera contains the spectral information of the sample but is affected by dark current and uneven illumination. The dark current reference image acquired with the lens cap closed represents 0% reflectivity and is used to subtract the device's own dark current noise. Reference image of the whiteboard taken from a standard polytetrafluoroethylene (Teflon) whiteboard, representing 99% reflectivity, used to calibrate differences in light intensity.
[0019] Spectral extraction: A region of interest (ROI) is randomly selected from the center of the corrected image, and the average spectrum of all pixels in the region is calculated. This average spectrum is used as the representative spectral data of the sample to ensure that the spectral data can reflect the overall characteristics of the sample.
[0020] In the above technical solution: First, the sample preparation process closely reflects actual market conditions, covering common types of adulteration, including foreign matter and closely related species. Mixed samples are configured in complete proportions to ensure that the data used for model training comprehensively covers all possible adulteration scenarios. This avoids missed or incorrect detections due to a single sample type or incomplete proportions, laying a solid foundation for the model's generalization ability. Second, hyperspectral imaging technology is used for data acquisition. The entire process is non-contact, requiring no sample damage or complex processing, perfectly preserving sample integrity. This solves the problem of sample consumption and non-reusability in traditional physicochemical testing, making it particularly suitable for the testing of precious Chinese medicinal materials. Third, the black-and-white plate calibration process effectively eliminates interference from the device's own dark current and uneven external lighting, allowing the acquired spectral data to truly reflect the chemical characteristics of the sample. This avoids spectral distortion caused by equipment and environmental factors, providing high-quality, highly reliable raw data support for subsequent preprocessing and model construction. Meanwhile, by selecting the region of interest in the center of the image and calculating the average spectrum, interference information that may exist at the image edges is eliminated, and the overall spectral characteristics of the sample are comprehensively reflected. This ensures that the spectral data of a single sample are representative and reduces the impact of local differences on the detection results.
[0021] Step 2, Spectral data preprocessing: Noise suppression processing: Input the corrected original spectral data into a Gaussian filter and set the standard deviation parameter. The spectral curve is smoothed. This step removes high-frequency random noise generated by the sensor while preserving the main waveform features of the spectrum, laying the foundation for subsequent feature extraction.
[0022] Baseline correction and feature enhancement: The smoothed spectral data is used as input, and Savitzky-Golay first derivative transformation is performed. The filter window size is set to 15, and the polynomial order is set to 3.
[0023] Its functions are: first, to effectively eliminate light scattering effects and baseline drift caused by uneven particle size in the sample; second, to separate overlapping absorption peaks, enhance the resolution of spectral characteristic peaks, and make the differences between different samples (genuine, foreign adulterated, and closely related adulterated) in characteristic bands (such as around 1378nm and 1400nm) more significant, thus providing clear physical characteristics for model learning.
[0024] In the above technical solution: First, Gaussian smoothing specifically removes high-frequency random noise generated by the sensor, strictly preserving the main waveform features of the spectrum during the noise reduction process. This avoids noise interference with subsequent feature extraction and model learning, making the core information of the spectral data more prominent. In actual detection, sensor noise is often a significant factor affecting detection accuracy. This processing effectively improves the purity of the spectral data, providing a clearer analytical foundation for subsequent steps. Second, the Savitzky-Golay first-order derivative transformation successfully solves the light scattering effect and baseline drift problem caused by uneven sample particle size. These two types of problems are common interference factors in the spectral detection of powder samples, easily leading to false shifts in the spectral curves of different samples and affecting the accuracy of feature comparison. At the same time, this transformation can also effectively separate overlapping absorption peaks, enhance the resolution of spectral feature peaks, and make the differences between genuine products and various adulterated samples more obvious in key feature bands. Especially for adulterated types with highly similar spectral features, such as closely related species, the enhanced spectrum can provide the model with more discriminative distinguishing criteria, significantly reducing the difficulty of model learning. Furthermore, the entire preprocessing process requires no manual intervention to adjust key parameters, has a high degree of standardization, avoids inconsistencies in processing results caused by human factors, ensures that the spectral data of different batches and samples have a unified quality standard after preprocessing, and improves the stability and reliability of subsequent model training and detection results.
[0025] Step 3, DLSM-CNN model construction and training; We construct a dual-task learnable spectral mask convolutional neural network (DLSM-CNN), which is an end-to-end deep learning framework consisting of three cascaded functional modules, and uses a joint loss function to optimize model training.
[0026] Module A: Learnable Spectral Mask (LSM) Module. This module is the core innovation, achieving automatic feature band selection through a "soft gating" mechanism. The specific calculation logic is as follows: First, define a learnable weight vector with the same dimension as the input spectrum. ; Input spectrum Upon entering this layer, a mask is generated using the Sigmoid activation function. The formula is: ; in, This represents the Sigmoid activation function, whose function is to activate the weight vector. The value of is constrained to the interval (0,1), so that the mask... The element values are between 0 and 1; - then an element-wise multiplication (Hadamard Product) operation is performed to obtain the weighted spectrum. The formula is: ; in, To input spectral data, The mask generated for the Sigmoid function. This indicates element-wise multiplication. The core function of this module is that during network training, the mask weights corresponding to background noise bands with no information are automatically reduced to 0, while the weights of bands containing key chemical fingerprints (such as CH bonds and OH bonds) are increased to 1, achieving end-to-end adaptive feature band selection and avoiding the limitations of traditional manual feature selection.
[0027] Module B: Weighted spectrum of a hierarchical one-dimensional convolutional backbone network (1D-CNNBackbone) The backbone network is used to extract features. The network contains three stacked convolutional blocks with a pyramidal kernel design (kernel sizes of 7, 5, and 3 respectively). Each convolutional block consists of a convolutional layer, a batch normalization (BN) layer, a ReLU activation layer, and a max-pooling layer. Convolutional layers: These layers perform convolution operations on spectral data using kernels of different sizes to capture local texture features at different scales. Batch Normalization (BN): Normalizes the output of convolutional layers, accelerating model training convergence and improving model stability; ReLU activation layer: Introduces nonlinear transformation to enhance the model's ability to fit complex features; Max pooling layer: Downsamples convolutional features, preserving key features while reducing data dimensionality and computational cost. The purpose of this design is to comprehensively capture local texture and global morphological features of the spectrum at different scales, providing high-quality deep features for subsequent dual-task prediction.
[0028] Module C: The deep features extracted by the dual-task prediction head backbone network are flattened and then distributed to two independent task heads to achieve coordinated qualitative and quantitative detection. Classification Head: Used for qualitative identification. It maps deep features through a fully connected layer and uses the Softmax function to output the probability that the sample belongs to "genuine product", "adulterated by foreign matter (starch / talc)" or "adulterated by closely related species (Pteris vittata / Ipomoea quamoclit, etc.)", thus completing the adulteration type judgment; Regression head: Used for quantitative analysis, it maps deep features through a fully connected layer and uses the Sigmoid function to output the adulteration ratio (within the range of 0 to 1), thus achieving accurate calculation of adulteration content.
[0029] Model Training and Optimization: A joint loss function is designed to achieve collaborative optimization of the two tasks and sparsity constraints in feature selection. The loss function formula is as follows: ; in, Cross-entropy loss is used to optimize classification tasks, minimize the difference between the classification prediction result and the true label, and improve the accuracy of qualitative identification. Smooth L1 Loss is used to optimize regression tasks, reduce the error between quantitative predictions and the actual adulteration ratio, and improve the accuracy of quantitative analysis. Regularization coefficient, used to balance the weights of the regularization term and other loss terms; LSM weight vector The L1 regularization term forces... The sparser structure allows the model to automatically select the few most critical chemical feature bands, further improving the model's robustness and interpretability.
[0030] In the above technical solution: First, the learnable spectral mask module completely changes the traditional manual selection of feature bands. It generates a mask through adaptive learning of weight vectors, automatically focusing on bands containing key chemical fingerprints while suppressing background noise bands lacking information. This fundamentally solves the shortcomings of traditional feature selection methods, which rely on fixed criteria and are susceptible to environmental interference. This adaptive feature selection method can accurately capture the essential chemical characteristics of substances, unaffected by external factors such as environmental humidity and sample water content, allowing the model to maintain stable detection performance in different application scenarios. Second, the hierarchical one-dimensional convolutional backbone network adopts a pyramid-shaped convolutional kernel design, which can comprehensively capture the local texture and global morphological features of the spectrum at different scales. Compared with single-scale feature extraction, this design can better mine the deep information in spectral data. Whether it is the significant features of foreign adulteration or the subtle features of closely related species adulteration, both can be effectively captured, improving the model's ability to analyze complex spectral information. Furthermore, the innovative dual-task prediction head architecture achieves collaborative qualitative identification and quantitative analysis. By sharing a feature extraction layer, the semantic features of the classification task can assist the quantitative prediction of the regression task, solving the problem of separate modeling of the two tasks and ignoring the inherent correlation in traditional techniques. It is particularly suitable for complex hierarchical adulteration scenarios, significantly improving detection efficiency and obtaining the adulteration type and proportion results simultaneously without performing two separate detections. Finally, the joint loss function combines classification loss, regression loss, and sparse regularization terms, ensuring collaborative optimization of the two tasks and achieving sparse selection of feature bands through regularization constraints. This makes the model decisions more targeted and also provides support for subsequent model interpretability analysis, avoiding the "black box" defect of traditional deep learning models.
[0031] Step 4, Model Reasoning and Evaluation; Dataset partitioning: A total of 1320 independent spectral samples were collected in the experiment, including the foreign matter adulteration dataset (Dataset1, 840 samples, including genuine Fritillaria cirrhosa and samples mixed with different proportions of starch and talc) and the closely related species adulteration dataset (Dataset11, 480 samples, including genuine Fritillaria cirrhosa and samples mixed with Fritillaria thunbergii, Fritillaria yicheni, Fritillaria thunbergii, Fritillaria thunbergii, Fritillaria cirrhosa, Fritillaria thunbergii, etc.). All samples were randomly divided into a training set (8096, used for model parameter learning) and a test set (20%, used only for final performance evaluation to ensure the objectivity of the results) in an 8:2 ratio.
[0032] Comparative experimental setup: The DLSM-CNN model is compared with traditional partial least squares (PLS), support vector regression (SVR), standard one-dimensional convolutional neural network without LSM module (1D-CNN), bidirectional long short-term memory network (Bi-LSTM), and random forest (RF).
[0033] Evaluation metrics: Qualitative identification performance was assessed using classification accuracy, while quantitative analysis performance was assessed using the coefficient of determination (R²) and root mean square error (RMSE). Experimental results showed that the DLSM-CNN model achieved 100% classification accuracy in detecting foreign adulteration and over 99% accuracy in identifying closely related species. The quantitative regression achieved a coefficient of determination (R²) of 0.9038 and a low root mean square error (RMSE) of 0.0913, significantly outperforming other comparative models.
[0034] In the above technical solution: First, the training and test sets are randomly divided in a reasonable proportion, ensuring the independence and representativeness of the test set and avoiding misjudgments of model performance due to improper data partitioning. This allows the final evaluation results to truly reflect the model's performance in practical applications, providing objective and reliable performance evidence for the technology's practical application. Second, the comparative experiments cover traditional chemometric methods and other deep learning models. Through comprehensive performance comparisons, the superiority of the proposed model in qualitative identification accuracy and quantitative analysis precision is clearly highlighted, allowing users to intuitively understand the core advantages of this technical solution compared to existing technologies, enhancing the persuasiveness of technology promotion. Third, multi-dimensional evaluation indicators are adopted, covering both the classification accuracy of qualitative identification and the coefficient of determination and root mean square error of quantitative analysis. This allows for a comprehensive and detailed evaluation of the model's performance on different tasks, avoiding the one-sidedness of single-indicator evaluation and ensuring that the model meets the actual detection needs in both qualitative and quantitative dimensions. Furthermore, experimental verification not only demonstrated the model's high performance but also validated the interpretability of the model's decisions through mechanistic analysis. This ensures that the detection results are not only accurate and reliable but also provide clear scientific evidence, meeting the stringent requirements for traceability and accountability in the food and drug regulatory field. This paves the way for the widespread application of this technology in various scenarios such as actual supervision, market screening, and enterprise quality control.
[0035] In summary, this invention, through a learnable spectral mask (LSM) module, utilizes end-to-end backpropagation to automatically learn band weights, combined with L1 sparse regularization. This effectively overcomes the shortcomings of traditional feature selection methods, such as reliance on fixed statistical criteria and susceptibility to environmental interference like moisture. It accurately identifies feature bands related to the chemical nature of substances (e.g., CH bonding frequencies and overtone absorptions corresponding to the carbohydrate skeleton), improving the model's generalization ability and robustness across different batches and environments. The visualized band importance map from the LSM module clearly demonstrates that the model makes decisions based on specific chemical fingerprints (e.g., identifying organics through CH features at 1378nm, and distinguishing closely related species through subtle differences in OH at 1400nm), solving the "black box" problem of conventional deep learning models and improving the interpretability of detection results. The system provides a reliable scientific basis for identifying the authenticity of Chinese medicinal materials, meeting the traceability requirements of food and drug supervision. Through a dual-task collaborative architecture, the classification and regression tasks share feature extraction layers and mutually constrain each other, successfully solving the problem of separating qualitative and quantitative processing in existing technologies. In complex adulteration scenarios (with both foreign matter adulteration and confusion with closely related species), it achieves simultaneous identification of adulteration types and calculation of adulteration ratios in a single scan, significantly improving detection efficiency and accuracy. The accuracy rate for foreign matter adulteration classification reaches 100%, the accuracy rate for closely related species identification exceeds 99%, the coefficient of determination for quantitative regression reaches 0.9038, and the root mean square error is as low as 0.0913. All indicators are superior to traditional partial least squares, support vector machines, and single-task deep learning models, meeting the needs of large-scale, rapid, and non-destructive on-site detection.
[0036] Analysis based on the attached diagram: Figure 1 This is a flowchart of the system workflow proposed in this invention; the framework begins with the following steps: (Step 1) acquiring data from pure and doped samples; (Step 2) preprocessing using Gaussian smoothing and differentiation; (Step 3) constructing the proposed DLSM-CNN model, which combines a learnable spectral mask with a multi-task network for simultaneous qualitative and quantitative analysis; and finally, (Step 4) evaluating its performance to verify its capabilities and compare it with conventional methods (SPA / CARS), and interpreting the learned chemical characteristics.
[0037] Figure 2 These are the spectral characteristics of the experimental samples in this invention; (A) the original spectral reflectance curves of pure fritillaria powder, fritillaria powder mixed with starch powder and fritillaria powder mixed with talc powder; (B) the preprocessed spectra after applying Gaussian smoothing (GS) and Savitzky-Golay first derivative (1-Der).
[0038] Figure 3The following are scatter plots showing the predicted and actual adulteration rates on the test set using different models in this invention: (A) the DLSM-CNN model proposed in this paper, (B) the Bidirectional Long Short-Term Memory (Bi-LSTM) model, (C) the One-Dimensional Convolutional Neural Network (1D-CNN) model, (D) the Partial Least Squares (PLS) model, (E) the Random Forest (RF) model, and (F) the Support Vector Regression (SVR) model; the edge histograms on the x-axis and y-axis represent the frequency distribution of the true and predicted values, respectively, demonstrating the coverage of the dataset.
[0039] Figure 4 This is a comprehensive performance evaluation diagram of the framework and baseline model developed in this invention; (A) R-values of six different methods in quantitative regression tasks. 2 (B) The confusion matrix obtained by the proposed DLSM-CNN model in qualitative classification tasks (pure product, starch adulterant and talc adulterant) compared with the RMSE value.
[0040] Figure 5 This is a visualization of the Learnable Spectral Mask (LSM) mechanism in this invention; (A) a heatmap showing the evolution of attention weights during training, illustrating the convergence process from random initialization to stable feature selection. (B) the final learned importance weights superimposed on the average spectrum. In addition to the main feature clusters in the 1360–1380 nm range (see Table 1), the visualization also shows that the model focuses on the second harmonic region of CH stretching vibrations near 1147 nm. The consistency of these key regions—all related to the organic carbohydrate skeleton—confirms that the model relies on stable chemical structure information, rather than the water-related band (960 nm) typically chosen by traditional methods.
[0041] Figure 6 The saliency plot in this invention visualizes the species-specific spectra learned by the LSM module. This model autonomously identifies different functional groups in each dopant, demonstrating differentiated chemical specificity: (A) CC (Changchun Fritillaria) is identified by the second harmonic of the OH stretching vibration (~957nm), indicating unique water or hydroxyl characteristics; (B) PB (Pingbei) is also distinguished by OH characteristics, but located in the first harmonic region (~1400nm); (C) YB (Yibei) is characterized by NH characteristics (~1048nm), indicating differences in protein or amino acid content; (D) ZB (Zhebei) is distinguished by subtle changes in the CH skeleton vibration (~1176nm).
[0042] Among them, the appendix Figure 1This paper clearly presents the complete system workflow for the layered adulteration detection of fritillaria powder based on hyperspectral imaging. Starting with data acquisition from pure and adulterated samples, followed by Gaussian smoothing and differential preprocessing, the paper then constructs a DLSM-CNN model integrating a learnable spectral mask and a multi-task network for simultaneous qualitative and quantitative analysis. Finally, performance verification is achieved through comparison with traditional methods and interpretation of chemical characteristics. Each step is interconnected, intuitively demonstrating the completeness and logic of the technical solution. (Appendix) Figure 2 Comparing the original spectral reflectance curves of the experimental samples with the preprocessed spectra, it is evident that after Gaussian smoothing and Savitzky-Golay first derivative processing, the spectral characteristic peaks of pure fritillaria powder, starch-added powder, and talc-added powder are more pronounced. Differences that might have previously overlapped or been unclear are effectively amplified, providing a clearer distinguishing basis for subsequent model learning. (Appendix) Figure 3 By comparing scatter plots of the predicted and actual adulteration rates on the test set using different models, the advantages of the proposed DLSM-CNN model in quantitative prediction are intuitively reflected. Its predictions closely match the true proportions to far exceed those of baseline models such as bidirectional long short-term memory networks, one-dimensional convolutional neural networks, partial least squares, random forests, and support vector regression, demonstrating the model's accuracy in quantitative analysis tasks. (Appendix) Figure 4 The performance of each model was comprehensively evaluated from two dimensions: the coefficient of determination for quantitative regression, the root mean square error, and the confusion matrix for qualitative classification. This clearly highlights the combined advantages of the DLSM-CNN model in both qualitative identification and quantitative analysis tasks, especially its extremely high accuracy in classifying pure products, starch adulterants, and talc adulterants. (Appendix) Figure 5 The learnable spectral masking mechanism was visualized. A heatmap showing the evolution of attention weights during training illustrates the convergence process from random initialization to stable feature selection. The learned importance weights are ultimately superimposed on the average spectrum, clearly identifying the key feature bands the model focuses on. These bands are mostly related to the organic carbohydrate skeleton, confirming that the model relies on stable chemical structure information rather than water-related bands, providing direct evidence for the model's chemical interpretability. Figure 6 The saliency plot further demonstrates the species-specific spectral fingerprint learned by the LSM module. The model can autonomously identify different functional groups of each dopant and distinguish closely related species such as Fritillaria cirrhosa, Fritillaria thunbergii, Fritillaria thunbergii, and Fritillaria thunbergii through differentiated chemical specific features. This fully proves that the detection method can not only accurately distinguish foreign adulteration, but also effectively identify adulteration of closely related species with similar spectral features. Moreover, the detection results have clear chemical mechanism support, which solves the problem of insufficient accuracy and interpretability of traditional methods in the detection of adulteration at complex levels.
[0043] Although embodiments of the invention have been shown and described, the scope of the invention will be defined by the appended claims and their equivalents by those skilled in the art.
Claims
1. A method for detecting adulteration in fritillaria powder based on hyperspectral imaging, characterized in that, Specifically, the following steps are included: Step 1, Sample preparation and hyperspectral data acquisition, specifically includes sample preparation, hyperspectral image acquisition, black and white plate calibration, and spectral extraction; Step 2, spectral data preprocessing, specifically includes noise suppression, baseline correction, and feature enhancement; Step 3, DLSM-CNN model construction and training: Construct a dual-task learnable spectral mask convolutional neural network. This network is an end-to-end deep learning framework, consisting of three cascaded functional modules, and uses a joint loss function to optimize model training. Step 4, Model Inference and Evaluation, specifically includes dataset partitioning, comparative experiment setup, and evaluation metric setting.
2. The method for detecting adulteration of fritillaria powder based on hyperspectral imaging according to claim 1, characterized in that, Step 1 is detailed as follows: Sample preparation: Prepare genuine Fritillaria cirrhosa powder and common adulterants, including foreign matter adulteration and adulteration with closely related species of the same genus; All samples were crushed and sieved, and mixed powder samples were prepared according to the mass ratio of 0% pure product to 100% pure adulterant. Hyperspectral Image Acquisition: Raw hyperspectral images of powder samples were acquired using a near-infrared hyperspectral imaging system. ; Blackboard correction: Reflectance correction of the original image. ; in, The corrected spectral reflectance image, after eliminating interference, can truly reflect the spectral characteristics of the sample; The raw hyperspectral image acquired by the hyperspectral camera contains the spectral information of the sample but is affected by dark current and uneven illumination. The dark current reference image acquired with the lens cap closed represents 0% reflectivity and is used to subtract the device's own dark current noise. Reference image of the whiteboard taken from a standard polytetrafluoroethylene whiteboard; Spectral extraction: Randomly select a region of interest from the center of the corrected image, calculate the average spectrum of all pixels in that region, and use it as the representative spectral data of the sample.
3. The method for detecting adulteration of fritillaria powder based on hyperspectral imaging according to claim 2, characterized in that, Step 2 is detailed as follows: Noise suppression processing: Input the corrected original spectral data into a Gaussian filter and set the standard deviation parameter. Smooth the spectral curve; Baseline correction and feature enhancement: The smoothed spectral data is used as input, and Savitzky-Golay first derivative transformation is performed. The filter window size is set to 15, and the polynomial fitting order is 3.
4. The method for detecting adulteration of fritillaria powder based on hyperspectral imaging according to claim 3, characterized in that, Step 3 is detailed as follows: A dual-task learnable spectral mask convolutional neural network is constructed. This network is an end-to-end deep learning framework consisting of three cascaded functional modules. A joint loss function is used to optimize model training, as follows: Module A: Learnable spectral mask module, which achieves automatic feature band selection through a "soft gating" mechanism. The specific calculation logic is as follows: First, define a learnable weight vector with the same dimension as the input spectrum. ; Input spectrum Upon entering this layer, a mask is generated using the Sigmoid activation function. The formula is: ; in, This represents the Sigmoid activation function, whose function is to activate the weight vector. The value of is constrained to the interval (0,1), so that the mask... The element values are between 0 and 1; Then, element-wise multiplication is performed to obtain the weighted spectrum. The formula is: ; in, To input spectral data, The mask generated for the Sigmoid function. This indicates element-wise multiplication. The core function of this module is to automatically reduce the mask weights corresponding to background noise bands with no information to 0 during network training, while increasing the weights of bands containing key chemical fingerprints to 1, thereby achieving end-to-end adaptive feature band selection. Module B: Weighted spectrum of a hierarchical one-dimensional convolutional backbone network The backbone network is used to extract features. The network contains three stacked convolutional blocks with a pyramidal kernel design. Each convolutional block consists of a convolutional layer, a batch normalization layer, a ReLU activation layer, and a max pooling layer. Convolutional layers: These layers perform convolution operations on spectral data using kernels of different sizes to capture local texture features at different scales. Batch normalization layer: Normalizes the output of the convolutional layer to accelerate model training convergence; ReLU activation layer: Introduces nonlinear transformation; Max pooling layer: Downsamples convolutional features, retaining key features while reducing data dimensionality and computational cost; Module C: The deep features extracted by the dual-task prediction head backbone network are flattened and then distributed to two independent task heads to achieve coordinated qualitative and quantitative detection. Classification Head: Used for qualitative identification. It maps deep features through a fully connected layer and uses the Softmax function to output the probability that the sample belongs to "genuine", "foreign substance adulteration" or "closely related species adulteration", thus completing the adulteration type judgment. Regression head: Used for quantitative analysis, it maps deep features through a fully connected layer and uses the Sigmoid function to output the adulteration ratio, thus achieving accurate calculation of adulteration content.
5. Model Training and Optimization: A joint loss function is designed to achieve collaborative optimization of the two tasks and sparsity constraints in feature selection. The loss function formula is as follows: ; in, Cross-entropy loss is used to optimize classification tasks, minimize the difference between the classification prediction result and the true label, and improve the accuracy of qualitative identification. : Smoothing L1 loss is used to optimize regression tasks, reduce the error between quantitative predictions and the actual adulteration ratio, and improve the accuracy of quantitative analysis; Regularization coefficient, used to balance the weights of the regularization term and other loss terms; LSM weight vector The L1 regularization term forces... It became sparse.
6. The method for detecting adulteration of fritillaria powder based on hyperspectral imaging according to claim 4, characterized in that, Step 4 is detailed as follows: Dataset partitioning: Multiple independent spectral samples were collected for the experiment, including datasets adulterated with foreign substances and datasets adulterated with closely related species; all samples were randomly partitioned into training and testing sets in an 8:2 ratio. Comparative experimental setup: The DLSM-CNN model is compared with traditional partial least squares, support vector regression, standard one-dimensional convolutional neural network without LSM module, bidirectional long short-term memory network, and random forest.
7. Evaluation indicators: Classification accuracy is used to evaluate qualitative identification performance, and coefficient of determination and root mean square error are used to evaluate quantitative analysis performance.
Citation Information
Cited By
A cat food taurine detection method based on hyperspectral imaging and sg-cck deep learning model
CN122176541A