A pre-prepared dish quality detection device

By combining multimodal data collection and deep learning with blockchain technology, the problems of non-real-time quality detection and low efficiency of traceability system for pre-prepared dishes have been solved, realizing real-time detection and safe traceability of pre-prepared dish quality, thus improving product quality and safety.

CN120258609BActive Publication Date: 2026-04-07FANJIA FOOD (QINGDAO) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-03-26
Publication Date
2026-04-07

Smart Images

  • Figure CN120258609B_ABST
    Figure CN120258609B_ABST
Patent Text Reader

Abstract

This invention relates to the field of pre-prepared food testing and traceability technology, and discloses a pre-prepared food quality testing device and a safe traceability method. The device collects multi-faceted data of pre-prepared food in real time through a multi-modal data acquisition module, eliminates environmental interference through a dynamic calibration module, generates multi-dimensional quality indicators through a multi-source data fusion module, outputs quality grades and anomaly probabilities through a deep learning quality assessment model, and generates a unique traceability code by binding relevant information through a traceability data generation module. The safe traceability method encompasses steps such as multi-dimensional data acquisition and binding, distributed encrypted storage, dynamic consensus verification, lightweight traceability verification, and supply chain reverse tracing. This invention achieves accurate testing and safe traceability of pre-prepared food quality, effectively ensuring the safety of pre-prepared food quality, enhancing consumer trust, and possessing intelligent optimization and adaptive learning capabilities to improve overall system performance and operating efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of pre-prepared food detection and traceability, in particular to a pre-prepared food quality detection device. BACKGROUND

[0002] In recent years, the demand for pre-prepared food has rapidly grown in the market. It simplifies the cooking process and saves consumers' time, and is popular in both the catering industry and home kitchens. However, pre-prepared food faces many quality and safety problems during production, storage, and transportation, which seriously hinders the healthy development of the industry.

[0003] From the quality aspect, the quality of raw materials for pre-prepared food is uneven. In the production process, unlike single food materials, some enterprises choose substandard food materials, such as not fresh meat and vegetables, to reduce costs. The quality defects of these raw materials will directly affect the final quality of pre-prepared food. At the same time, the difference in processing technology also has a huge impact on the quality of pre-prepared food. Different processing temperatures, time control, seasoning, and packaging methods will lead to differences in the multi-dimensional evaluation of pre-prepared food in terms of taste, nutritional composition, and process-related retention. For example, excessive heating can destroy the nutritional ingredients of the food, and improper packaging can accelerate the deterioration of the food.

[0004] During storage and transportation, environmental factors are the key to affecting the quality of pre-prepared food. Changes in temperature and humidity have a significant impact on the shelf life and quality of pre-prepared food. High temperatures can accelerate the reproduction of microorganisms, leading to food spoilage; high humidity can cause mold growth, and low humidity can cause food to dry out, affecting taste. Moreover, there is currently a lack of effective real-time monitoring means to detect changes in the quality of pre-prepared food during storage and transportation. When consumers discover the problem, it has often already caused losses.

[0005] From the perspective of safety traceability, the existing traceability system has many shortcomings. Traditional traceability methods mainly rely on manual recording and paper labels, which are not only inefficient but also prone to recording errors and incomplete information. In the case of many supply chain links, if information is missing or incorrect at one link, it will disrupt the traceability chain and make it impossible to accurately track the source and flow of products.

[0006] In addition, the existing traceability system lacks an effective data sharing mechanism, and the data between each link is isolated, which cannot realize real-time sharing and collaborative processing of information. This makes it difficult for regulatory authorities to comprehensively supervise the entire supply chain, and consumers also have difficulty obtaining accurate and complete product information. For example, when consumers purchase prepared dishes, they cannot obtain key information such as the source of raw materials used in the production process, the processing technology, and the temperature and humidity changes during transportation, and cannot effectively evaluate the quality and safety of the product.

[0007] In terms of data security, with the development of information technology, traceability data is at risk of being tampered with and leaked. If the traceability data is maliciously tampered with, it will mislead consumers and regulatory authorities, and seriously affect the market order and consumer rights and interests. Therefore, it is urgent to develop a technology and device that can comprehensively and accurately detect the quality of prepared dishes and achieve efficient and secure traceability. SUMMARY

