System and method for detecting residual hydrogen peroxide

Through image recognition and deep learning technology, the problems of insufficient sensitivity and complicated operation in the detection of food in the existing technology to detect food in foods have achieved rapid and accurate detection efficiency, and provide strong support for food safety testing.

CN119380087APending Publication Date: 2025-01-28CHONGQING COLLEGE OF ELECTRONICS ENG +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411428649.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-14
Publication Date
2025-01-28

AI Technical Summary

Technical Problem

The prior art is inadequate in detecting hydrogen peroxide residues in food, and it is difficult to meet the needs of fast and accurate large-scale testing.

Method used

Adopt image recognition and deep learning technology, capture the image of the food surface through the camera or imaging sensor, conduct pre -processing and model training, and use logic regression loss functions and adaptive torque estimates for model training and performance evaluation.

Benefits of technology

The rapid and accurate detection of hydrogen peroxide residues on the surface of the food surface is realized, the detection efficiency is improved, the artificial operation error is reduced, and the food safety test provides strong support.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119380087A_ABST
    Figure CN119380087A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of detection, and discloses a system and method for detecting hydrogen peroxide residues, and the system comprises a data acquisition module, a data processing module and a model training and evaluation module; the data acquisition module is used for capturing an image of the food surface through a camera or an imaging sensor; the data processing module is used for preprocessing the captured image, including image size adjustment, conversion into a Tensor format and standardization processing; the model training and evaluation module is used for loading the processed image data and carrying out model training and performance evaluation; and the output module is used for outputting the performance index of the model in each training period. According to the system and the method for detecting the hydrogen peroxide residue, the detection of the hydrogen peroxide residue on the surface of the food is realized through an image recognition and deep learning technology; according to the system and the method, the detection efficiency is improved, manual operation errors are reduced, and powerful support is provided for food safety detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of detection technology, and in particular to a system and method for detecting residual hydrogen peroxide. Background Art

[0002] Hydrogen peroxide (H 2 O 2 ), commonly known as hydrogen peroxide, is a common chemical substance that is widely used in industrial production and daily life. However, with the frequent occurrence of food safety issues in recent years, the problem of hydrogen peroxide residues in food processing has gradually attracted the attention of the public and regulators. In particular, long-term consumption of foods containing hydrogen peroxide residues may have potential negative effects on human health, which has prompted in-depth research and development of rapid and accurate detection methods for hydrogen peroxide residues.

[0003] Although there are many methods for detecting hydrogen peroxide residues in food and health foods, such as redox titration, 4-aminoantipyrine colorimetry, oxygen electrode method, etc., these methods still have many limitations in practical applications. For example, some methods are not sensitive enough to accurately detect low concentrations of hydrogen peroxide residues; while other methods are complicated and time-consuming to operate, and are not suitable for large-scale rapid detection. Summary of the invention

[0004] In view of the deficiencies in the prior art, the present invention provides a system and method for detecting residual hydrogen peroxide to solve the above technical problems.

[0005] In a first aspect, a system for detecting hydrogen peroxide residue is provided, comprising a data acquisition module, a data processing module and a model training and evaluation module; the data acquisition module is used to capture images of food surfaces through a camera or an imaging sensor; the data processing module is used to preprocess the captured images, including adjusting the image size, converting to Tensor format and standardizing; the model training and evaluation module is used to load processed image data, perform model training and performance evaluation; the output module is used to output performance indicators of the model in each training cycle.

[0006] Furthermore, the data processing module includes an image size adjustment module, a format conversion module and a standardization processing module;

[0007] The image size adjustment module is used to uniformly adjust the size of all images to 64x64 pixels;

[0008] The format conversion module is used to convert image data into Tensor format;

[0009] The standardization processing module is used to perform standardization processing on the image data so that its mean value is 0.5 and its standard deviation is 0.5.

[0010] Furthermore, the model training and evaluation module includes a data set loading module, a data loader module, a device configuration module, a loss function and optimizer configuration module, and a model training and evaluation execution module;

[0011] The dataset loading module uses the image folder to load the training set and test set from the specified path and applies the preprocessing steps;

[0012] The data loader module is used to create training and test data loaders, set batch size, and whether to shuffle data parameters;

[0013] The device configuration module is used to determine the device on which the model runs, use the GPU for training, and fall back to the CPU if the GPU is not available;

[0014] The loss function and optimizer configuration module configures a logistic regression loss function and an adaptive moment estimation optimizer for a binary classification task;

[0015] The model training and evaluation execution module is used to perform model training and performance evaluation in each training cycle.

