A food safety detection system based on spectral analysis
Through the combination of fuzzy C-mean clustering algorithm and incremental learning module, the accuracy and real-time problems of traditional spectral analysis and detection systems in complex sample processing are solved, efficient and accurate judgment of food safety grades is achieved, and detection is improved System adaptability and real-time.
Patent Information
- Application Number
- CN202411204815.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2044-08-30
AI Technical Summary
Traditional food safety testing systems based on spectral analysis are difficult to quickly and accurately detect complex samples, and the sample preparation process is cumbersome, resulting in high detection cost and low efficiency, and cannot adapt to new data characteristics, affecting the real-time and accuracy of detection. .
The fuzzy C-means clustering algorithm is used to classify spectral data, combine the incremental learning module to dynamically update the model, and the deep feature fusion module combines spectral features, and optimizes the model through the adaptive moment estimation algorithm to realize real-time judgment and monitoring of food safety levels.
Effectively handle the uncertainty and ambiguity of spectral data, reduce judgment errors, improve real-time and adaptability of detection, ensure accurate determination of food safety levels under complex sample conditions, and reduce detection costs and time.
Smart Images

Figure CN118730953B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of food detection, and in particular to a food safety detection system based on spectral analysis. Background Art
[0002] The field of food testing technology focuses on using various scientific methods and technical means to analyze food samples to ensure food safety and compliance with relevant health standards. This technology includes microbiological, chemical and physical testing to identify harmful substances, contaminants or pathogenic microorganisms that may be present in food and verify the authenticity and quality of food ingredients. It aims to improve food safety and protect public health while meeting regulatory requirements and consumer demand for high-quality food.
[0003] Among them, the food safety testing system based on spectral analysis is a method that uses spectral technology to analyze the composition and characteristics of food samples. Its purpose is to identify and quantify specific chemicals in food through rapid and non-destructive means to evaluate its safety and quality. It aims to achieve efficient and accurate food testing results, reduce the complex sample preparation process common in traditional chemical analysis methods, reduce costs, and shorten testing time. It helps the food industry improve production efficiency while ensuring that consumers can eat safe and uncontaminated food.
[0004] Traditional testing systems include complicated sample handling processes and long testing cycles, which are particularly evident when dealing with food safety incidents that require rapid feedback. Although they play an important role in ensuring food safety, they are limited in meeting the needs of fast and efficient testing. The complicated sample preparation process and reliance on specialized equipment increase testing costs, limiting their widespread application in the field of food safety testing. When faced with sample diversity and complexity, they are difficult to adapt to new data features, affecting testing efficiency and accuracy. Summary of the invention
[0005] The purpose of the present invention is to solve the shortcomings of the prior art and to propose a food safety detection system based on spectral analysis.
[0006] In order to achieve the above object, the present invention adopts the following technical solution: a food safety detection system based on spectral analysis, the system comprising:
[0007] The spectrum acquisition module performs spectral scanning based on the target food sample, collects data from infrared, ultraviolet, and Raman spectroscopy equipment, adjusts the scanning parameters to cover the wavelength range, and obtains the spectral data set;
[0008] The fuzzy logic analysis module uses a fuzzy C-means clustering algorithm based on the spectral data set to set the threshold range of the absorption peak and wavelength, construct a fuzzy set reflecting the difference security level, including safe, potentially unsafe and unsafe, and classify the data according to the set threshold to generate a fuzzy classification index;
[0009] The incremental learning module monitors the difference between new and old spectral data based on the fuzzy classification index, adjusts the learning rate and data weight, matches the new data features, and dynamically updates the model to construct an incremental update model;
[0010] The deep feature fusion module adjusts the feature extraction parameters, including filter size and step size, for infrared, ultraviolet, and Raman spectral data based on the incremental update model, merges the differentiated spectral features, and establishes a comprehensive fusion feature set;
[0011] The model training module uses an adaptive moment estimation algorithm based on the comprehensive fusion feature set, adjusts the network layer structure and activation function parameters, performs multiple rounds of training, optimizes weights and biases, and determines model parameters through validation set evaluation to generate a performance optimization model;
[0012] The model adjustment module analyzes the safety level distribution of food samples based on the performance optimization model, adjusts the judgment threshold and classification standard, recalibrates the model, optimizes the pertinence and accuracy, and obtains a calibrated model;
[0013] The safety level determination module determines the safety level of the food sample based on the calibrated model, maps the result to the categories of safe, potentially unsafe and unsafe, and assigns the safety level according to the confidence level predicted by the model to obtain the safety level determination result;
[0014] The real-time monitoring module sets monitoring parameters and alarm thresholds according to the safety level determination result, continuously monitors the food safety status, adjusts the monitoring strategy according to the real-time data, and establishes a monitoring status log.
[0015] The improvements of the present invention are that the fuzzy classification indicators include a safety level threshold, an absorption peak threshold, and a wavelength range; the incremental update model includes new data adaptability, a dynamic weight adjustment mechanism, and real-time learning rate adjustment; the performance optimization model includes training round adjustment, activation function selection, and network structure optimization parameters; the calibrated model includes a safety level determination threshold, classification accuracy optimization parameters, and determination standard refinement items; the safety level determination result includes a food safety level, a confidence index, and a safety level classification basis; the monitoring status log includes a monitoring timestamp, a food safety event record, and a monitoring strategy adjustment history.
[0016] The present invention is improved in that the spectrum acquisition module includes a scanning parameter setting submodule, a spectrum data collection submodule, and a data integration submodule;
[0017] The scanning parameter setting submodule performs spectral scanning based on the target food sample, adjusts the scanning parameters of the infrared, ultraviolet and Raman spectroscopy equipment, and covers the required wavelength range to generate the scanning parameter configuration;
[0018] The spectral data collection submodule collects spectral data of food samples from infrared, ultraviolet and Raman spectroscopy equipment based on scanning parameter configuration, including wavelength, absorption peak and intensity, to obtain a preliminary spectral data set;
[0019] The data integration submodule integrates and formats the data from the difference spectrum device based on the preliminary spectrum data set, verifies the consistency and integrity of the data, and obtains the spectrum data set.
[0020] The present invention is improved in that the fuzzy logic analysis module includes a threshold setting submodule, a security level building submodule, and a data classification submodule;
[0021] The threshold setting submodule analyzes the spectral features, including the absorption peak and the wavelength range, based on the spectral data set, and sets the threshold range of the difference security level to generate a threshold parameter table;
[0022] The security level construction submodule is based on the threshold parameter table. If the spectral feature is within the set range, it is classified into the corresponding security level, including safe, potentially unsafe and unsafe, to construct a fuzzy security set;
[0023] The data classification submodule classifies the spectral data set based on the fuzzy security set and adopts the fuzzy C-means clustering algorithm. If the data features meet the fuzzy security set of the security level, it is classified into the corresponding level and a fuzzy classification index is generated;
[0024] The fuzzy C-means clustering algorithm is based on the formula:
[0025] ;
[0026] Calculate the membership of each data point to the cluster center and generate fuzzy classification indicators;
[0027] in, For the Data points for The membership degree of the cluster centers is For the data points, For the Cluster centers, is the number of cluster centers, is the fuzzy parameter, is the weight factor, For data points The data sensitivity coefficient is is the clustering fitness coefficient, is the environmental impact factor, is the index.
[0028] The present invention is improved in that the incremental learning module includes a data difference analysis submodule, a learning parameter adjustment submodule, and a model update submodule;
[0029] The data difference analysis submodule compares the new and old spectral data sets based on the fuzzy classification index, identifies the changes in data features, determines the learning rate and data weight that need to be adjusted, and obtains the data difference analysis results;
[0030] The learning parameter adjustment submodule calculates the value of the feature change of the new and old data based on the data difference analysis results, adjusts the data input weight and rate, optimizes the response sensitivity of the model, and generates adjusted learning parameters;
[0031] The model update submodule dynamically updates the existing model based on the adjusted learning parameters, integrates the new parameters into the model through iterative training, and constructs an incremental update model.
[0032] The present invention is improved in that the deep feature fusion module includes an extraction parameter adjustment submodule, a feature merging submodule, and a feature set construction submodule;
[0033] The extraction parameter adjustment submodule adjusts the feature extraction parameters, including the filter size and step size, for infrared, ultraviolet and Raman spectral data based on the incremental update model to obtain the adjusted extraction parameters;
[0034] The feature merging submodule merges the features from the difference spectrum data based on the adjusted extraction parameters, verifies the fusion effect of the difference spectrum features, and generates a merged feature set;
[0035] The feature set construction submodule organizes and formats the features based on the merged feature set, performs data format consistency verification, and establishes a comprehensive fusion feature set.
[0036] The present invention is improved in that the model training module includes a network structure design submodule, a training process execution submodule, and a performance evaluation submodule;
[0037] The network structure design submodule is based on the comprehensive fusion feature set, evaluates the feature set dimension, designs the network hierarchy, including the number of layers and neurons, matches the feature set requirements, and generates the network architecture configuration;
[0038] The training process execution submodule is configured according to the network architecture, adopts an adaptive moment estimation algorithm, and gradually adjusts the network parameters through iterative training including forward propagation, loss calculation, back propagation, and weight and bias update to generate a training network model;
[0039] The adaptive moment estimation algorithm is according to the formula:
[0040] ;
[0041] Calculate parameter updates and generate the network model in training;
[0042] in, is the parameter value of the current iteration step, is the learning rate, is the learning rate adjustment factor, is the corrected first-order moment estimate, is the first-order moment estimation adjustment coefficient, is the corrected second-order moment estimate, is the second-order moment estimation adjustment coefficient, is a numerical stability constant, Parameters for performance considerations;
[0043] The performance evaluation submodule performs performance evaluation based on the training network model and the validation set, analyzes the performance of the model on unseen data, adjusts the network structure and parameters according to the evaluation results, and generates a performance optimization model.
[0044] The present invention is improved in that the model adjustment module includes a security level analysis submodule, a threshold adjustment submodule, and a model calibration submodule;
[0045] The safety level analysis submodule analyzes the safety level distribution of food samples based on the performance optimization model, identifies the deviation of the model in determining the difference safety level, determines the range of model parameters that need to be adjusted, and obtains a safety level analysis record;
[0046] The threshold adjustment submodule adjusts the threshold used for classification in the determination model according to the security level analysis record, optimizes the model's recognition performance for different security levels, and generates adjusted threshold parameters;
[0047] The model calibration submodule retrains and calibrates the performance optimization model based on the adjusted threshold parameters, optimizes the model's determination performance at the security level, and obtains a calibrated model.
[0048] The present invention is improved in that the security level determination module includes a level determination submodule, a confidence assessment submodule, and a level mapping submodule;
[0049] The grade determination submodule predicts the safety grade of food samples based on the calibrated model, classifies them into safe, potentially unsafe and unsafe according to the model output, and generates preliminary safety grade determination data;
[0050] The confidence assessment submodule performs confidence assessment on the preliminary security level determination data, calculates the confidence of the model for the security level determination, matches the sample determination result with a corresponding confidence score, and obtains a confidence score record;
[0051] The level mapping submodule maps the confidence score record to the security level classification based on the security level determination result of each sample and the corresponding confidence score to obtain the security level determination result.
[0052] The present invention is improved in that the real-time monitoring module includes a monitoring parameter setting submodule, a food safety status monitoring submodule, and a monitoring strategy adjustment submodule;
[0053] The monitoring parameter setting submodule determines the parameters required for monitoring the food safety status based on the safety level determination result, including the detection frequency, alarm threshold and safety level standard, sets the initial monitoring conditions, and establishes the monitoring parameter configuration;
[0054] The food safety status monitoring submodule monitors the food safety status based on the monitoring parameter configuration, including data collection and safety level assessment, and triggers an alarm according to a preset threshold to generate real-time monitoring records;
[0055] The monitoring strategy adjustment submodule evaluates the monitoring effect and alarm response according to the real-time monitoring records, adjusts the monitoring strategy, modifies the monitoring parameters and thresholds, optimizes the monitoring efficiency, and establishes a monitoring status log.
[0056] Compared with the prior art, the advantages and positive effects of the present invention are:
[0057] In the present invention, a fuzzy C-means clustering algorithm is used to perform fuzzy classification on spectral data, and a fuzzy set of difference safety levels is dynamically constructed according to the threshold range of absorption peaks and wavelengths, thereby effectively handling the uncertainty and ambiguity of spectral data, allowing the system to accurately determine the safety level of complex and ambiguous food sample data, greatly reducing the determination errors caused by the high complexity of the samples, and dynamically updating the model through the incremental learning module to ensure that the system can adapt to new data features, further improving the real-time and adaptability of the detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Figure 1 A module diagram of a food safety detection system based on spectral analysis is proposed for the present invention;
[0059] Figure 2The present invention proposes a system framework diagram of a food safety detection system based on spectral analysis;
[0060] Figure 3 The present invention proposes a spectrum acquisition module flow chart in a food safety detection system based on spectrum analysis;
[0061] Figure 4 The present invention proposes a flow chart of a fuzzy logic analysis module in a food safety detection system based on spectral analysis;
[0062] Figure 5 The present invention proposes a flow chart of an incremental learning module in a food safety detection system based on spectral analysis;
[0063] Figure 6 The present invention proposes a flow chart of a deep feature fusion module in a food safety detection system based on spectral analysis;
[0064] Figure 7 The present invention proposes a flow chart of a model training module in a food safety detection system based on spectral analysis;
[0065] Figure 8 The present invention proposes a flow chart of a model adjustment module in a food safety detection system based on spectral analysis;
[0066] Fig. 9 The present invention proposes a flow chart of a safety level determination module in a food safety detection system based on spectral analysis;
[0067] Fig.10 The present invention proposes a flow chart of a real-time monitoring module in a food safety detection system based on spectral analysis. DETAILED DESCRIPTION
[0068] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0069] In the description of the present invention, it should be understood that the terms "length", "width", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc., indicating positions or positional relationships, are based on the positions or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, in the description of the present invention, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined.
[0070] Example: See Figure 1 The present invention provides a technical solution: a food safety detection system based on spectral analysis comprises:
[0071] The spectrum acquisition module performs spectral scanning based on the target food sample, collects data from infrared, ultraviolet, and Raman spectroscopy equipment, adjusts the scanning parameters to cover the wavelength range, and obtains the spectral data set;
[0072] The fuzzy logic analysis module uses the fuzzy C-means clustering algorithm based on the spectral data set, sets the threshold range of the absorption peak and wavelength, constructs a fuzzy set that reflects the difference in security level, including safe, potentially unsafe, and unsafe, and classifies the data according to the set threshold to generate a fuzzy classification index;
[0073] The incremental learning module monitors the difference between new and old spectral data based on fuzzy classification indicators, adjusts the learning rate and data weight, matches the new data features, and dynamically updates the model to build an incremental update model;
[0074] The deep feature fusion module is based on the incremental update model, which adjusts the feature extraction parameters for infrared, ultraviolet, and Raman spectral data, including filter size and step size, merges differentiated spectral features, and establishes a comprehensive fusion feature set;
[0075] The model training module is based on a comprehensive fusion feature set and uses an adaptive moment estimation algorithm to adjust the network layer structure and activation function parameters, conduct multiple rounds of training, optimize weights and biases, and determine model parameters through validation set evaluation to generate a performance optimization model;
[0076] The model adjustment module analyzes the safety level distribution of food samples based on the performance optimization model, adjusts the judgment threshold and classification criteria, recalibrates the model, optimizes the pertinence and accuracy, and obtains the calibrated model;
[0077] The safety level determination module determines the safety level of food samples based on the calibrated model, maps the results into safe, potentially unsafe, and unsafe categories, and assigns safety levels based on the confidence level predicted by the model to obtain safety level determination results;
[0078] The real-time monitoring module sets monitoring parameters and alarm thresholds based on the safety level determination results, continuously monitors food safety status, adjusts monitoring strategies based on real-time data, and establishes a monitoring status log.
[0079] The fuzzy classification indicators include safety level threshold, absorption peak threshold, and wavelength range. The incremental update model includes adaptability to new data, dynamic weight adjustment mechanism, and real-time learning rate adjustment. The performance optimization model includes training round adjustment, activation function selection, and network structure optimization parameters. The calibrated model includes safety level judgment threshold, classification accuracy optimization parameters, and judgment standard refinement items. The safety level judgment results include food safety level, confidence index, and safety level classification basis. The monitoring status log includes monitoring timestamp, food safety incident records, and monitoring strategy adjustment history.
[0080] See also Figure 2 and Figure 3 ,The spectral acquisition module includes a scanning parameter setting submodule, a spectral data collection submodule, and a data integration submodule;
[0081] The scanning parameter setting submodule performs spectral scanning based on the target food sample, adjusts the scanning parameters of the infrared, ultraviolet, and Raman spectroscopy equipment, and covers the required wavelength range to generate the scanning parameter configuration;
[0082] The spectral data collection submodule collects spectral data of food samples from infrared, ultraviolet, and Raman spectroscopy equipment based on scanning parameter configuration, including wavelength, absorption peak, and intensity, to obtain a preliminary spectral data set;
[0083] The data integration submodule integrates and formats the data from the differential spectral equipment based on the preliminary spectral data set, verifies the consistency and integrity of the data, and obtains the spectral data set.
[0084] In the scanning parameter setting submodule, the genetic algorithm is used to optimize the scanning parameters based on the target food samples. The algorithm is implemented using Matlab. The initial population size is set to 50, the crossover rate is 0.8, and the mutation rate is 0.05. The scanning parameters of the infrared, ultraviolet, and Raman spectroscopy equipment are adjusted to cover the required wavelength range and generate the scanning parameter configuration.
[0085] In the spectral data collection submodule, based on the scanning parameter configuration, a direct data acquisition method is adopted. The acquisition script is written in Python language, and the serial port communication parameters are configured, including the baud rate is set to 115200, the data bit is 8, the stop bit is 1, and there is no parity bit. The spectral data of food samples, including wavelength, absorption peak and intensity, are collected from infrared, ultraviolet and Raman spectroscopy equipment to obtain a preliminary spectral data set.
[0086] In the data integration submodule, based on the preliminary spectral dataset, the JSON formatting method is adopted, and the Python json library is used for data integration and formatting to ensure the consistency of the data key-value pairs. The data verification algorithm is used to verify the data integrity, and the verification rules are set to data items that are not empty and the data types match to obtain the spectral dataset.
[0087] See also Figure 2 and Figure 4 ,The fuzzy logic analysis module includes a threshold setting submodule, a security level building submodule, and a data classification submodule;
[0088] The threshold setting submodule analyzes the spectral features, including the absorption peak and wavelength range, based on the spectral data set, and sets the threshold range of the difference security level to generate a threshold parameter table;
[0089] The security level construction submodule is based on the threshold parameter table. If the spectral characteristics are within the set range, they are classified into the corresponding security level, including safe, potentially unsafe and unsafe, and a fuzzy security set is constructed;
[0090] The data classification submodule is based on fuzzy security sets and uses fuzzy C-means clustering algorithm to classify the spectral data set. If the data characteristics meet the fuzzy security set of the security level, it is classified into the corresponding level and a fuzzy classification index is generated.
[0091] In the threshold setting submodule, based on the spectral data set, statistical analysis methods are adopted, and Python's SciPy library is used to perform characteristic analysis of absorption peaks and wavelength ranges. The mean plus or minus three times the standard deviation method is used to determine the threshold range of the difference safety level. The parameters are set as the mean and standard deviation of each feature item in the data set to generate a threshold parameter table.
[0092] In the security level construction submodule, based on the threshold parameter table, the decision tree algorithm is adopted to determine the security level using Python's sklearn library. The decision tree depth is set to 5, and the information gain is selected as entropy. If the spectral feature is within the set range, it is classified into the corresponding security level, including safe, potentially unsafe, and unsafe, to construct a fuzzy security set.
[0093] In the data classification submodule, based on the fuzzy security set, the fuzzy C-means clustering algorithm is used to classify the spectral data set using Python's skfuzzy library. The number of cluster centers is set to 3 and the matching threshold is set to 0.5. If the data features meet the fuzzy set of the security level, they are classified into the corresponding level to generate a fuzzy classification index.
[0094] Fuzzy C-means clustering algorithm, according to the formula:
[0095] ;
[0096] Calculate the membership of each data point to each cluster center and generate fuzzy classification indicators;
[0097] in, For the Data points for The membership degree of the cluster centers is For the data points, For the Cluster centers, is the number of cluster centers (set to 3), is the fuzzification parameter (value is 2), is a weight factor, which is adjusted according to the importance or influence of the data point. For data points The data sensitivity coefficient indicates the sensitivity or importance of the data point. is the clustering adaptability coefficient, which reflects the adaptability of the cluster center to the characteristics of the data set. is the environmental influencing factor, considering the impact of external environmental changes on the clustering process. is an index used to traverse all cluster centers.
[0098] Execution process:
[0099] S1: Set the number of cluster centers =3, fuzzy parameter 2, randomly select the initial cluster center ;
[0100] S2: Use the formula to calculate the degree of membership of the data point to the cluster center , considering the weight , Data Sensitivity , Clustering Adaptability and environmental factors ;
[0101] S3: According to renew , so that the cluster center moves closer to the data point set;
[0102] S4: Repeat steps 2 and 3 until the termination condition is met, such as the change in the cluster center is less than the set threshold. The data point affiliation is determined based on the final membership degree and the set threshold, and a fuzzy classification index is generated.
[0103] See also Figure 2 and Figure 5 ,The incremental learning module includes a data difference analysis submodule, a learning ,parameter adjustment submodule, and a model updating submodule;
[0104] The data difference analysis submodule compares the new and old spectral data sets based on fuzzy classification indicators, identifies changes in data features, determines the learning rate and data weight that need to be adjusted, and obtains data difference analysis results;
[0105] The learning parameter adjustment submodule calculates the numerical value of the feature change between the new and old data based on the data difference analysis results, adjusts the data input weight and rate, optimizes the response sensitivity of the model, and generates adjusted learning parameters;
[0106] The model update submodule dynamically updates the existing model based on the adjusted learning parameters, integrates the new parameters into the model through iterative training, and constructs an incremental update model.
[0107] In the data difference analysis submodule, based on the fuzzy classification index, a differential analysis algorithm is adopted, and Python's NumPy library is used to compare the new and old spectral data sets, identify the changes in data features, calculate the absolute value and relative change rate of feature differences, determine the learning rate and data weight that need to be adjusted, and generate data difference analysis results.
[0108] In the learning parameter adjustment submodule, based on the data difference analysis results, the gradient descent method is used to calculate the numerical changes in the characteristics of the new and old data using Python's SciPy library, and the data input weights and learning rates are adjusted. The parameter adjustment strategy adopts a dynamic adjustment mechanism, that is, the learning rate and weight are adjusted proportionally according to the size of the difference to generate the adjusted learning parameters.
[0109] In the model update submodule, based on the adjusted learning parameters, an online learning strategy is adopted to dynamically update the existing model using the TensorFlow framework. By setting small batch data iterative training, the size of each batch of data is 32, the number of iterations is dynamically adjusted according to the size of the data set, and the learning rate uses the adjusted parameters. The new parameters are integrated into the model to build an incremental update model.
[0110] See also Figure 2 and Figure 6 ,The deep feature fusion module includes the extraction parameter adjustment submodule, the ,feature merging submodule, and the feature set construction submodule;
[0111] The extraction parameter adjustment submodule adjusts the feature extraction parameters, including filter size and step size, for infrared, ultraviolet and Raman spectral data based on the incremental update model to obtain the adjusted extraction parameters;
[0112] The feature merging submodule merges the features from the difference spectrum data based on the adjusted extraction parameters, verifies the fusion effect of the difference spectrum features, and generates a merged feature set;
[0113] The feature set construction submodule organizes and formats the features based on the merged feature set, verifies the consistency of the data format, and establishes a comprehensive fusion feature set.
[0114] In the extraction parameter adjustment submodule, based on the incremental update model, an adaptive filter algorithm is used for infrared, ultraviolet and Raman spectral data. The feature extraction parameters are adjusted using Python's OpenCV library. The filter size is set to 3x3 and the step size is 1. Each type of spectral data is adjusted separately to ensure parameter optimization and obtain the adjusted extraction parameters.
[0115] In the feature merging submodule, based on the adjusted extraction parameters, the feature weighted fusion method is adopted, and the features from the difference spectral data are weightedly merged using Python's Numpy library. The weight ratio of each spectral data feature is set to 1:1:1 to ensure the equal contribution of each spectral data feature, verify the consistency of the difference spectral feature fusion, and generate the merged feature set.
[0116] In the feature set construction submodule, based on the merged feature set, the data formatting processing method is adopted to organize and format the features using Python's Pandas library, and the data format consistency verification is performed, including checking whether the data type is unified, ensuring the standardization of the feature value range, and establishing a comprehensive fusion feature set.
[0117] See also Figure 2 and Figure 7 ,The model training module includes a network structure design submodule, a training process execution submodule, and a performance evaluation submodule;
[0118] The network structure design submodule is based on the comprehensive fusion feature set, evaluates the feature set dimension, designs the network hierarchy, including the number of layers and neurons, matches the feature set requirements, and generates the network architecture configuration;
[0119] The training process execution submodule is configured according to the network architecture and uses an adaptive moment estimation algorithm to gradually adjust the network parameters through iterative training including forward propagation, loss calculation, back propagation, and weight and bias updates to generate a training network model;
[0120] The performance evaluation submodule uses the validation set to perform performance evaluation based on the network model in training, analyzes the performance of the model on unseen data, adjusts the network structure and parameters according to the evaluation results, and generates a performance optimization model.
[0121] In the network structure design submodule, based on the comprehensive fusion feature set, the dimensional analysis method is adopted, and the Python sklearn library is used to evaluate the feature set dimension and design the network hierarchy, including setting the number of layers to 3. The number of neurons in each layer is dynamically determined according to the feature set dimension to ensure that the feature set requirements are matched and the network architecture configuration is generated.
[0122] In the training process execution submodule, according to the network architecture configuration, the adaptive moment estimation algorithm (Adam) is used to perform iterative training through the TensorFlow framework, including forward propagation, loss calculation, back propagation, and weight and bias update. The learning rate is set to 0.001, the batch size is 32, and the number of iterations is 1000. The network parameters are gradually adjusted to generate a training network model.
[0123] Adaptive moment estimation algorithm, according to the formula:
[0124] ;
[0125] Calculate parameter updates and generate the network model in training;
[0126] in, is the parameter value of the current iteration step, is the learning rate, is the learning rate adjustment factor, is the corrected first-order moment estimate, is the first-order moment estimation adjustment coefficient, is the corrected second-order moment estimate, is the second-order moment estimation adjustment coefficient, is a numerical stability constant, It is a performance consideration parameter.
[0127] Execution process:
[0128] S1: Adjust based on model performance , to adapt to performance changes during training;
[0129] S2: Use and Adjust the effects of first- and second-order moment estimates to improve the model's sensitivity and stability to new data;
[0130] S3: Adjust based on the performance on the validation set , to optimize the generalization ability of the model, and use the formula to update the network parameters and perform the training process.
[0131] In the performance evaluation submodule, based on the network model in training, performance evaluation is performed using the validation set. The cross-validation method is used to analyze the performance of the model on unseen data using Python's sklearn library. The network structure and parameters are adjusted according to the evaluation results, such as increasing or decreasing the number of layers and adjusting the number of neurons, to generate a performance optimization model.
[0132] See also Figure 2 and Figure 8 ,The model adjustment module includes a security level analysis submodule, a threshold adjustment submodule, and a model calibration submodule;
[0133] The safety level analysis submodule analyzes the safety level distribution of food samples based on the performance optimization model, identifies the deviation of the model in determining the difference safety level, determines the range of model parameters that need to be adjusted, and obtains the safety level analysis record;
[0134] The threshold adjustment submodule adjusts the threshold used for classification in the judgment model according to the security level analysis records, optimizes the model's recognition performance for different security levels, and generates adjusted threshold parameters;
[0135] The model calibration submodule retrains and calibrates the performance optimization model based on the adjusted threshold parameters, optimizes the model's judgment performance at the security level, and obtains a calibrated model.
[0136] In the safety level analysis submodule, based on the performance optimization model, the decision tree analysis method is adopted, and Python's sklearn library is used to analyze the safety level distribution of food samples, identify the deviation of the model in the judgment of different safety levels, determine the range of model parameters that need to be adjusted, set the decision tree depth to 5, and select entropy as the information gain to obtain the safety level analysis record.
[0137] In the threshold adjustment submodule, according to the security level analysis records, an optimization algorithm is adopted to use Python's scipy library to adjust the threshold used for classification in the judgment model. The optimization goal is set to maximize the classification accuracy. The optimization method is sequential quadratic programming (SQP). The model's recognition performance of different security levels is optimized to generate adjusted threshold parameters.
[0138] In the model calibration submodule, based on the adjusted threshold parameters, an online learning strategy is adopted to retrain and calibrate the performance optimization model using the TensorFlow framework. Small batch data iterative training is set, with each batch of data size being 32. The number of iterations is dynamically adjusted according to the size of the data set to optimize the model's judgment performance at the security level and obtain a calibrated model.
[0139] See also Figure 2 and Fig. 9 ,The security level determination module includes a level determination submodule, a confidence assessment submodule, and a level mapping submodule;
[0140] The grade determination submodule predicts the safety grade of food samples based on the calibrated model, classifies them into safe, potentially unsafe and unsafe according to the model output, and generates preliminary safety grade determination data;
[0141] The confidence assessment submodule performs confidence assessment on the preliminary security level determination data, calculates the confidence of the model in the security level determination, matches the corresponding confidence score to the sample determination result, and obtains the confidence score record;
[0142] The level mapping submodule is based on the confidence score record, combines the security level determination result of each sample and the corresponding confidence score, maps it to the security level classification, and obtains the security level determination result.
[0143] In the grade determination submodule, based on the calibrated model, a multi-class classification algorithm is adopted, and Python's TensorFlow library is used to predict the safety level of food samples. The softmax function is set to process the model output and divide it into three categories: safe, potentially unsafe, and unsafe, to generate preliminary safety level determination data.
[0144] In the confidence assessment submodule, the confidence assessment is performed on the preliminary security level judgment data. The probability correction method is adopted, and the confidence of the security level judgment model is calculated using Python's sklearn library. The corresponding confidence score is matched to the sample judgment result to obtain the confidence score record.
[0145] In the level mapping submodule, based on the confidence score record, a threshold mapping strategy is adopted and implemented using Python programming. The security level judgment result of each sample and the corresponding confidence score are combined and mapped to the security level classification. The confidence threshold is set to 0.7. Judgment results above this value are considered valid, and the security level judgment result is obtained.
[0146] See also Figure 2 and Fig.10 ,The real-time monitoring module includes a monitoring parameter setting submodule, a food safety status monitoring submodule, and a monitoring strategy adjustment submodule;
[0147] The monitoring parameter setting submodule determines the parameters required to monitor the food safety status based on the safety level determination results, including the detection frequency, alarm threshold and safety level standard, sets the initial monitoring conditions, and establishes the monitoring parameter configuration;
[0148] The food safety status monitoring submodule monitors the food safety status based on the monitoring parameter configuration, including data collection and safety level assessment, and triggers alarms according to preset thresholds to generate real-time monitoring records;
[0149] The monitoring strategy adjustment submodule evaluates the monitoring effect and alarm response based on real-time monitoring records, adjusts the monitoring strategy, modifies monitoring parameters and thresholds, optimizes monitoring efficiency, and establishes a monitoring status log.
[0150] In the monitoring parameter setting submodule, based on the safety level determination results, the parameter optimization method is adopted, and Python's Pandas library is used to determine the parameters required to monitor the food safety status. The detection frequency is set to once an hour, the alarm threshold is lower than the safety level, and the safety level standards are safe, potentially unsafe, and unsafe, and the monitoring parameter configuration is established.
[0151] In the food safety status monitoring submodule, based on the monitoring parameter configuration, an event trigger mechanism is adopted and Python programming is used to monitor the food safety status, including the use of scheduled tasks for data collection and safety level assessment, and triggering alarms according to preset thresholds to generate real-time monitoring records.
[0152] In the monitoring strategy adjustment submodule, a feedback control strategy is adopted based on real-time monitoring records, and the Python matplotlib library is used to evaluate the monitoring effect and alarm response, adjust the monitoring strategy, modify the monitoring parameters and thresholds to a detection frequency of once every 30 minutes, adjust the alarm threshold to a safety level lower than or equal to the potential unsafe level, and establish a monitoring status log.
[0153] The above are only preferred embodiments of the present invention and are not intended to limit the present invention in other forms. Any technician familiar with the profession may use the technical contents disclosed above to change or modify them into equivalent embodiments with equivalent changes and apply them to other fields. However, any simple modification, equivalent change and modification made to the above embodiments based on the technical essence of the present invention without departing from the technical solution of the present invention still falls within the protection scope of the technical solution of the present invention.
Claims
1. A food safety detection system based on spectral analysis, characterized in that: The system comprises: The spectrum acquisition module performs spectral scanning based on the target food sample, collects data from infrared, ultraviolet, and Raman spectroscopy equipment, adjusts the scanning parameters to cover the wavelength range, and obtains the spectral data set; The fuzzy logic analysis module uses a fuzzy C-means clustering algorithm based on the spectral data set to set the threshold range of the absorption peak and wavelength, construct a fuzzy set reflecting the difference security level, including safe, potentially unsafe and unsafe, and classify the data according to the set threshold to generate a fuzzy classification index; The incremental learning module monitors the difference between new and old spectral data based on the fuzzy classification index, adjusts the learning rate and data weight, matches the new data features, and dynamically updates the model to construct an incremental update model; The deep feature fusion module adjusts the feature extraction parameters, including filter size and step size, for infrared, ultraviolet, and Raman spectral data based on the incremental update model, merges the differentiated spectral features, and establishes a comprehensive fusion feature set; The model training module uses an adaptive moment estimation algorithm based on the comprehensive fusion feature set, adjusts the network layer structure and activation function parameters, performs multiple rounds of training, optimizes weights and biases, and determines model parameters through validation set evaluation to generate a performance optimization model; The model adjustment module analyzes the safety level distribution of food samples based on the performance optimization model, adjusts the judgment threshold and classification standard, recalibrates the model, optimizes the pertinence and accuracy, and obtains a calibrated model; The safety level determination module determines the safety level of the food sample based on the calibrated model, maps the result to the categories of safe, potentially unsafe and unsafe, and assigns the safety level according to the confidence level predicted by the model to obtain the safety level determination result; The real-time monitoring module sets monitoring parameters and alarm thresholds according to the safety level determination result, continuously monitors the food safety status, adjusts the monitoring strategy according to the real-time data, and establishes a monitoring status log; The fuzzy logic analysis module includes a threshold setting submodule, a security level building submodule, and a data classification submodule; The threshold setting submodule analyzes the spectral features, including the absorption peak and the wavelength range, based on the spectral data set, and sets the threshold range of the difference security level to generate a threshold parameter table; The security level construction submodule is based on the threshold parameter table. If the spectral feature is within the set range, it is classified into the corresponding security level, including safe, potentially unsafe and unsafe, to construct a fuzzy security set; The data classification submodule classifies the spectral data set based on the fuzzy security set and adopts the fuzzy C-means clustering algorithm. If the data features meet the fuzzy security set of the security level, it is classified into the corresponding level and a fuzzy classification index is generated; The fuzzy C-means clustering algorithm is based on the formula: ; Calculate the membership of each data point to the cluster center and generate fuzzy classification indicators; in, For the Data points for The membership degree of the cluster centers is For the data points, For the Cluster centers, is the number of cluster centers, is the fuzzy parameter, is the weight factor, For data points The data sensitivity coefficient is is the clustering fitness coefficient, is the environmental impact factor, is the index; The model training module includes a network structure design submodule, a training process execution submodule, and a performance evaluation submodule; The network structure design submodule is based on the comprehensive fusion feature set, evaluates the feature set dimension, designs the network hierarchy, including the number of layers and neurons, matches the feature set requirements, and generates the network architecture configuration; The training process execution submodule is configured according to the network architecture, adopts an adaptive moment estimation algorithm, and gradually adjusts the network parameters through iterative training including forward propagation, loss calculation, back propagation, and weight and bias update to generate a training network model; The adaptive moment estimation algorithm is according to the formula: ; Calculate parameter updates and generate the network model in training; in, is the parameter value of the current iteration step, is the learning rate, is the learning rate adjustment factor, is the corrected first-order moment estimate, is the first-order moment estimation adjustment coefficient, is the corrected second-order moment estimate, is the second-order moment estimation adjustment coefficient, is a numerical stability constant, Parameters for performance considerations; The performance evaluation submodule performs performance evaluation based on the training network model using the validation set, analyzes the performance of the model on unseen data, adjusts the network structure and parameters according to the evaluation results, and generates a performance optimization model; The fuzzy classification indicators include security level threshold, absorption peak threshold, and wavelength range; the incremental update model includes new data adaptability, dynamic weight adjustment mechanism, and real-time learning rate adjustment; the performance optimization model includes training round adjustment, activation function selection, and network structure optimization parameters; the calibrated model includes security level judgment threshold, classification accuracy optimization parameters, and judgment standard refinement items; the safety level judgment result includes food safety level, confidence index, and safety level classification basis; the monitoring status log includes monitoring timestamp, food safety incident records, and monitoring strategy adjustment history.
2. The food safety detection system based on spectral analysis according to claim 1 is characterized in that: The spectrum acquisition module includes a scanning parameter setting submodule, a spectrum data collection submodule, and a data integration submodule; The scanning parameter setting submodule performs spectral scanning based on the target food sample, adjusts the scanning parameters of the infrared, ultraviolet and Raman spectroscopy equipment, and covers the required wavelength range to generate the scanning parameter configuration; The spectral data collection submodule collects spectral data of food samples from infrared, ultraviolet and Raman spectroscopy equipment based on scanning parameter configuration, including wavelength, absorption peak and intensity, to obtain a preliminary spectral data set; The data integration submodule integrates and formats the data from the difference spectrum device based on the preliminary spectrum data set, verifies the consistency and integrity of the data, and obtains the spectrum data set.
3. The food safety detection system based on spectral analysis according to claim 1 is characterized in that: The incremental learning module includes a data difference analysis submodule, a learning parameter adjustment submodule, and a model update submodule; The data difference analysis submodule compares the new and old spectral data sets based on the fuzzy classification index, identifies the changes in data features, determines the learning rate and data weight that need to be adjusted, and obtains the data difference analysis results; The learning parameter adjustment submodule calculates the value of the feature change of the new and old data based on the data difference analysis results, adjusts the data input weight and rate, optimizes the response sensitivity of the model, and generates adjusted learning parameters; The model update submodule dynamically updates the existing model based on the adjusted learning parameters, integrates the new parameters into the model through iterative training, and constructs an incremental update model.
4. The food safety detection system based on spectral analysis according to claim 1 is characterized in that: The deep feature fusion module includes an extraction parameter adjustment submodule, a feature merging submodule, and a feature set construction submodule; The extraction parameter adjustment submodule adjusts the feature extraction parameters, including the filter size and step size, for infrared, ultraviolet and Raman spectral data based on the incremental update model to obtain the adjusted extraction parameters; The feature merging submodule merges the features from the difference spectrum data based on the adjusted extraction parameters, verifies the fusion effect of the difference spectrum features, and generates a merged feature set; The feature set construction submodule organizes and formats the features based on the merged feature set, performs data format consistency verification, and establishes a comprehensive fusion feature set.
5. The food safety detection system based on spectral analysis according to claim 1 is characterized in that: The model adjustment module includes a security level analysis submodule, a threshold adjustment submodule, and a model calibration submodule; The safety level analysis submodule analyzes the safety level distribution of food samples based on the performance optimization model, identifies the deviation of the model in determining the difference safety level, determines the range of model parameters that need to be adjusted, and obtains a safety level analysis record; The threshold adjustment submodule adjusts the threshold used for classification in the determination model according to the security level analysis record, optimizes the model's recognition performance for different security levels, and generates adjusted threshold parameters; The model calibration submodule retrains and calibrates the performance optimization model based on the adjusted threshold parameters, optimizes the model's determination performance at the security level, and obtains a calibrated model.
6. The food safety detection system based on spectral analysis according to claim 1 is characterized in that: The security level determination module includes a level determination submodule, a confidence assessment submodule, and a level mapping submodule; The grade determination submodule predicts the safety grade of food samples based on the calibrated model, classifies them into safe, potentially unsafe and unsafe according to the model output, and generates preliminary safety grade determination data; The confidence assessment submodule performs confidence assessment on the preliminary security level determination data, calculates the confidence of the model for the security level determination, matches the sample determination result with a corresponding confidence score, and obtains a confidence score record; The level mapping submodule maps the confidence score record to the security level classification based on the security level determination result of each sample and the corresponding confidence score to obtain the security level determination result.
7. The food safety detection system based on spectral analysis according to claim 1, characterized in that: The real-time monitoring module includes a monitoring parameter setting submodule, a food safety status monitoring submodule, and a monitoring strategy adjustment submodule; The monitoring parameter setting submodule determines the parameters required for monitoring the food safety status based on the safety level determination result, including the detection frequency, alarm threshold and safety level standard, sets the initial monitoring conditions, and establishes the monitoring parameter configuration; The food safety status monitoring submodule monitors the food safety status based on the monitoring parameter configuration, including data collection and safety level assessment, and triggers an alarm according to a preset threshold to generate real-time monitoring records; The monitoring strategy adjustment submodule evaluates the monitoring effect and alarm response according to the real-time monitoring records, adjusts the monitoring strategy, modifies the monitoring parameters and thresholds, optimizes the monitoring efficiency, and establishes a monitoring status log.