[0008] The purpose of the present application is to provide a prepared dish quality detection device to solve the problems raised in the background art.

[0009] To achieve the above-mentioned purpose, the present application provides the following technical solution: a prepared dish quality detection device, the device comprising:

[0010] A multi-modal data acquisition module comprising a hyperspectral imaging sensor, a gas sensor array, a weight sensor, and a temperature and humidity sensor, for real-time acquisition of physical characteristics, chemical composition, weight change, and environmental data of prepared dishes;

[0011] A dynamic calibration module comprising a reference sample library and a calibration algorithm, for dynamically adjusting the sensor output according to the environmental parameters and eliminating environmental interference;

[0012] A multi-source data fusion module using a multi-source data fusion algorithm based on Kalman filtering to perform temporal and spatial alignment and feature fusion of real-time data from different sensors, generating multi-dimensional quality indicators;

[0013] A deep learning quality evaluation model using a hybrid architecture combining convolutional neural networks and long short-term memory networks, inputting the multi-dimensional quality indicators, and outputting quality grades and abnormal probabilities;

[0014] A traceability data generation module for binding the quality detection results with production batches, processing parameters, and logistics information to generate a unique traceability code.

[0015] Preferably, in the multi-modal data acquisition module:

[0016] The hyperspectral imaging sensor covers the visible light to near-infrared band with a resolution not less than 5nm, for detecting surface microbial contamination and ingredient distribution;

[0017] The gas sensor array includes metal oxide semiconductor sensors and electrochemical sensors to detect volatile organic compounds and hydrogen sulfide concentrations;

[0018] The weight sensor has an accuracy of 0.1 gram and can monitor the integrity of the package in real time;

[0019] The temperature and humidity sensor is integrated in a sealed cavity and has a sampling frequency of ≥10 Hz.

[0020] Preferably, the specific implementation of the multi-source data fusion module includes:

[0021] A space-time alignment layer is constructed to match the timestamps of sensor data using a sliding window mechanism and unify the spatial reference through coordinate transformation;

[0022] A feature extraction layer is designed to extract spectral features of hyperspectral images, time series features of gas concentrations, and trend features of weight changes, respectively;

[0023] A fusion decision layer is implemented to calculate the weight of each feature through a Bayesian network and output the fused quality index vector.

[0024] Preferably, in the dynamic calibration module:

[0025] The reference sample library contains standard sample data under different temperature and humidity conditions;

[0026] The calibration algorithm is an adaptive compensation model based on the least squares method, and its formula is:

[0027]

[0028] where, is the output of the calibrated sensor, is the original data, and are the real-time temperature and humidity deviations, and are the compensation coefficients obtained through offline calibration.

[0029] Preferably, the training process of the deep learning quality evaluation model includes:

[0030] Data collection: Collect 10,000 labeled pre-prepared food sample data, covering normal products, microbial contamination, oxidation deterioration, and physical damage;

[0031] Feature engineering: Perform principal component analysis dimensionality reduction on hyperspectral images and extract the first 20 principal components; calculate the moving average and first-order difference of gas data;

[0032] Model architecture: ResNet-50 is used to extract image features, LSTM network is used to process time series data, and fully connected layer is used to output classification results.

[0033] Loss function: Focal Loss is used to solve the class imbalance problem, and a temperature parameter is introduced to adjust the prediction confidence.

[0034] Preferably, the device further comprises an anomaly detection module, which is implemented as follows:

[0035] An unsupervised detection algorithm based on Isolation Forest is constructed, and the multi-dimensional quality indicators are input to calculate the anomaly score.

[0036] A dynamic threshold adjustment mechanism is set up to adaptively update the decision threshold according to the KL divergence of historical data distribution.

[0037] When the anomaly score exceeds the threshold, an alarm is triggered and the type of anomaly is recorded in the traceability database.

[0038] Preferably, the specific steps of the traceability data generation module include:

[0039] The production batch information is encoded as a 32-bit hash value.

[0040] The quality detection results and the hash value are bound through a blockchain smart contract to generate tamper-proof traceability records.

[0041] A lightweight Merkle tree structure is used to store the logistics node data, which supports fast verification.

[0042] Preferably, the device further comprises an adaptive learning module, which is implemented as follows:

[0043] A reinforcement learning framework is used, with the quality detection error as the reward signal.

[0044] A policy network is designed to dynamically adjust the hyperparameters of the deep learning model, including learning rate and batch size.

[0045] The sensor sampling frequency is optimized through the Q-learning algorithm to balance the accuracy and energy consumption.

[0046] Preferably, the present application further comprises a pre-prepared food safety traceability method, which comprises the following steps:

[0047] Step S1: Multi-dimensional data acquisition and binding, real-time acquisition of hyperspectral characteristics, gas concentration, weight fluctuation and environmental parameters of pre-prepared food through multi-modal data acquisition module, association of production batch code, processing equipment log and cold chain logistics track, generation of structured traceability data package.

[0048] Step S2: Distributed encrypted storage, using a distributed storage network based on the IPFS protocol to fragment the traceability data packet and store it to multiple nodes, and write the storage location hash value into the blockchain smart contract;

[0049] Step S3: Dynamic consensus verification. An improved practical Byzantine fault-tolerant algorithm is used to verify the consistency of cross-node data. A dynamic weight mechanism is introduced to optimize consensus efficiency and generate an immutable block hash chain.

[0050] Step S4: Lightweight traceability verification. Consumers scan the QR code on the packaging to trigger a zero-knowledge proof protocol, which verifies data integrity based on a Merkle tree path without exposing original sensitive information.

[0051] Step S5: Supply chain reverse tracing. When a quality anomaly is detected, a supply chain topology network is constructed using a graph database. High-risk nodes are located based on the PageRank algorithm, and a multi-dimensional traceability report containing handling suggestions is generated.

[0052] Compared with the prior art, the beneficial effects of the present invention are:

[0053] This invention integrates a hyperspectral imaging sensor, a gas sensor array, a weight sensor, and a temperature and humidity sensor into a multimodal data acquisition module, enabling real-time acquisition of physical characteristics, chemical composition, weight changes, and environmental data for pre-prepared dishes. The hyperspectral imaging sensor accurately detects surface microbial contamination and component distribution; the gas sensor array detects volatile organic compounds and hydrogen sulfide concentrations; the weight sensor monitors packaging integrity in real time; and the temperature and humidity sensor provides environmental parameters. This multi-dimensional data acquisition provides a rich and accurate data foundation for quality inspection.

[0054] The dynamic calibration module dynamically adjusts the sensor output based on environmental parameters, using a reference sample library and calibration algorithm. Through an adaptive compensation model based on the least squares method, it effectively eliminates interference from environmental factors such as temperature and humidity on sensor data, ensuring the accuracy of the collected data and thus improving the reliability of quality inspection. Under different temperature and humidity conditions, this module can perform real-time calibration of the sensor data, making the test results more accurately reflect the quality of the prepared dishes.

[0055] The multi-source data fusion module employs a Kalman filter-based algorithm to perform spatiotemporal alignment and feature fusion of real-time data from different sensors, generating multi-dimensional quality indicators. Simultaneously, the deep learning quality assessment model uses a hybrid architecture combining convolutional neural networks and long short-term memory networks to analyze the multi-dimensional quality indicators, accurately outputting quality grades and anomaly probabilities. Compared to traditional quality assessment methods, this data fusion and deep learning approach can more comprehensively and accurately evaluate the quality of prepared dishes and promptly identify potential quality problems.

[0056] The traceability data generation module binds quality inspection results with production batches, processing parameters, and logistics information to generate unique traceability codes. Utilizing blockchain smart contracts and a lightweight Merkle tree structure, it ensures the immutability of traceability records and rapid verification of logistics node data. Consumers can scan the packaging QR code for lightweight traceability verification based on a zero-knowledge proof protocol, obtaining relevant product information without exposing original sensitive information. Regarding reverse supply chain tracing, a supply chain topology network is constructed using a graph database. High-risk nodes are located using the PageRank algorithm, generating multi-dimensional traceability reports and providing handling suggestions, effectively ensuring the quality and safety of pre-prepared meals and enhancing consumer trust.