[0016] Furthermore, the model training and evaluation execution module includes: a training mode setting module, a data traversal and processing module, an evaluation mode setting module and a test data evaluation module;

[0017] The training mode setting module is used to set the model to training mode at the beginning of each training cycle;

[0018] The data traversal and processing module is used to traverse each batch of data in the training data loader, move the data to the specified device, clear the gradient, perform forward propagation to calculate the predicted output, calculate the loss, perform back propagation and update the model parameters;

[0019] The evaluation mode setting module is used to set the model to evaluation mode after each training cycle and disable gradient calculation;

[0020] The test data evaluation module is used to traverse each batch of data in the test data loader, perform forward propagation to calculate the prediction output, and calculate evaluation indicators such as accuracy.

[0021] Furthermore, it also includes an output module for outputting the model performance indicators of the current cycle at the end of each training cycle.

[0022] In a second aspect, a method for detecting residual hydrogen peroxide is provided, based on a system for detecting residual hydrogen peroxide as described in any one of the preceding items, comprising the following steps:

[0023] Step S01, collecting food surface image data;

[0024] Step S02, preprocessing the image data;

[0025] Step S03: load the preprocessed data set and configure the loss function and optimizer;

[0026] Step S04, performing model training in each training cycle;

[0027] Step S05: Evaluate model performance after each training cycle.

[0028] Step S06: output the performance index of each training cycle.

[0029] Furthermore, step S02 includes:

[0030] Resize the image, convert it to Tensor format, and normalize it.

[0031] Furthermore, step S04 includes:

[0032] During model training, logistic regression loss was used as the loss function, adaptive moment estimation optimizer was used as the optimizer, and the learning rate was set to 0.001.

[0033] Furthermore, step S05 includes:

[0034] After each training cycle, the accuracy is calculated by comparing the model prediction output with the actual labels to evaluate the model performance.

[0035] The invention adopting the above technical solution has the following advantages:

[0036] The present invention realizes the detection of hydrogen peroxide residues on the surface of food through image recognition and deep learning technology; the system and method not only improve the detection efficiency, but also reduce human operation errors, providing strong support for food safety detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] In order to more clearly illustrate the specific implementation of the present invention, the following will briefly introduce the drawings required for use in the specific implementation. In all the drawings, each element or part is not necessarily drawn according to the actual scale.

[0038] Figure 1 A flow chart of a method for detecting residual hydrogen peroxide according to the present invention; DETAILED DESCRIPTION

[0039] The following embodiments of the technical solution of the present invention are described in detail in conjunction with the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and are therefore only used as examples, and cannot be used to limit the protection scope of the present invention.

[0040] It should be noted that, unless otherwise specified, the technical terms or scientific terms used in this application should be the common meanings understood by technicians in the field to which the present invention belongs. The terms "first", "second", etc. in the specification and claims of the embodiments of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so as to implement the embodiments of the present disclosure described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. Unless otherwise specified, the term "multiple" means two or more. In the embodiments of the present disclosure, the character " / " indicates that the objects before and after are in an "or" relationship. For example, A / B means: A or B. The term "and / or" is a description of the association relationship of objects, indicating that there can be three relationships. For example, A and / or B means: A or B, or, A and B. The term "corresponding" can refer to an association relationship or a binding relationship, and A and B correspondingly refer to an association relationship or a binding relationship between A and B.

[0041] like Figure 1 As shown, a system for detecting hydrogen peroxide residues of the present invention includes a data acquisition module, a data processing module and a model training and evaluation module; the data acquisition module is used to capture images of food surfaces through a camera or an imaging sensor; the data processing module is used to preprocess the captured images, including adjusting the image size, converting to Tensor format and standardizing; the model training and evaluation module is used to load processed image data, perform model training and performance evaluation; the output module is used to output the performance indicators of the model in each training cycle.

[0042] Through image recognition and deep learning technology, the detection of hydrogen peroxide residues on the food surface is realized; the system and method not only improves the detection efficiency, but also reduces human operation errors, providing strong support for food safety testing.

[0043] In some embodiments, the data processing module includes an image size adjustment module, a format conversion module, and a standardization processing module;

[0044] The image resizing module is used to uniformly resize all images to 64x64 pixels;

[0045] The format conversion module is used to convert image data into Tensor format;

[0046] The standardization processing module is used to standardize the image data so that its mean value is 0.5 and its standard deviation is 0.5.

[0047] In some embodiments, the model training and evaluation module includes a data set loading module, a data loader module, a device configuration module, a loss function and optimizer configuration module, and a model training and evaluation execution module;

[0048] The dataset loading module loads the training and test sets from the specified path using the image folder and applies the preprocessing steps;

