Honey syrup adulteration detection method and system based on CNN-CBAM-SVM combined with H NMR
By combining ¹H NMR technology with an improved CNN-CBAM-SVM model, the problems of speed and accuracy in honey adulteration detection have been solved, achieving efficient and applicable honey adulteration detection suitable for small sample scenarios.
Patent Information
- Application Number
- CN202511046239.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-29
- Publication Date
- 2025-10-31
AI Technical Summary
Existing technologies are insufficient for quickly and accurately detecting adulterated honey. Traditional methods rely on manual experience, are cumbersome or costly, and are difficult to implement in batches.
By combining ¹H NMR technology with an improved deep learning model CNN-CBAM-SVM, a CNN-CBAM-SVM model is constructed by collecting ¹H NMR spectral data of honey. The CBAM module is used to enhance feature weight allocation, and the fully connected layer is replaced with an SVM classifier to achieve efficient and accurate detection of honey adulteration.
It enables rapid and accurate detection of adulteration in honey, is suitable for small sample scenarios, and has high detection efficiency and accuracy. It is applicable to the detection of adulteration in honey and other foods.
Smart Images

Figure CN120877963A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of food quality testing technology, specifically to a method and system for detecting adulteration in honey syrup based on CNN-CBAM-SVM combined with ¹H NMR. Background Technology
[0002] Honey, a nutritious natural food, is loved by consumers for its antibacterial and antioxidant properties. However, due to strong market demand and limited production, honey has become one of the most frequently adulterated foods. Unscrupulous vendors often add syrup to adulterate it, seriously harming consumer rights and market order.
[0003] Currently, common methods for detecting adulterated honey include sensory evaluation, physicochemical analysis, and chromatography-mass spectrometry. However, these methods have many shortcomings: sensory evaluation relies on subjective experience and has low accuracy; physicochemical analysis is cumbersome and time-consuming; and instrumental analysis methods such as chromatography-mass spectrometry are costly, require professional personnel, and are difficult to implement for rapid batch testing.
[0004] Nuclear magnetic resonance (NMR) technology, especially ¹H NMR, can rapidly acquire the chemical fingerprint spectrum of samples, enabling simultaneous detection of multiple components. It boasts advantages such as high sensitivity and non-destructive nature, showing great potential in food component analysis. Meanwhile, convolutional neural networks (CNNs) in deep learning technology excel in image recognition and feature extraction; however, traditional CNNs suffer from problems such as unreasonable allocation of feature channels and spatial weights, and weak generalization ability with small sample sizes.
[0005] Therefore, how to combine ¹H NMR technology with improved deep learning models to achieve efficient and accurate detection of adulteration in honey syrup has become an urgent technical problem to be solved. Summary of the Invention
[0006] To address the problems in the existing technology, this invention proposes a method for detecting adulteration in honey syrup based on CNN-CBAM-SVM combined with ¹H NMR, comprising the following steps: Step 1: Collect ¹H NMR spectral data of the honey sample to be tested; Step 2: Construct a CNN-CBAM-SVM model, which includes convolutional layers and CBAM. A module and an SVM classifier, wherein the CBAM module is located between the convolutional layer and the activation function; Step 3: Train the CNN-CBAM-SVM using the ¹H NMR spectral data of the training samples. Model; Step 4: Input the ¹H NMR spectral data of the sample to be tested into the trained model. Results of honey adulteration test are available.
[0007] Furthermore, in step 1, the ¹H NMR spectral data includes an aliphatic region, a carbohydrate region, and an aromatic region; the aliphatic region is 0–3 ppm, the carbohydrate region is 3–6 ppm, and the aromatic region is 6–10 ppm.
[0008] Furthermore, in step 1, the ¹H NMR spectral data is converted into an image feature matrix and divided into a training set and a validation set.
[0009] Furthermore, step 2 specifically includes: Step 2.1: Build the CNN-CBAM model: Using batch normalization, the input value of each neuron is converted into a standard normal distribution with a mean of 0 and a variance of 1; a CBAM module is added after the convolutional layer and before the activation function, so that the model can pay attention to both channel and spatial dimensions at the same time; Step 2.2: Train the CNN-CBAM model: Pre-train the CNN+MLP model, specifying the parameters for the number of iterations, error propagation function, and learning rate; after training, extract the feature vectors of the CNN model using the Flatten operation, and obtain image features through the CNN; use the extracted feature vectors as the input dataset for the support vector machine; use the make_pipeline() function with StandardScaler to process the feature vectors, scaling them to a standard normal distribution with a mean of 0 and a standard deviation of 1; MLP is a multilayer perceptron; Step 2.3: Construct the CNN-CBAM-SVM model: Modify the CNN-CBAM model by removing the last fully connected layer and the SoftMax output layer, and replace them with a support vector machine model suitable for small samples; input the corresponding labels and specify the number of iterations, kernel function type, regularization parameter C, and random parameters to train the support vector machine model; use the t-SNE method to map the final classification result to a two-dimensional plane and generate the t-SNE classification map and the corresponding confusion matrix.
[0010] Furthermore, in step 2.1, the CBAM module includes a channel attention mechanism (CAM) and a spatial attention mechanism (SAM). The channel attention mechanism (CAM) assigns weights to each channel of the feature map, and the spatial attention mechanism (SAM) generates a weight mask for spatial location.
[0011] Furthermore, in step 2.2, the StandardScaler is implemented through the make_pipeline() function for the standardization of feature vectors.
[0012] Furthermore, in step 2.2, the number of iterations is 300, the error transfer function is sparse classification cross-entropy, and the initial value of the learning rate is 0.0001; the parameters also include a batch size of 16 and an optimizer of Adam.
[0013] Furthermore, in step 2.3, the number of iterations is 300, the kernel function type is linear, the regularization parameter C is 1, and the random parameter is 42.
[0014] Furthermore, the output detection results of step 4 are verified by confusion matrix and t-SNE visualization, where t-SNE reduces the dimensionality of the classification results to a two-dimensional plane.
[0015] On the other hand, the present invention also provides a honey syrup adulteration detection system based on CNN-CBAM-SVM combined with ¹H NMR, comprising: The data acquisition module is used to acquire ¹H NMR spectral data of honey samples; The model training module is used to build and train the CNN-CBAM-SVM model described above. The detection module is used to input the ¹H NMR spectral data of the sample to be tested into the trained model and output the detection results.
[0016] The present invention has the following technical effects: 1. High detection efficiency: No complicated preprocessing steps are required. Rapid detection is achieved directly through ¹H NMR spectroscopy combined with a deep learning model, which greatly shortens the detection time. 2. High accuracy: The CBAM module is introduced to enhance the weight allocation of key features, and the SVM classifier is combined to improve the generalization ability under small sample conditions, achieving 100% accuracy on both the training and validation sets; 3. Strong applicability: It is suitable for small sample scenarios, solves the overfitting problem of traditional CNN when the sample size is limited, and can be widely used in the detection of adulteration in honey and other foods. Attached Figure Description
[0017] Figure 1 This is the specific structure of the CBAM module of the present invention; Figure 2 This is a partially stitched image of the dataset of this invention; Figure 3 This is the specific model structure of CNN-CBAM in this invention; Figure 4 This is the specific process of training the CNN-CBAM model in this invention; Figure 5This is the CNN-CBAM-SVM model structure of the present invention; Figure 6 The ¹H NMR spectra of pure wolfberry honey and honey adulterated with two different syrups are shown in this invention. Figure 7 The accuracy variation curves during the training process of the CNN-CBAM and CNN-CBAM-SVM models of this invention are shown. Figure 8 This is a schematic diagram of the system of the present invention. Detailed Implementation
[0018] To make the objectives, advantages, and features of the present invention more apparent, the following description is provided in conjunction with the appendix. Figure 1-8 The present invention will be further described in detail below with reference to specific embodiments.
[0019] To identify syrup adulteration in honey, this invention develops a deep learning model based on a CNN-CBAM-SVM architecture combined with ¹H NMR spectroscopy. By incorporating CBAM modules and replacing fully connected layers with SVM classifiers, the traditional CNN model is enhanced, making it well-suited for small sample sizes. ¹H NMR spectra of 20 genuine honey samples and 20 adulterated samples containing two different syrups were used to create a training set (32 samples) and a validation set (8 samples). The CNN-CBAM-SVM architecture effectively addresses common problems in traditional CNN models, such as class imbalance in the softmax layer, weak generalization ability, poor robustness, and low detection accuracy. The final model achieved 100% accuracy on both the training and validation sets, and t-SNE visualization further confirmed its correct classification performance.
[0020] Specifically, Convolutional Neural Networks (CNNs) typically consist of an input layer, multiple hidden layers, fully connected layers, and an output layer. When analyzing an image, the input layer consists of a pixel matrix, usually a three-dimensional array representing the image's width, height, and number of channels. Hidden layers typically include multiple convolutional and pooling layers. The convolutional layer is the core of the CNN; it applies convolutional kernels to the pixel matrix to generate feature maps. Pooling layers reduce the dimensionality of the data and compress the extracted features, reducing the computational complexity of the network while preserving key information (X. Liu et al., 2024). The specific formula for a convolutional layer is...
[0021] Where: uppercase X, subscript ij..., uppercase S is the j-th feature value of the i-th feature map in the S-th layer network; b, subscript ij..., left parenthesis uppercase S minus 1, right parenthesis is the bias value; w, subscript ij..., s is the weight coefficient; f is the selected corresponding activation function.
[0022] The input to a fully connected layer consists of features extracted from previous layers, typically represented as multidimensional vectors. The function of a fully connected layer is to process these features and map them to the final output space, such as the class label of a sample. The output layer then maps the features from the previous fully connected layer to the final task, such as calculating class probabilities using the softmax function.
[0023] Traditional convolutional neural networks do not assign weights during convolution operations to indicate the importance of each channel. This not only leads to high computational costs but also negatively impacts image classification accuracy. Convolutional Block Attention Modules (CBAMs) perform attention operations in both spatial and channel dimensions, improving the effectiveness of image classification and object detection. By placing the CBAM module after the convolution operation and before the activation function, the weight distribution becomes more balanced. The specific structure of the CBAM module is shown in Figure 1.
[0024] Support Vector Machine (SVM) is a widely used supervised learning algorithm, primarily used for classification and regression tasks. For non-linearly separable data, SVM uses a kernel function to map the input data to a high-dimensional feature space, aiming to find a linearly separable hyperplane within this space. The advantages of SVM include a strong theoretical foundation, minimal data requirements, and robustness to high-dimensional data, making it particularly suitable for classification problems with small samples and high-dimensional feature spaces.
[0025] This invention employs a CNN-CBAM-SVM neural network model combined with ¹H NMR spectroscopy to detect syrup adulteration in goji berry honey. By integrating the CBAM module and SVM into a classic CNN model for improvement, the proposed CNN-DBAM-SVM model is used to extract image features from ¹H NMR fingerprint data. The aim is to develop a deep learning model for small sample data, providing a novel method for detecting honey adulteration. Example
[0026] Step 1: Dataset Selection Support Vector Machines (SVMs) are suitable for classification problems in high-dimensional spaces with small sample sizes. In this invention, 20 genuine goji berry honey samples and 20 adulterated honey samples (mixed with corn syrup or malt syrup) were used. Genuine goji berry honey was labeled 1, and adulterated goji berry honey was labeled 0. The dataset was further divided into training and validation sets in a 4:1 ratio, with the training set (32 samples) used to tune model parameters and the validation set (8 samples) used to evaluate the accuracy and performance of the model during training. A partial stitched image of the dataset is shown in Figure 2.
[0027] Step 2: Build the CNN-CBAM-SVM model Here, we first establish the CNN-CBAM model: A network model with six convolutional and pooling layers was built based on the traditional CNN architecture. During the construction process, it was observed that as training progressed, the data distribution gradually shifted towards the upper and lower bounds of the activation function. For the ReLU function, this means that too many neurons output 0, leading to the vanishing gradient problem in lower layers during backpropagation, resulting in unstable network performance. To address this issue, batch normalization was applied, which transforms the input values of each neuron into a standard normal distribution with a mean of 0 and a variance of 1. This normalization satisfies the assumption of independent and identically distributed (IID) data, thus preventing the vanishing gradient problem and accelerating the convergence and training process of the network. Furthermore, to enhance the model's focus on important features in the input NMR spectrum, a CBAM module was added after the convolutional layers and before the activation function, enabling the model to simultaneously focus on channel and spatial dimensions. The specific model structure is as follows. Figure 3 As shown.
[0028] Then, train the CNN-CBAM model: Since the SMO algorithm of Support Vector Machines (SVMs) is a discrete optimization method, directly backpropagating the error and adjusting the CNN parameters is not easy. Therefore, we first pre-train the CNN+MLP model, where MLP stands for Multilayer Perceptron, specifying its iteration count, error propagation function, learning rate, and other parameters. After training, we extract the feature vectors of the CNN model using the Flatten operation and obtain image features through the CNN. Then, we use the extracted feature vectors as the input dataset for the SVM. Subsequently, we use the `make_pipeline()` function with `StandardScaler` to scale the feature vectors to a standard normal distribution with a mean of 0 and a standard deviation of 1. This is used to train the SVM classifier, specifying the iteration count and various hyperparameters. The specific process is as follows: Figure 4 As shown.
[0029] Based on the previous processing results, construct the CNN-CBAM-SVM model: The CNN-CBAM model was modified by removing the last fully connected layer and the SoftMax output layer, and replacing them with a support vector machine (SVM) model suitable for small sample sizes. The SVM model was trained by inputting the corresponding labels and specifying the number of iterations, kernel type, regularization parameter C, and random parameters. Then, the t-SNE method was used to map the final classification result to a two-dimensional plane, generating a t-SNE classification map and the corresponding confusion matrix. Specific improvements are shown in the red dashed circle in Figure 5.
[0030] The computer parameters for the training and validation sets, as well as the model environment resource configuration, are shown in Table 1: Table 1
[0031] The model was evaluated and results were predicted. The purpose of model evaluation was to assess the impact of different modeling methods. In this study, evaluation metrics included recall (R), precision (P), F1 score, and confusion matrix. The abbreviations used in the formulas are defined as follows: TP: True positives, i.e., positive samples are classified as positive; FP: False positives, i.e., negative samples are classified as positive; FN: False negatives, i.e., positive samples are classified as negative.
[0032]
[0033]
[0034]
[0035] Next step: The final results obtained from the ¹H NMR spectra of wolfberry honey and adulterated wolfberry honey are as follows: Based on chemical shift, the ¹H NMR spectrum of honey is typically divided into three regions: an aliphatic region (0–3 ppm), a carbohydrate region (3–6 ppm), and an aromatic region (6–10 ppm). Figure 6 shows the ¹H NMR spectra of pure goji berry honey and honey adulterated with two different syrups. The differences between pure goji berry honey and the adulterated sample are most pronounced in the carbohydrate region, with some distinctive peaks changing as the degree of adulteration increases. However, distinguishing subtle differences in other regions remains challenging.
[0036] The training parameters of the CNN-CBAM and the improved CNN-CBAM-SVM models are shown in Table 2 and Table 3, respectively: Table 2
[0037] Table 3
[0038] Figure 7 shows the accuracy variation curves during the training process of CNN-CBAM and CNN-CBAM-SVM models. Figure 7 Figure 1 shows the accuracy curves of the CNN-CBAM model on the training and validation sets. Clearly, the model achieves near 100% accuracy on the training set, but its accuracy stagnates on the validation set, indicating poor generalization ability and suboptimal performance when classifying unseen data. This suggests overfitting.
[0039] In contrast, the SVM classifier trained with the CNN-CBAM model consistently maintained a high accuracy, achieving 100% accuracy on both the training and validation sets (the two lines completely overlap) (Figure 7b). This indicates that the CNN-CBAM-SVM model is superior to... The CNN-CBAM model has better generalization ability and superior accuracy performance.
[0040] To further validate the model's performance, a confusion matrix and t-SNE visualization were generated. The confusion matrix of the CNN-CBAM model struggled to detect adulterated samples, as almost all adulterated goji berry honey samples were misclassified as genuine goji berry honey. This highlights the model's poor robustness and limited generalization ability.
[0041] In contrast, the confusion matrix of the CNN-CBAM-SVM model demonstrates strong classification performance on both the training and validation sets. All samples are arranged along the diagonal of the matrix, indicating that the model correctly classifies all samples, highlighting its good generalization ability and high robustness.
[0042] For the CNN-CBAM-SVM model, t-SNE visualization results were obtained. Dimensionality reduction clearly shows that genuine and adulterated goji berry honey are correctly classified, with the samples clearly divided into two distinct regions in the two-dimensional graph. This indicates that the model achieves a good balance in its classification results. Category 0 represents adulterated goji berry honey, while category 1 represents genuine goji berry honey.
[0043] Table 4 shows the classification performance of the CNN-CBAM and CNN-CBAM-SVM models on the training and validation sets. It is clear that when applied to small datasets, the CNN-CBAM model performs worse than the CNN-CBAM-SVM model, with significantly lower accuracy and F1 score. This indicates that the CNN-CBAM-SVM model is more suitable for small datasets, while the CNN-CBAM model performs poorly with small sample sizes due to its limited generalization ability. The CNN-CBAM model may require more data to perform effectively, highlighting its limitations in handling small datasets.
[0044] Table 4
[0045] This invention combines ¹H NMR spectroscopy with a CNN-CBAM-SVM deep learning network for detecting syrup adulteration in monofloral honey (goji berry honey). The traditional CNN model is enhanced by introducing a CBAM module and replacing the fully connected layers with an SVM classifier. The CNN-CBAM-SVM deep learning network model achieves near 100% accuracy on both the training and validation sets, demonstrating high accuracy and robustness when handling small datasets. It is well-suited for small datasets and shows great potential in verifying the authenticity of honey.
[0046] The contents not described in detail in this specification are existing technologies known to those skilled in the art.
[0047] Finally, it should be noted that the above descriptions are merely preferred embodiments of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for detecting adulteration in honey syrup based on CNN-CBAM-SVM combined with ¹H NMR, characterized in that, Includes the following steps: Step 1: Collect ¹H NMR spectral data of the honey sample to be tested; Step 2: Construct a CNN-CBAM-SVM model, which includes convolutional layers and CBAM. A module and an SVM classifier, wherein the CBAM module is located between the convolutional layer and the activation function; Step 3: Train the CNN-CBAM-SVM using the ¹H NMR spectral data of the training samples. Model; Step 4: Input the ¹H NMR spectral data of the sample to be tested into the trained model, and input... Results of honey adulteration test are available.
2. The method as described in claim 1, characterized in that, In step 1, the ¹H NMR spectral data includes aliphatic region, carbohydrate region and aromatic region; the aliphatic region is 0–3 ppm, the carbohydrate region is 3–6 ppm and the aromatic region is 6–10 ppm.
3. The method as described in claim 1, characterized in that, In step 1, the ¹H NMR spectral data is converted into an image feature matrix and divided into a training set and a validation set.
4. The method as described in claim 1, characterized in that, Step 2 specifically includes: Step 2.1: Build the CNN-CBAM model: Using batch normalization, normalize each neuron... The input values of the model are converted to a standard normal distribution with a mean of 0 and a variance of 1. A CBAM module is added after the convolutional layer and before the activation function to enable the model to focus on both channel and spatial dimensions. Step 2.2: Train the CNN-CBAM model: Pre-train the CNN+MLP model, specifying the parameters for the number of iterations, error propagation function, and learning rate; after training, extract the feature vectors of the CNN model using the Flatten operation, and obtain image features through the CNN; use the extracted feature vectors as the input dataset for the support vector machine; use the make_pipeline() function to process the feature vectors using StandardScaler, scaling them to a standard normal distribution with a mean of 0 and a standard deviation of 1; Step 2.3: Construct the CNN-CBAM-SVM model: Modify the CNN-CBAM model by removing the last fully connected layer and the SoftMax output layer, and replace them with a support vector machine model suitable for small samples; input the corresponding labels and specify the number of iterations, kernel function type, regularization parameter C, and random parameters to train the support vector machine model; use the t-SNE method to map the final classification result to a two-dimensional plane and generate the t-SNE classification map and the corresponding confusion matrix.
5. The method as described in claim 4, characterized in that, In step 2.1, the CBAM module includes a channel attention mechanism (CAM) and a spatial attention mechanism (SAM). The channel attention mechanism (CAM) assigns weights to each channel of the feature map, and the spatial attention mechanism (SAM) generates a weight mask for spatial location.
6. The method as described in claim 4, characterized in that, In step 2.2, the StandardScaler is implemented through the make_pipeline() function for the standardization of feature vectors.
7. The method as described in claim 4, characterized in that, In step 2.2, the number of iterations is 300, the error propagation function is sparse classification cross-entropy, and the initial value of the learning rate is 0.0001; the parameters also include a batch size of 16 and an optimizer of Adam.
8. The method as described in claim 4, characterized in that, In step 2.3, the number of iterations is 300, the kernel function type is linear, the regularization parameter C is 1, and the random parameter is 42.
9. The method as described in claim 1, characterized in that, The output detection results of step 4 are verified by confusion matrix and t-SNE visualization, where t-SNE maps the classification results to a two-dimensional plane.
10. A honey syrup adulteration detection system based on CNN-CBAM-SVM combined with ¹H NMR, characterized in that, include: The data acquisition module is used to acquire ¹H NMR spectral data of honey samples; A model training module for constructing and training the CNN-CBAM-SVM model as described in any one of claims 1-9; The detection module is used to input the ¹H NMR spectral data of the sample to be tested into the trained model and output the detection results.