[0057] The device also includes an anomaly detection module and an adaptive learning module. The anomaly detection module, based on the Isolation Forest algorithm and a dynamic threshold adjustment mechanism, can promptly detect and alarm on quality anomalies in pre-prepared dishes. The adaptive learning module employs a reinforcement learning framework, using quality detection errors as reward signals to dynamically adjust the hyperparameters of the deep learning model and the sensor sampling frequency. This optimizes energy consumption while ensuring detection accuracy, achieving intelligent and adaptive operation of the device and improving the overall system performance and operational efficiency. Attached Figure Description

[0058] Figure 1 This is a schematic diagram illustrating the working principle of the pre-prepared food quality testing device described in this invention.

[0059] Figure 2 A flowchart illustrating the workflow of the multi-source data fusion module;

[0060] Figure 3 A flowchart illustrating the training process for a deep learning quality assessment model.

[0061] Figure 4 This is a flowchart of the adaptive learning module. Detailed Implementation

[0062] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0063] Please see Figures 1-4 This invention provides a pre-prepared food quality testing device and a safety traceability method. The pre-prepared food quality testing device mainly consists of a multimodal data acquisition module, a dynamic calibration module, a multi-source data fusion module, a deep learning quality assessment model, and a traceability data generation module.

[0064] The multimodal data acquisition module integrates a hyperspectral imaging sensor, a gas sensor array, a weight sensor, and a temperature and humidity sensor to collect real-time data on the physical characteristics, chemical composition, weight changes, and environmental conditions of the prepared food. These sensors work together to acquire information about the prepared food from multiple dimensions, providing a data foundation for subsequent testing and evaluation.

[0065] The dynamic calibration module utilizes a reference sample library and calibration algorithms to dynamically adjust the sensor output based on environmental parameters, effectively eliminating environmental interference and ensuring the accuracy of the sensor's data acquisition. Environmental factors such as changes in temperature and humidity may affect the sensor's measurement accuracy; the dynamic calibration module can correct the sensor data in real time.

[0066] The multi-source data fusion module employs a Kalman filter-based multi-source data fusion algorithm to perform spatiotemporal alignment and feature fusion of real-time data from different sensors, generating multi-dimensional quality indicators. Because data collected by different sensors differs in time and space, this module processes the data using specific methods to integrate multi-dimensional indicators that more comprehensively reflect the quality of pre-prepared dishes.

[0067] The deep learning-based quality assessment model employs a hybrid architecture combining convolutional neural networks and long short-term memory networks. It takes multi-dimensional quality indicators as input and outputs the quality grade and probability of anomalies for prepared dishes. Trained on a large amount of data, this model can accurately assess the quality of prepared dishes and promptly identify potential quality problems.

[0068] The traceability data generation module links quality inspection results with production batches, processing parameters, and logistics information to generate a unique traceability code. This ensures that each pre-prepared meal has its own corresponding traceability information, facilitating tracking and management in subsequent stages.

[0069] The present invention will be further described below with reference to Examples 1 to 5:

[0070] Example 1:

[0071] This embodiment details the specific structure and working principle of the multimodal data acquisition module, which is used to accurately acquire real-time data on various aspects of pre-prepared dishes, providing a reliable basis for subsequent testing and evaluation.

[0072] The hyperspectral imaging sensor covers the visible to near-infrared band with a resolution of at least 5 nm. In practical applications, its working principle utilizes the differences in absorption and reflection characteristics of different substances at different wavelengths of light to image and detect the surface of pre-prepared food. For example, regarding surface microbial contamination, microorganisms alter the material composition of the pre-prepared food surface during their growth, and these changes will exhibit unique spectral characteristics in the hyperspectral image. By analyzing these characteristics, it is possible to determine whether microbial contamination exists on the surface of the pre-prepared food and the degree of contamination. Simultaneously, the sensor can also detect the distribution of components in pre-prepared food, such as the uniformity of distribution of different nutrients, providing important physical characteristic data for quality assessment.

[0073] The gas sensor array consists of a metal-oxide-semiconductor (MODS) sensor and an electrochemical sensor. The MODS sensor detects volatile organic compounds (VOCs) to reflect the freshness and spoilage status of prepared dishes. When prepared dishes spoil, various VOCs are produced, and different types of VOCs represent different causes of spoilage; for example, lipid oxidation produces specific volatile aldehydes. The electrochemical sensor is mainly used to detect hydrogen sulfide concentration. Hydrogen sulfide is usually produced by protein decomposition, and its elevated concentration indicates that the prepared dishes may be contaminated by microorganisms, and the proteins have spoiled. Through the synergistic operation of these two sensors, the gas composition produced by prepared dishes can be comprehensively detected, reflecting changes in the quality of prepared dishes from a chemical composition perspective.