[0049] The data loader module is used to create training and test data loaders, set batch size, and whether to shuffle data parameters;

[0050] The device configuration module is used to determine the device on which the model runs, using the GPU for training and falling back to the CPU if the GPU is not available;

[0051] The loss function and optimizer configuration module configures the logistic regression loss function and adaptive moment estimation optimizer for binary classification tasks;

[0052] The model training and evaluation execution module is used to perform model training and performance evaluation in each training cycle.

[0053] Specifically, load the dataset: use the image folder (ImageFolder) to load the training set and test set from the specified path, and apply the above preprocessing transformation. Use the data loader (DataLoader) to create training and test data loaders for training and evaluating the model respectively, where the training data loader will shuffle the data order at the beginning of each cycle (epoch).

[0054] Device configuration: Determines the device on which the model runs, preferably using the GPU if available, otherwise using the CPU.

[0055] Define the loss function and optimizer: For the binary classification task, choose logistic regression loss (BCEWithLogitsLoss) as the loss function, which combines the Sigmoid activation function and the binary cross entropy loss. Use the adaptive moment estimation optimizer to adjust the model parameters, and the learning rate is set to 0.001.

[0056] In some embodiments, the model training and evaluation execution module includes: a training mode setting module, a data traversal and processing module, an evaluation mode setting module, and a test data evaluation module;

[0057] The training mode setting module is used to set the model to training mode at the beginning of each training cycle;

[0058] The data traversal and processing module is used to traverse each batch of data in the training data loader, move the data to the specified device, clear the gradient, perform forward propagation to calculate the predicted output, calculate the loss, perform back propagation and update the model parameters;

[0059] The evaluation mode setting module is used to set the model to evaluation mode after each training cycle, disabling gradient calculation;

[0060] The test data evaluation module is used to traverse each batch of data in the test data loader, perform forward propagation to calculate the prediction output, and calculate evaluation indicators such as accuracy.

[0061] Specifically, model training:

[0062] For each training epoch:

[0063] Set the model to training mode.

[0064] Iterate over each batch of data in the training data loader:

[0065] Input format:

[0066] Image size: The data preprocessing stage mentioned that the image size should be adjusted to 64x64 pixels, which means that the image input to the network should be of this size. If a color image is used, there will be three channels (RGB), so the input data shape for each sample is (3, 64, 64) or (batch_size, 3, 64, 64), where batch_size is the number of samples processed each time for training or testing.

[0067] Data type and standardization: After preprocessing, the image data will be converted into Tensor format and standardized so that the mean and standard deviation of the data are 0.5, which means that the value range of the input data will be adjusted to [-1, 1].

[0068] Output format:

[0069] Model output: For binary classification tasks, the output layer of the model uses the Sigmoid activation function to output a value between 0 and 1, which represents the probability of belonging to the positive class. Therefore, the output of a single sample is a scalar value, and the output shape of the entire batch is (batch_size, 1).

[0070] Label format: The labels for binary classification problems are usually encoded as binary (e.g., 1 for positive class and 0 for negative class). During training, in order to use the BCEWithLogitsLoss loss function, the labels should also be converted to a form that matches the model output, i.e. floating point numbers. For a single sample, the label is a scalar (0 or 1), while for a batch, the label shape is (batch_size, 1)

[0071] Move input and label data to the specified device.

[0072] Clear the gradient.

[0073] The forward pass computes the predicted output.

[0074] Transformation process of data forward propagation:

[0075] Input layer: Raw data (such as image pixel values) are input to the first layer of the network. (Raw data is mainly obtained through image acquisition devices, such as cameras or professional imaging sensors, directly photographing or scanning the surface of food. Even though hydrogen peroxide residues themselves are transparent, their presence on food may cause subtle changes in the microstructure, color, gloss, etc. of the surface or internal microstructure of the food. Although these changes are difficult to detect with the naked eye, these subtle differences can be captured through high-precision image sensors and appropriate lighting conditions. Image processing techniques, such as increasing contrast, adjusting brightness and saturation, or using specific wavelengths of light (such as ultraviolet light), can help further highlight these subtle features.)

[0076] In addition to image data, the system also combines sensor data, such as using electrochemical sensors to directly measure the concentration of hydrogen peroxide in food. By combining the values ​​detected by these sensors with image features, a more comprehensive assessment of hydrogen peroxide residues in food can be made. The fusion of image data and sensor data enhances the accuracy and reliability of detection, allowing even transparent residues to be reflected in data analysis through indirect effects.

[0077] In short, even though hydrogen peroxide residue itself is transparent and invisible, the present invention effectively identifies and analyzes indirect signs of hydrogen peroxide residue by comprehensively using a variety of technical means such as image acquisition, sensor detection, and algorithm model processing, thereby achieving rapid detection of its presence and concentration.