[0074] The weight sensor achieves an accuracy of 0.1 grams, monitoring packaging integrity in real time. If the packaging of pre-prepared meals is damaged during the packaging process, it may cause weight changes. The weight sensor continuously monitors the weight of the pre-prepared meals, and once abnormal weight fluctuations are detected, a preliminary judgment can be made regarding packaging problems. For example, if the weight suddenly decreases during storage and transportation, it may indicate packaging leakage, allowing outside air to enter or internal moisture to dissipate. This can affect the quality and shelf life of the pre-prepared meals, and the weight sensor can promptly detect such potential problems.

[0075] The temperature and humidity sensor is integrated into the sealed cavity, with a sampling frequency of ≥10Hz. The temperature and humidity of the environment in which pre-prepared food is stored have a significant impact on its quality. Excessively high temperatures accelerate microbial growth and chemical reactions, leading to spoilage; excessively high humidity may induce microbial proliferation, while excessively low humidity may cause the food to dry out. The temperature and humidity sensor collects real-time temperature and humidity data within the sealed cavity at a high sampling frequency, providing accurate environmental parameters for the dynamic calibration module to calibrate data from other sensors. It also reflects the real-time status of the pre-prepared food storage environment, providing environmental data support for quality assessment.

[0076] Example 2:

[0077] The role of the multi-source data fusion module is to effectively integrate different types of data acquired by the multimodal data acquisition module to generate comprehensive and accurate multidimensional quality indicators, thereby improving the reliability of quality inspection.

[0078] When constructing the spatiotemporal alignment layer, a sliding window mechanism is used to match the timestamps of sensor data. Different sensors may collect data at different frequencies and times; the sliding window mechanism can filter and match data at specific time intervals. For example, a hyperspectral imaging sensor might acquire an image frame at regular intervals, while gas and weight sensors output data in real time. Through the sliding window, data is processed at specific time steps (e.g., 1 second), associating data from different sensors within the same time window and adding a unified timestamp. Simultaneously, a unified spatial reference is achieved through coordinate transformation. Since different sensors may detect pre-prepared food at different positions and angles, the spatial coordinates of the data need to be transformed to ensure processing within the same spatial coordinate system, guaranteeing spatiotemporal consistency.

[0079] Feature extraction layers are designed to extract features for different types of data. For hyperspectral images, spectral features are extracted using spectral analysis techniques. For example, parameters such as reflectance and absorptivity in different bands are calculated, which can reflect the content and distribution of various components in the prepared food. For gas concentration data, time series analysis methods are used to extract time series features, such as calculating the trend and peak values ​​of gas concentration changes over a period of time. For weight change data, trend analysis is used to extract trend features to determine whether the weight is gradually increasing, decreasing, or remaining stable.

[0080] The fusion decision layer calculates the weights of each feature using a Bayesian network. A Bayesian network is a graphical model based on probabilistic reasoning that calculates the weight of each feature based on the correlation between different features and their influence on quality indicators. For example, when determining whether prepared food has spoiled, the gas concentration feature may have a greater impact on spoilage judgment than the weight change feature; therefore, the Bayesian network would assign a higher weight to the gas concentration feature. In this way, the features are weighted and fused according to their importance, outputting a fused quality indicator vector. This vector comprehensively reflects the quality status of prepared food across multiple dimensions, providing more accurate data support for subsequent quality assessments.

[0081] Example 3:

[0082] The function of the dynamic calibration module is to calibrate the sensor data in real time according to environmental changes, reduce the interference of environmental factors on the detection results, and ensure the accuracy of the detection data.

[0083] The reference sample library contains standard sample data under different temperature and humidity conditions. When establishing the reference sample library, a large number of pre-prepared food samples are prepared, and high-precision detection equipment is used to acquire various sensor data of these samples under different temperature and humidity combinations. This data is then stored as standard sample data in the reference sample library. For example, multiple environmental chambers with different temperatures (e.g., 5℃, 10℃, 15℃, etc.) and humidity levels (e.g., 40%RH, 60%RH, 80%RH, etc.) are set up. Pre-prepared food samples are placed in these chambers, and hyperspectral image data, gas concentration data, weight data, etc., of each sample under different environmental conditions are collected to construct the reference sample library.

[0084] The calibration algorithm employs an adaptive compensation model based on the least squares method, with the following formula:

[0085]

[0086] in, For the sensor output after calibration, This is the original data. and These are the real-time temperature and humidity deviations, and These are the compensation coefficients obtained through offline calibration. In practical applications, the temperature and humidity sensor collects ambient temperature and humidity data in real time and calculates the real-time temperature and humidity deviation. and . and The compensation coefficients are obtained through offline calibration. They are calculated using data from a reference sample library and the least squares method, before the device leaves the factory or during periodic calibration. This is done when the sensor acquires raw data. Then, the calibrated sensor output is calculated according to the above formula. For example, when an increase in temperature causes the gas sensor output to be too high, a calibration algorithm, combined with real-time temperature deviation and compensation coefficient, corrects the original data to obtain more accurate gas concentration data, effectively eliminating the impact of temperature and humidity changes on the sensor's measurement accuracy.

[0087] Example 4:

[0088] This embodiment details the training process and practical application of a deep learning quality assessment model. Its function is to use deep learning technology to accurately assess the quality of pre-prepared dishes, output quality grades and anomaly probabilities, and provide strong support for the quality monitoring of pre-prepared dishes.

[0089] During the data collection phase, 10,000 sets of labeled pre-prepared food samples were collected, covering four categories: normal products, microbial contamination, oxidative spoilage, and physical damage. In practice, these sample data were obtained through multiple methods. Normally produced pre-prepared food samples were collected from the production line as normal product data; microbial contamination samples were simulated by artificial inoculation with microorganisms; oxidative spoilage samples were obtained by exposing pre-prepared food to air for a certain period to induce oxidative spoilage; and physically damaged samples were collected by intentionally causing physical damage to the pre-prepared food, such as squeezing or scratching. Each sample was meticulously labeled, and its category was recorded.

[0090] In the feature engineering phase, principal component analysis (PCA) is performed on the hyperspectral images to reduce dimensionality, extracting the top 20 principal components. Hyperspectral images contain a large amount of band information, resulting in high data dimensionality. Direct processing would increase computational load and potentially introduce information redundancy. PCA transforms the original data into a set of uncorrelated principal components through linear transformation, preserving most of the information in the original data. After PCA processing, the top 20 principal components are extracted, reducing data dimensionality while retaining key spectral features. For gas data, moving averages and first differences are calculated. Moving averages smooth fluctuations in gas concentration data, more clearly reflecting data trends; first differences highlight the rate of change in data, more sensitively capturing changes in gas concentration and providing more valuable features for the model.

[0091] The model architecture employs ResNet-50 to extract image features, an LSTM network to process time-series data, and a fully connected layer to output classification results. ResNet-50 is a classic convolutional neural network with strong image feature extraction capabilities, automatically learning complex features in hyperspectral images. LSTM networks excel at processing time-series data, effectively capturing long-term and short-term dependencies in data such as gas concentration and weight changes over time. The image features extracted by ResNet-50 and the time-series features processed by the LSTM network are fused and input into the fully connected layer for classification, outputting the quality grade and anomaly probability of the prepared dish.

[0092] The loss function uses Focal Loss to address class imbalance and introduces a temperature parameter to adjust prediction confidence. In real-world sample data, the number of samples in different classes can vary significantly; for example, the number of normal samples may be much greater than the number of samples contaminated with microorganisms. This can cause the model to favor the more numerous class during training. Focal Loss addresses class imbalance by assigning different weights to samples from different classes, making the model pay more attention to the less numerous class. Simultaneously, the temperature parameter adjusts the confidence of the prediction results. A larger temperature parameter results in a more uniform distribution of predictions, increasing model uncertainty; a smaller temperature parameter concentrates predictions in a particular class, increasing model confidence. By appropriately adjusting the temperature parameter, the model's predictive performance can be optimized.

[0093] Example 5:

[0094] The specific steps of the traceability data generation module are as follows: Production batch information is encoded into a 32-bit hash value. A hash algorithm (such as SHA-256) is used to encrypt the production batch information, generating a unique 32-bit hash value, which serves as the identifier for the production batch. Quality inspection results are bound to the hash value through a blockchain smart contract, generating an immutable traceability record. Blockchain technology features decentralization and immutability, while smart contracts are automatically executed programs running on the blockchain. In this invention, the smart contract associates quality inspection results (including quality grade, anomaly probability, etc.) with the production batch hash value. Once recorded on the blockchain, the data cannot be tampered with. A lightweight Merkle tree structure is used to store logistics node data, supporting rapid verification. A Merkle tree is a binary tree structure that hashes logistics node data (such as transportation time, transportation location, temperature changes, etc.) according to certain rules to construct a Merkle tree. When verifying the integrity of logistics data, only the root hash value of the Merkle tree and related path hash values ​​need to be verified, without verifying all data, greatly improving verification efficiency.

[0095] The anomaly detection module constructs an unsupervised detection algorithm based on Isolation Forest. It takes multidimensional quality indicators as input and calculates anomaly scores. The Isolation Forest algorithm constructs multiple isolated trees, using the path length of each sample within the tree as the anomaly score. Normal samples are typically located in dense regions of the data distribution, with shorter path lengths; while anomalous samples are located in sparse regions, with longer path lengths. A dynamic threshold adjustment mechanism is implemented, adaptively updating the judgment threshold based on the KL divergence of historical data distributions. KL divergence measures the difference between two probability distributions; by calculating the KL divergence between the current and historical data distributions, changes in the data are determined. If the KL divergence exceeds a certain threshold, it indicates a significant change in the data distribution, and the anomaly detection judgment threshold is adjusted accordingly. When the anomaly score exceeds the threshold, an alarm is triggered, and the anomaly type is recorded in the traceability database for subsequent tracking and analysis of anomalies.

[0096] The adaptive learning module employs a reinforcement learning framework, using the quality detection error as the reward signal. In reinforcement learning, the agent (which can be considered the entire detection system in this invention) interacts with the environment (pre-prepared food samples and their detection process) and adjusts its behavior based on the reward signals from the environment. A policy network is designed to dynamically adjust the hyperparameters of the deep learning model, including the learning rate and batch size. The learning rate affects the convergence speed of model training, while the batch size affects the stability and efficiency of model training. The policy network dynamically adjusts these hyperparameters based on the quality detection error using an optimization algorithm (such as the Adam algorithm), allowing the model to continuously optimize during training. The sensor sampling frequency is optimized using a Q-learning algorithm to achieve a balance between accuracy and energy consumption. The Q-learning algorithm is a classic reinforcement learning algorithm that continuously tries different sampling frequencies, calculates the Q-value based on the quality detection error and energy consumption, and selects the optimal sampling frequency, reducing sensor energy consumption while ensuring detection accuracy.

[0097] This invention also includes a method for tracing the safety of pre-prepared food, the method comprising:

[0098] Step S1: Multi-dimensional data acquisition and binding. The hyperspectral characteristics, gas concentration, weight fluctuation and environmental parameters of the pre-cooked food are obtained in real time through the multi-modal data acquisition module. At the same time, the production batch code, processing equipment log and cold chain logistics trajectory are associated to generate a structured traceability data package.

[0099] Step S2: Distributed encrypted storage, using a distributed storage network based on the IPFS protocol to fragment the traceability data packet and store it to multiple nodes, and write the storage location hash value into the blockchain smart contract;

[0100] Step S3: Dynamic consensus verification. An improved practical Byzantine fault-tolerant algorithm is used to verify the consistency of cross-node data. A dynamic weight mechanism is introduced to optimize consensus efficiency and generate an immutable block hash chain.

[0101] Step S4: Lightweight traceability verification. Consumers scan the QR code on the packaging to trigger a zero-knowledge proof protocol, which verifies data integrity based on a Merkle tree path without exposing original sensitive information.

[0102] Step S5: Supply chain reverse tracing. When a quality anomaly is detected, a supply chain topology network is constructed using a graph database. High-risk nodes are located based on the PageRank algorithm, and a multi-dimensional traceability report containing handling suggestions is generated.

[0103] The implementation of this method is the same as described in the above embodiments, and will not be repeated in the specification.

[0104] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus.