[0078] Convolutional layer: Use a convolution kernel (a set of learnable weights) to slide the input data, perform element-wise multiplication and sum, add a bias term, and then perform a nonlinear transformation through an activation function (such as ReLU).

[0079] The formula can be expressed as: Z = f (W * X + b)

[0080] Among them, Z is the output, W is the convolution kernel weight, X is the input, * represents the convolution operation, is the activation function, and b is the bias term.

[0081] Pooling layer: usually used for downsampling, reducing data dimensions, and improving the computational efficiency and robustness of the model. Commonly used pooling operations include maximum pooling, average pooling, etc.

[0082] Fully connected layer: The features processed by the convolutional layer and the pooling layer are flattened into a one-dimensional vector and then input into the fully connected layer for linear combination and nonlinear transformation of the features.

[0083] The formula is: Y = g (W T X+b)

[0084] Where Y is the output, W is the weight matrix, X is the input vector, and g is the activation function.

[0085] In the output layer, the last fully connected layer does not use an activation function such as Sigmoid or Softmax, but a linear activation function. The linear activation function allows the model to output an unrestricted continuous value that directly corresponds to the predicted residual hydrogen peroxide concentration.

[0086] Calculate the loss for the current batch.

[0087] Purpose of loss calculation:

[0088] The loss function (or cost function) is used to measure the gap between the model's prediction and the true value. The purpose of loss calculation is to find the degree of model prediction error, so as to guide the model on how to adjust its weights to reduce this gap. Common loss functions include mean squared error (MSE) for regression problems and cross entropy loss (such as Binary Cross-Entropy or Categorical Cross-Entropy) for classification problems. The smaller the loss value, the better the prediction performance of the model.

[0089] The loss function is calculated as follows:

[0090] Where y is the actual label (in binary form, 0 or 1), is the predicted output of the model (log probability without Sigmoid activation), N is the number of samples, and σ represents the Sigmoid function, defined as

[0091] Backpropagation calculates the gradient.

[0092] The transformation process of back propagation:

[0093] Gradient calculation: Using the chain rule, starting from the output layer, the gradient (partial derivative) of the loss function with respect to each weight is calculated, and this process is gradually reversed through the network to the input layer.

[0094] The specific formula for gradient calculation is:

[0095] For model parameters and loss function, the gradient is calculated as follows:

[0096] 1. For the linear layer: If there are weights W and bias b, and activation function σ, assuming the output

[0097] y=σ(W x +b), the gradient of loss with respect to W can be expressed as

[0098] in, is the derivative of the loss with respect to the output (also called the error term), and is the derivative of the output with respect to the weights.

[0099] 2. For the activation function: If the activation function is ReLU, that is, y = max(0, x), then its derivative is

[0100] 3. For loss function: For example, for mean square error Loss on prediction The derivative of

[0101] Weight update: After calculating the gradient, use an optimization algorithm (such as gradient descent, Adam, etc.) to update the model weights according to the loss gradient.

[0102] The update formula is:

[0103] Among them, W new is the updated weight, W old is the weight before updating, η is the learning efficiency, is the gradient of the loss with respect to the weights.

[0104] Update model parameters.

[0105] Rules for updating model parameters:

[0106] Learning rate: A hyperparameter that controls the step size of weight updates and determines how fast the model learns.

[0107] Momentum (in some optimization algorithms such as Adam): takes into account historical gradients, speeds up the convergence process, and reduces oscillations.

[0108] Regularization: such as L1 or L2 regularization, prevents the model from overfitting by adding a penalty term to the loss function to constrain the size of the weight.

[0109] Model testing:

[0110] After each training epoch:

[0111] Set the model to evaluation mode, disabling gradient calculations to save resources.

[0112] Iterate over each batch of data in the test data loader:

[0113] Move data to the specified device.

[0114] The forward pass computes the predictions.

[0115] The number of samples predicted correctly is calculated to evaluate the accuracy.

[0116] Output the accuracy of the current epoch model on the test set.

[0117] In some embodiments, an output module is also included to output the model performance index of the current cycle at the end of each training cycle.

[0118] In some embodiments, an artificial intelligence 3D model generation module is also included, which is used to generate a 3D model from graphic data.

[0119] In some embodiments, an AR display module is also included, which calls the AI ​​database to accurately generate popular science 3D lesion images based on the collected individual comprehensive data, which is used to combine the hydrogen peroxide image data and food images for reality enhancement, and perform naked-eye AR display through an AR display terminal.