[0105] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

Claims

1. A pre-prepared food quality testing device, characterized in that, include: The multimodal data acquisition module includes a hyperspectral imaging sensor, a gas sensor array, a weight sensor, and a temperature and humidity sensor, which are used to collect physical characteristics, chemical composition, weight changes, and environmental data of pre-cooked dishes in real time. The dynamic calibration module, including a reference sample library and calibration algorithm, is used to dynamically adjust the sensor output based on environmental parameters and eliminate environmental interference. The multi-source data fusion module uses a Kalman filter-based multi-source data fusion algorithm to perform spatiotemporal alignment and feature fusion of real-time data from different sensors to generate multi-dimensional quality indicators. The deep learning quality assessment model adopts a hybrid architecture combining convolutional neural networks and long short-term memory networks. It takes the multidimensional quality indicators as input and outputs the quality level and anomaly probability. The traceability data generation module is used to bind quality inspection results with production batches, processing parameters and logistics information to generate a unique traceability code; It also includes an adaptive learning module, which is implemented as follows: A reinforcement learning framework is adopted, with quality detection error as the reward signal; The design strategy network dynamically adjusts the hyperparameters of the deep learning quality evaluation model, including the learning rate and batch size; By optimizing the sensor sampling frequency using the Q-learning algorithm, a balance is achieved between accuracy and energy consumption; The training process of the deep learning quality assessment model includes: Data collection: Collected data from 10,000 labeled pre-prepared food samples, covering four categories: normal products, microbial contamination, oxidative deterioration, and physical damage; Feature engineering: Principal component analysis was performed on hyperspectral images to reduce dimensionality and extract the top 20 principal components; moving average and first difference were calculated for gas data; Model architecture: ResNet-50 is used to extract image features, LSTM network is used to process time series data, and fully connected layers are used to output classification results; Loss function: Focal Loss is used to address the class imbalance problem, and a temperature parameter is introduced to adjust the prediction confidence.

2. The pre-prepared food quality testing device according to claim 1, characterized in that, In the multimodal data acquisition module: The hyperspectral imaging sensor covers the visible to near-infrared band with a resolution of not less than 5 nm and is used to detect surface microbial contamination and component distribution. The gas sensor array includes a metal oxide semiconductor sensor and an electrochemical sensor to detect the concentration of volatile organic compounds and hydrogen sulfide. The weight sensor has an accuracy of 0.1 grams and monitors the integrity of the packaging in real time. The temperature and humidity sensor is integrated into a sealed cavity and has a sampling frequency of ≥10Hz.

3. The pre-prepared food quality testing device according to claim 1, characterized in that, The specific implementation of the multi-source data fusion module includes: A spatiotemporal alignment layer is constructed, a sliding window mechanism is used to match timestamps of sensor data, and a spatial benchmark is unified through coordinate transformation. Design a feature extraction layer to extract spectral features, time-series features of gas concentration, and trend features of weight change from the hyperspectral image; A fusion decision layer is implemented, which calculates the weights of each feature through a Bayesian network and outputs the fused quality index vector.

4. The pre-prepared food quality testing device according to claim 1, characterized in that, In the dynamic calibration module: The reference sample library contains standard sample data under different temperature and humidity conditions; The calibration algorithm is an adaptive compensation model based on the least squares method, and its formula is: in, For the sensor output after calibration, This is the original data. and These are the real-time temperature and humidity deviations, and These are the compensation coefficients obtained through offline calibration.

5. The pre-prepared food quality testing device according to claim 1, characterized in that, It also includes an anomaly detection module, which is implemented as follows: Construct an unsupervised detection algorithm based on isolated forests, input the multidimensional quality index, and calculate the anomaly score; A dynamic threshold adjustment mechanism is set up to adaptively update the judgment threshold based on the KL divergence of historical data distribution; When the abnormal score exceeds the threshold, an alarm is triggered and the abnormal type is recorded in the source tracing database.

6. The pre-prepared food quality testing device according to claim 1, characterized in that, The specific steps of the source tracing data generation module include: The production batch information is encoded as a 32-bit hash value; By binding quality inspection results with hash values ​​through blockchain smart contracts, an immutable traceability record is generated; It uses a lightweight Merkle tree structure to store logistics node data, supporting rapid verification.