[0120] In some other embodiments, a method for detecting residual hydrogen peroxide is provided, and a system for detecting residual hydrogen peroxide based on any one of the above items comprises the following steps:

[0121] Step S01, collecting image data of the food surface through a camera or an imaging sensor;

[0122] Step S02, preprocessing the image data;

[0123] Step S03: load the preprocessed data set and configure the loss function and optimizer;

[0124] Step S04, performing model training in each training cycle;

[0125] Step S05: Evaluate model performance after each training cycle.

[0126] Step S06: output the performance index of each training cycle.

[0127] In some embodiments, step S02 includes:

[0128] Resize the image, convert it to Tensor format, and normalize it.

[0129] In some embodiments, step S04 includes:

[0130] During model training, logistic regression loss was used as the loss function, adaptive moment estimation optimizer was used as the optimizer, and the learning rate was set to 0.001.

[0131] In some embodiments, step S05 includes:

[0132] After each training cycle, the accuracy is calculated by comparing the model prediction output with the actual labels to evaluate the model performance.

[0133] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein by equivalents. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present invention, and they should all be included in the scope of the claims and specification of the present invention.

Claims

1. A system for detecting residual hydrogen peroxide, characterized in that: include: Data acquisition module, data processing module and model training and evaluation module; The data acquisition module is used to capture images of the food surface through a camera or an imaging sensor; The data processing module is used to pre-process the captured images, including adjusting the image size, converting to Tensor format and standardizing; The model training and evaluation module is used to load processed image data and perform model training and performance evaluation; The output module is used to output the performance indicators of the model in each training cycle.

2. A system for detecting residual hydrogen peroxide according to claim 1, characterized in that: The data processing module includes an image size adjustment module, a format conversion module and a standardization processing module; The image size adjustment module is used to uniformly adjust the size of all images to 64x64 pixels; The format conversion module is used to convert image data into Tensor format; The standardization processing module is used to perform standardization processing on the image data so that its mean value is 0.5 and its standard deviation is 0.

5.

3. A system for detecting residual hydrogen peroxide according to claim 1, characterized in that: The model training and evaluation module includes a data set loading module, a data loader module, a device configuration module, a loss function and optimizer configuration module and a model training and evaluation execution module; The dataset loading module uses the image folder to load the training set and test set from the specified path and applies the preprocessing steps; The data loader module is used to create training and test data loaders, set batch size, and whether to shuffle data parameters; The device configuration module is used to determine the device on which the model runs, use the GPU for training, and fall back to the CPU if the GPU is not available; The loss function and optimizer configuration module configures a logistic regression loss function and an adaptive moment estimation optimizer for a binary classification task; The model training and evaluation execution module is used to perform model training and performance evaluation in each training cycle.

4. A system for detecting residual hydrogen peroxide according to claim 3, characterized in that: The model training and evaluation execution module includes: a training mode setting module, a data traversal and processing module, an evaluation mode setting module and a test data evaluation module; The training mode setting module is used to set the model to training mode at the beginning of each training cycle; The data traversal and processing module is used to traverse each batch of data in the training data loader, move the data to the specified device, clear the gradient, perform forward propagation to calculate the predicted output, calculate the loss, perform back propagation and update the model parameters; The evaluation mode setting module is used to set the model to evaluation mode after each training cycle and disable gradient calculation; The test data evaluation module is used to traverse each batch of data in the test data loader, perform forward propagation to calculate the prediction output, and calculate evaluation indicators such as accuracy.

5. A system for detecting residual hydrogen peroxide according to any one of claims 1 to 4, further comprising an output module for outputting a model performance indicator of the current cycle at the end of each training cycle.

6. A method for detecting residual hydrogen peroxide, characterized in that: A system for detecting residual hydrogen peroxide according to any one of claims 1 to 5, comprising the following steps: Step S01, collecting food surface image data; Step S02, preprocessing the image data; Step S03: load the preprocessed data set and configure the loss function and optimizer; Step S04, performing model training in each training cycle; Step S05: Evaluate model performance after each training cycle. Step S06: output the performance index of each training cycle.

7. The method for detecting residual hydrogen peroxide according to claim 6, comprising in step S02: Resize the image, convert it to Tensor format, and normalize it.

8. The method for detecting residual hydrogen peroxide according to claim 6, comprising in step S04: During model training, logistic regression loss was used as the loss function, adaptive moment estimation optimizer was used as the optimizer, and the learning rate was set to 0.

001.

9. The method for detecting residual hydrogen peroxide according to claim 6, comprising in step S05: After each training cycle, the accuracy is calculated by comparing the model prediction output with the actual labels to evaluate the model performance.