SERS (Surface Enhanced Raman Scattering) spectrum cloud deep learning platform for food safety detection
Through the deep learning platform parameter synchronization and multimodal fusion model at the edge end and the cloud, the problem of real-time and accuracy in the SERS detection system is solved, and the rapid response and high-precision analysis of food safety inspection are achieved, and the system efficiency and credibility of detection results are improved.
Patent Information
- Application Number
- CN202510515147.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-23
- Publication Date
- 2025-08-08
AI Technical Summary
The existing SERS-based food safety testing system is difficult to take into account both real-time and accuracy. The computing power of edge devices is limited, the cloud analysis efficiency is low, the model generalization ability is weak, and the data transmission value evaluation is missing, making it difficult to dynamically adapt to new pollutants and environmental changes.
The parameter bidirectional synchronization mechanism of the edge-end intelligent acquisition module and the cloud-end deep learning platform is adopted, and combined with the multimodal fusion classification model, dynamic collaborative management engine and blockchain data proof-keeping module, it realizes local rapid classification of spectral data and high-precision review in the cloud. Data transmission is optimized through adaptive filtering, differential coding and high-compression ratio algorithms, dynamically updates model parameters, monitors the device status in real time and generates a trusted detection report.
It realizes fast response at the edge and high-precision coordination between the cloud, improves the real-time and accuracy of the detection system, reduces the data transmission bandwidth requirement, enhances the detection ability of low-concentration pollutants, ensures the credibility and compliance of the detection results, and reduces operation and maintenance costs.
Smart Images

Figure CN120455503A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of food safety detection, and specifically to a SERS spectroscopy cloud-based deep learning platform for food safety detection. Background Art
[0002] The demand for rapid identification and precise quantification of trace contaminants in food safety testing is becoming increasingly urgent. Surface-enhanced Raman scattering (SERS) technology, with its molecular fingerprint recognition capabilities and high sensitivity, has become a core method for detecting food additives, pesticide residues, and illegal additives. However, existing SERS-based detection systems face multiple technical bottlenecks in practical applications:
[0003] Edge devices are limited by the computing power and storage resources of embedded hardware and can usually only run simplified classification models, resulting in a high rate of missed detection of low-concentration pollutants or complex matrix samples. While solutions that rely on centralized cloud processing can improve accuracy, they generate a huge transmission load due to the high-dimensional nature of the original spectral data. In cross-regional multi-node concurrent scenarios, network bandwidth contention is exacerbated, resulting in significant delays in the real-time upload and review of high-value data, seriously affecting the timeliness of detection. In addition, traditional detection models are often trained based on static data sets, making it difficult to dynamically adapt to the distribution offset problems caused by the emergence of new pollutants, aging of equipment hardware, or drift in environmental parameters. Frequent manual intervention in model iteration is required, and operation and maintenance costs increase sharply. Existing transmission optimization solutions mostly use fixed compression ratio algorithms and equalized bandwidth allocation strategies, and fail to combine the information entropy characteristics of the data itself to achieve differentiated management, resulting in low response efficiency for key detection tasks, further restricting food safety risk early warning capabilities. Summary of the Invention
[0004] In response to the shortcomings of the existing technology, the present invention provides a SERS spectroscopy cloud-based deep learning platform for food safety testing, which solves the problems of insufficient edge real-time performance, low cloud analysis efficiency, weak model generalization ability and lack of data transmission value assessment in the existing SERS detection technology.
[0005] To achieve the above objectives, the present invention is implemented through the following technical solutions: a SERS spectroscopy cloud-based deep learning platform for food safety testing, including the following modules:
[0006] Edge-end intelligent acquisition module: Connected to the SERS device via a USB / Bluetooth interface, it performs spectral signal acquisition, adaptive filtering, and edge classification. The edge-end intelligent acquisition module uploads high-entropy spectral data to the cloud via the MQTT protocol and simultaneously receives updated subnetwork weights and routing matrices from the cloud, achieving bidirectional synchronization of model parameters.
[0007] A cloud-based deep learning platform receives the spectral data stream from the edge intelligent acquisition module and deploys a multimodal fusion classification model. The multimodal fusion classification model dynamically updates the fully connected layer parameters through an incremental learning algorithm and extracts sub-network weights based on knowledge distillation technology.
[0008] Dynamic collaborative management engine: Deployed on a cloud server, it performs differential encoding and compression on uploaded spectral data, using the Zstandard compression algorithm with a compression ratio of ≥8:1. It prioritizes data packets based on classification entropy and dynamically allocates transmission bandwidth using a weighted fair queuing algorithm, where the weight coefficient is negatively correlated with the classification confidence.
[0009] Intelligent Decision-Making and Visualization Module: This module receives cloud-based classification results in real time via the WebSocket protocol and generates a structured inspection report containing pollutant concentrations, risk levels, and treatment recommendations based on fuzzy logic rules. It uses the t-SNE algorithm to project high-dimensional spectral data into a two-dimensional space, setting the perplexity to 30 and the learning rate to 200, to generate interactive visualizations that support multi-view linkage.
[0010] Blockchain data notarization module: performs SHA-256 hash calculation on the original spectral data and test results, and anchors the hash value to the Ethereum shard chain through smart contracts. When the pollutant concentration exceeds the preset threshold, it automatically triggers compliance verification based on zero-knowledge proof and sends an alarm signal to the regulatory node. The blockchain data notarization module interacts with the dynamic collaborative management engine through RESTful API to ensure that the data on-chain delay is less than 2 seconds.
[0011] Preferably, the edge intelligent acquisition module includes the following units:
[0012] Multimodal data access unit: Generates a unique device fingerprint by extracting and compressing the frequency domain features of the device calibration spectrum, solving the detection bias problem caused by hardware differences;
[0013] Adaptive nonlinear filtering unit: removes spectral baseline drift and noise through a learnable dynamic equation system, achieving local adaptive filtering and avoiding the over-smoothing or under-filtering problems of traditional fixed parameter filters;
[0014] Dynamic routing inference unit: Generates routing weights based on device fingerprints and selects lightweight subnets for edge classification.
[0015] Preferably, the cloud-based deep learning platform includes the following units:
[0016] High-precision inference unit: deploys a multimodal fusion classification model based on the Transformer architecture to perform fusion classification on the spliced original spectrum and filtered spectrum;
[0017] Elastic incremental learning unit: Through an improved elastic weight solidification algorithm, only high-frequency activation parameters are constrained.
[0018] Preferably, the dynamic collaborative management engine includes the following units:
[0019] Bandwidth optimization transmission unit: Through differential encoding and Zstandard compression algorithm, it compresses uploaded data and reduces network bandwidth usage;
[0020] Priority scheduling unit: Allocates bandwidth based on entropy value through a weighted fair queuing algorithm, giving priority to transmitting high-uncertainty data and improving system response efficiency.
[0021] Device generalization monitoring unit: Detects device status deviations in real time through statistical analysis methods and triggers dynamic adaptation of cloud-based models to maintain detection accuracy.
[0022] Preferably, the multimodal fusion classification model includes a spectral feature extraction sub-model, a time series-context association sub-model and a device topology embedding sub-model.
[0023] Preferably, the deep learning model dynamically weights and fuses the features output by the spectral feature extraction sub-model, the time series-context association sub-model, and the device topology embedding sub-model through a multi-head self-attention mechanism, and the calculation form is:
[0024]
[0025] Among them, Q, K, and V come from the characteristic matrices of the spectral, temporal, and topological sub-models respectively, and d k is the scaling factor. This layer adaptively enhances the contribution of key modes and suppresses noise interference.
[0026] Preferably, the knowledge of the multimodal fusion model is migrated to a lightweight quantum network deployable at the edge based on knowledge distillation technology, and the output distribution of the cloud model and the sub-network is aligned through the KL divergence loss function:
[0027]
[0028] Among them, p cloud With p edge They are the classification probability distributions of the cloud multimodal model and the edge sub-network, respectively.
[0029] Preferably, the elastic incremental learning unit applies dynamic constraints on high-frequency activation parameters by improving the elastic weight solidification algorithm, thereby suppressing catastrophic forgetting while adapting to new tasks. The specific improvement includes the following steps:
[0030] Set dynamic thresholds based on statistical quantiles to filter out high-frequency activation parameters;
[0031] Improve incremental training efficiency by shielding the calculation of low-frequency parameters;
[0032] Introducing a forgetting suppression verification mechanism to automatically test performance on historical task verification sets after incremental training;
[0033] Balance model stability and adaptability through iterative optimization.
[0034] Preferably, the differential encoding in the bandwidth optimization transmission unit is implemented as follows:
[0035] For continuous spectral frame S t With S t-1 Compute the point-wise difference matrix:
[0036] ΔS t =S t -S t-1 ;
[0037] When there is a mutation point |ΔS t [i]|>δ, then switch to absolute value encoding:
[0038] ΔS t =S t ;
[0039] Coding optimization: The adaptive threshold δ is dynamically adjusted according to the standard deviation of historical data, δ = 2σ t-1 , to avoid the error accumulation caused by fixed thresholds.
[0040] Preferably, the adaptive filtering equation is:
[0041]
[0042] in: Input spectrum signal, N is the number of wavelength points;
[0043] φ i (·): basis function set, which includes Gaussian kernel Piecewise Polynomial and Mexican Hat Wavelet
[0044] α i (x)∈[0,1]: dynamic weights, predicted by lightweight CNN;
[0045] β(x)∈[0,1]: noise suppression coefficient, constrained by the Sigmoid function;
[0046] Noise gating module, convolution kernel size 5, output channels 16.
[0047] The present invention provides a SERS spectroscopy cloud-based deep learning platform for food safety testing.
[0048] It has the following beneficial effects:
[0049] 1. This invention utilizes a bidirectional parameter synchronization mechanism between an intelligent edge acquisition module and a cloud-based deep learning platform to achieve rapid local classification of spectral data and high-precision cloud-based verification. Lightweight inference execution at the edge reduces response latency, while dynamic updates of model parameters in the cloud ensure global detection accuracy. This addresses the challenge of balancing real-time performance and accuracy in traditional SERS detection systems.
[0050] 2. This invention significantly reduces the bandwidth requirements for spectral data uploads through a dynamic collaborative management engine, employing differential encoding and high-compression algorithms. Combined with a priority scheduling strategy based on classification uncertainty, it prioritizes the transmission of high-entropy data, ensuring rapid cloud-based response for critical detection tasks. This design overcomes the resource waste and critical data bottlenecks associated with traditional uniform transmission, improving overall system efficiency.
[0051] 3. This invention effectively overcomes the vulnerability of single spectral data to interference from environmental noise and device differences by implementing a multimodal deep learning model that integrates spectral features, temporal context, and device topology information. A multi-head attention mechanism dynamically weights the contributions of each modality, enhancing the ability to capture weak signals from low-concentration pollutants.
[0052] 4. The improved elastic weight curing algorithm in this invention focuses on protecting high-frequency parameters, allowing the model to retain existing knowledge when incrementally learning new pollutant categories, avoiding catastrophic forgetting. This mechanism enables the system to continuously adapt to the unknown risks of new illegal additives, ensuring that detection capabilities evolve dynamically with regulatory requirements and reducing the frequency of manual model reconstruction.
[0053] 5. This invention uses a generalized device monitoring unit to analyze edge data distribution deviations in real time, automatically triggering dynamic model adaptation to mitigate performance degradation caused by sensor aging or environmental changes. Combined with blockchain evidence storage technology, this technology enables trusted traceability of data throughout the entire testing process, ensuring consistency of test results across regions and multiple devices, and meeting compliance requirements for food safety regulations. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 Schematic diagram of the overall system of the present invention. DETAILED DESCRIPTION
[0055] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the present specification. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0056] Please see the attached Figure 1 The present invention provides a SERS spectroscopy cloud-based deep learning platform for food safety testing, including the following modules:
[0057] Edge-end intelligent acquisition module: Connected to the SERS device via a USB / Bluetooth interface, it performs spectral signal acquisition, adaptive filtering, and edge classification. The edge-end intelligent acquisition module uploads high-entropy spectral data to the cloud via the MQTT protocol and simultaneously receives updated subnetwork weights and routing matrices from the cloud, achieving bidirectional synchronization of model parameters.
[0058] A cloud-based deep learning platform receives the spectral data stream from the edge intelligent acquisition module and deploys a multimodal fusion classification model. The multimodal fusion classification model dynamically updates the fully connected layer parameters through an incremental learning algorithm and extracts sub-network weights based on knowledge distillation technology.
[0059] Dynamic collaborative management engine: Deployed on a cloud server, it performs differential encoding and compression on uploaded spectral data, using the Zstandard compression algorithm with a compression ratio of ≥8:1. It prioritizes data packets based on classification entropy and dynamically allocates transmission bandwidth using a weighted fair queuing algorithm, where the weight coefficient is negatively correlated with the classification confidence.
[0060] Intelligent Decision-Making and Visualization Module: Receives cloud classification results via the WebSocket protocol, generates a test report containing pollutant concentration, risk level, and treatment recommendations, and uses the t-SNE algorithm with a perplexity of 30 and a learning rate of 200 to generate interactive spectral visualizations.
[0061] Blockchain data storage module: original spectral data The test results are hashed using SHA-256, and the hash value H=SHA256(S||R) is written into the Ethereum shard chain through a smart contract. This automatically triggers a regulatory alert when the pollutant concentration exceeds the standard.
[0062] The edge intelligent acquisition module and the cloud synchronize model parameters through the two-way MQTT protocol;
[0063] The dynamic collaborative management engine interacts with the blockchain module through RESTful API to ensure that the data on-chain delay is less than 2 seconds.
[0064] In this embodiment, the edge-end intelligent acquisition module connects to a surface-enhanced Raman scattering (SERS) detection device via a modal interface to enable real-time acquisition and standardized processing of spectral signals. The interface protocol preferably supports USB 3.0 or Bluetooth 5.0, ensuring a sampling rate of no less than 10 Hz, a wavelength coverage range of 500 cm⁻¹ to 2000 cm⁻¹, and a spectral resolution of ≤2 cm⁻¹.
[0065] In this embodiment, the generation of device fingerprint is based on the joint encoding of device hardware characteristics and calibration spectrum. is the number of wavelength points) is converted to the frequency domain through fast Fourier transform (FFT) to extract the amplitude spectrum As the input of the meta-learning model. The meta-learning model is a two-layer fully connected neural network, and its mathematical expression is:
[0066] z=W2·ReLU(W1·|FFT(S calibration )|+b1)+b2;
[0067] in:
[0068] The input layer weight matrix is initialized using He normal distribution;
[0069] Input layer bias term, initialized to zero;
[0070] Output layer weight matrix;
[0071] Output layer bias term;
[0072] Device fingerprint vector, used to characterize device hardware characteristics.
[0073] In this embodiment, the adaptive nonlinear filtering unit achieves spectral signal denoising and baseline correction through a dynamic basis function combination and noise gating mechanism. Its core filtering equation is:
[0074]
[0075] in: Input spectrum signal, N is the number of wavelength points (500≤N≤2000);
[0076] φ i (·): The base function library collection includes:
[0077] Gaussian kernel function:
[0078]
[0079] μ i ∈[500,2000]: wavelength center position, initialized during the training phase by the clustering algorithm;
[0080] σ i ∈[5,50]: bandwidth parameter, optimized by gradient descent.
[0081] Piecewise polynomial:
[0082] Fit a 3rd order polynomial in the local window [x-10,x+10] Coefficient {a j Solved by least squares method.
[0083] Mexican Hat Wavelet:
[0084]
[0085] The wavelet function is preferably used to detect abrupt changes in the edge of a characteristic peak.
[0086] In this embodiment, the dynamic weight prediction network:
[0087] The input is a local spectral window centered at wavelength x The network structure is:
[0088] Convolutional layer 1: 1D convolution, kernel size 3, output channels 16, stride 1, padding 1, activation function ReLU, used to extract translation-invariant features of the local spectrum;
[0089] Convolutional layer 2: 1D convolution, kernel size 5, output channels 32, stride 1, padding 2, activation function ReLU, used to expand the receptive field;
[0090] Global average pooling layer: outputs a 32-dimensional feature vector to preserve the overall spectral distribution information;
[0091] Fully connected layer: 3 maps 32-dimensional features to k+1-dimensional output, activates the Sigmoid function, and generates a normalized weight coefficient α i (x) and noise suppression coefficient β(x) noise gating module:
[0092]
[0093] in:
[0094] Θ1, Θ2: convolution parameters, kernel size 5, output channels 16, stride 1, padding 2, used to separate noise from valid signals;
[0095] ⊙: Element-wise multiplication, used to suppress high-frequency noise. For example, when β(x)≈0, the noise gating is turned off.
[0096] In this embodiment, the dynamic routing inference unit dynamically fuses the inference results of multiple lightweight subnetworks according to the device fingerprint vector z, and its routing weight is calculated as:
[0097]
[0098] in:
[0099] Learnable routing matrix, each sub-network corresponds to an independent matrix;
[0100] Edge subnetwork f j : Compressed version 1D-ResNet18, the structure is as follows:
[0101] Input layer: 1D convolution, kernel size 7, output channels 16, stride 2, extracting coarse-grained spectral features;
[0102] Residual block 1: two convolutional layers (kernel 3×1, channel 16), skip connection, skip connection is achieved through identity mapping;
[0103] Residual block 2: two convolutional layers (kernel 3×1, channel 32), skip connections, and the skip connections align the dimensions through 1×1 convolutions;
[0104] Global pooling layer: outputs a 32-dimensional feature vector for classification;
[0105] Classification layer: Fully connected layer (32→10 dimensions), Softmax activation, outputs the probability distribution of 10 common pollutants.
[0106] Entropy filter conditions:
[0107] Calculate the entropy of the marginal classification results to assess uncertainty:
[0108]
[0109] When H(p edge )>0.7, the current sample is judged to have classification ambiguity, and the original spectrum S is compared with the filtered result. Splice to Upload to the cloud. The threshold of 0.7 is preferably determined through cross-validation to balance the error rate and computational load.
[0110] Also, ensure that the device fingerprint matches the dimensions of the routing matrix:
[0111] Device fingerprint With routing matrix Strict matching ensures that the matrix multiplication z T W j mathematical validity.
[0112] The physical meaning of local window:
[0113] The local spectral window width is 41 (corresponding to ±20 wavelength points) covering about 40cm -1 range, capable of capturing characteristic peaks (melamine characteristic peak 709cm -1 ) in its complete form.
[0114] Frequency domain interpretation of noise gating:
[0115] The kernel size of the gated convolution is 5, which corresponds to about 10cm. -1 wavelength range, which can effectively separate high-frequency noise (CCD thermal noise) from low-frequency baseline drift.
[0116] Specifically, the high-precision inference unit of the cloud-based deep learning platform is used to analyze the high-uncertainty spectral data uploaded by the edge end, and achieve accurate classification of pollutants through multi-level feature fusion and global dependency modeling. The input data of the unit is preferably the original spectrum. and edge filtering results The concatenated tensor Where N is the number of wavelength points to preserve the integrity of the original signal and the baseline correction information after filtering.
[0117] In this embodiment, the high-precision inference unit adopts a cascade neural network architecture, which is composed of a 1D-ResNet50 backbone network and a Transformen encoder. The two realize multi-scale information fusion through a feature pyramid structure. 1D-ResNet50 contains four residual blocks with 64, 128, 256, and 512 channels respectively. Each residual block consists of two one-dimensional convolutional layers (kernel size 3, stride 1) and a jump connection. For example, the output feature of the first residual block is After downsampling through the maximum pooling layer (kernel size 3, stride 2), it is input into the second residual block to gradually expand the receptive field and extract the local detail features of the spectrum.
[0118] Furthermore, the Transformer encoder models the global dependencies between wavelength points through a multi-head self-attention mechanism. Specifically, the input feature The query matrix Q, key matrix K, and value matrix V are generated by linear projection. The calculation process is defined as:
[0119]
[0120] Where: Q, K, V come from the characteristic matrices of the spectral, temporal and topological sub-models respectively, d k is the scaling factor. This layer adaptively enhances the contribution of key modes and suppresses noise interference.
[0121] The self-attention output is layer-normalized (LayerNorm) and connected to the residual before being input into the feed-forward network (FFN). Its expression is:
[0122] FFN(x)=ReLU(xW1+b1)W2+b2;
[0123] in, are learnable parameters.
[0124] The output features of the Transformer encoder are mapped to the classification head through the global average pooling layer to generate the probability distribution of pollutant categories. (C = 10 common pollutants). The output distribution of the cloud model and the sub-network are aligned using the KL divergence loss function:
[0125]
[0126] Among them, p cloud With p edge They are the classification probability distributions of the cloud multimodal model and the edge sub-network, respectively.
[0127] In this embodiment, the elastic incremental learning unit is used to continuously update the model parameters in the cloud, while avoiding the catastrophic forgetting problem through the improved elastic weight consolidation (EWC) algorithm. The loss function is defined as:
[0128]
[0129] in:
[0130] The cross entropy loss function calculates the difference between the predicted probability p and the true label y, driving the model to adapt to new pollutant categories;
[0131] The strength of the elastic constraint, preferably determined through grid search, balances the knowledge retention and learning ability of new and old tasks;
[0132] Ω is the set of historical high-frequency activation parameters. By counting the activation frequency of each parameter in the past 100 inferences, the top 10% of high-frequency parameters are selected and added to the constraint set.
[0133] Parameter importance weight, reflecting the contribution of the parameter to the historical task, where Count i is the parameter θ i the number of activations in historical reasoning;
[0134] θ oldi: The value of the parameter under the historical optimal state is stored in an independent memory space to avoid overwriting.
[0135] In this embodiment, the incremental learning process only updates the routing matrix and the classification head parameter W cls , freezing the backbone network parameters to maintain the stability of basic feature extraction capabilities. For example, the model update cycle is dynamically adjusted based on the cumulative number of new samples. When the number of new samples exceeds 500, the incremental learning process is triggered to ensure the timeliness of model iteration.
[0136] In this embodiment, the dynamic routing fusion mechanism uses the device fingerprint vector Dynamically assign weights to the edge and cloud sub-networks to achieve adaptive classification of cross-device spectral data. The routing weight generation formula for the cloud sub-network is:
[0137]
[0138] in:
[0139] The routing matrix corresponding to the cloud sub-network shares the same orthogonal initialization strategy as the edge routing matrix to ensure orthogonality and stability of the projection direction;
[0140] Cloud sub-networks f4 and f5: deploy high-precision models (1D-ResNet50+Transformer) with an optimal parameter size of 120MB, used to analyze complex patterns of high-uncertainty samples, overlapping characteristic peaks, or low signal-to-noise ratio spectra.
[0141] The final classification result is the weighted fusion output of the edge intelligent collection module and the cloud sub-network:
[0142]
[0143] Among them, f1, f2, and f3 are lightweight quantum networks at the edge, and f4 and f5 are high-precision sub-networks at the cloud end. The dynamic allocation of computing resources is achieved through routing weights driven by device fingerprints.
[0144] In this embodiment, the cloud-based deep learning platform supports multi-tenant isolated deployment, allocating independent model instances to different users through containerization technology. Preferably, the basic feature extraction layer is shared, while the classification head and routing matrix are trained independently to ensure user data privacy and model personalization requirements. Model update strategies include:
[0145] Synchronous update of the base layer: After the global model is optimized through incremental learning, the base layer parameters of all tenant instances are synchronously replaced to ensure consistency in common feature extraction capabilities.
[0146] The personalization layer is updated independently: Each tenant's classification head and routing matrix are continuously fine-tuned based on local data to adapt to specific detection scenarios (melamine detection in dairy products and formaldehyde detection in seafood).
[0147] For example, tenant isolation is achieved through namespace and virtual private cloud (VPC) technology, and the data storage and transmission process uses the AES-256 encryption algorithm to meet the privacy compliance requirements of food safety testing.
[0148] In this embodiment, the bandwidth optimization transmission unit of the dynamic collaborative management engine is designed for the continuous and smooth characteristics of the surface enhanced Raman scattering (SERS) spectrum, and reduces data redundancy through differential coding and adaptive compression algorithm. t With S t-1 Compute the point-wise difference matrix:
[0149] ΔS t =S t -S t-1 ;
[0150] Furthermore, when there is a mutation point |ΔS t [i]|>δ, then switch to absolute value encoding:
[0151] ΔS t =S t ;
[0152] Finally, coding optimization: the adaptive threshold δ is dynamically adjusted according to the standard deviation of historical data, δ = 2σ t-1 , to avoid the error accumulation caused by fixed thresholds.
[0153] In this embodiment, the compression algorithm preferably adopts the Zstandard framework, the core of which is dynamic dictionary training and multi-threaded acceleration. For example, the compression dictionary is trained offline based on the historical SERS spectral dataset, and the dictionary size is preferably 512KB to capture the characteristic peak distribution pattern of different pollutants. The compression level is set to 22, and through 4-thread parallel processing, the single sample compression delay is less than 50ms, and the compression ratio is ≥8:1. The compressed data packet is uploaded via the MQTT protocol (QoS = 1) to ensure the reliable transmission of high-entropy spectral data.
[0154] In this embodiment, the priority scheduling unit implements prioritized transmission of critical data through classification uncertainty assessment and dynamic bandwidth allocation. Its core process includes:
[0155] Information entropy calculation: classification results at the edge (C = 10 common pollutants) Calculate information entropy:
[0156]
[0157] The entropy value H(p) quantifies the classification confidence. Samples with high entropy values (H(p)>0.7) indicate that there are multiple candidate pollutant categories and need to be uploaded to the cloud first.
[0158] Weighted Fair Queuing (WFQ):
[0159] The packet priority weight ww is determined by the entropy value and the remaining survival time:
[0160]
[0161] γ∈[0,1]: Entropy weight coefficient, preferably 0.8, determined by regression analysis of historical transmission logs;
[0162] H max =logC: maximum theoretical entropy value, used for normalization;
[0163] T remain The remaining survival time of the data packet, T max is the maximum allowed transmission delay (set to 5 minutes for example).
[0164] Bandwidth resources are dynamically allocated according to weight ratio. High-weight data packets take priority in the transmission channel. At the same time, a ring buffer is used to manage the queue and pre-allocate the bandwidth resource pool to ensure that the scheduling delay is less than 50ms.
[0165] In this embodiment, the device generalized monitoring unit detects device state deviations in real time through statistical analysis methods and triggers dynamic adaptation of the cloud model to maintain detection accuracy. Specifically, it includes:
[0166] Device fingerprint distribution modeling:
[0167] Statistical historical device fingerprint vector The mean and the covariance matrix Construct a multi-dimensional Gaussian distribution model. Preferably, a sliding window update mechanism is used to incrementally update μΣ every 30 minutes to adapt to the gradual aging of equipment.
[0168] Mahalanobis distance anomaly detection:
[0169] Real-time device fingerprinting new Calculate the Mahalanobis distance from the historical distribution:
[0170] D 马氏 =(z new -μ) T Σ -1 (z new -μ);
[0171] When D马氏 >3σ (σ is the historical distribution standard deviation), indicating that the device hardware and environmental status are abnormal.
[0172] Model dynamic adaptation mechanism:
[0173] When an exception is triggered, the routing matrix is fine-tuned based on the 1000 spectral data recently uploaded by the device. With the classification header parameter
[0174] Freeze the backbone network parameters to prevent overfitting, and constrain historical important parameters through incremental learning loss function:
[0175]
[0176] The updated model parameters are synchronized to the edge in real time via the MQTT protocol to restore device detection accuracy.
[0177] Preferred: Adaptability of differential encoding to SERS spectral characteristics:
[0178] Raman spectrum in the characteristic peak region (Sudan Red 1580cm -1 ) shows a steep change, while in the baseline region (500-800cm -1 ) is smooth and continuous. Differential encoding significantly reduces data redundancy by leveraging the strong correlation between adjacent wavelength points. Combined with dynamic range scaling technology, it avoids truncation errors in the characteristic peak amplitude during the quantization process.
[0179] WFQ algorithm and real-time food safety requirements:
[0180] High-entropy samples typically correspond to new pollutants or complex mixed pollution scenarios. Prioritizing the transmission of this type of data can accelerate incremental learning of cloud-based models and improve the platform's response to unknown risks. The weighting coefficient γ = 0.8 is preferably determined through historical log analysis to balance classification uncertainty and transmission timeliness requirements.
[0181] Mahalanobis distance detection and device state generalization:
[0182] The Mahalanobis distance normalizes device fingerprint offsets using the covariance matrix, accurately identifying distribution shifts caused by increased CCD noise or aging optical components. Model fine-tuning targets only the routing matrix and classification head, ensuring rapid restoration of detection robustness without compromising global feature extraction capabilities.
[0183] The dynamic report generation unit of the intelligent decision-making and visualization module integrates multi-source data with fuzzy logic rules to achieve quantitative assessment and dynamic decision-making of pollutant risk levels. Specifically, it constructs an adaptive risk calculation model based on surface-enhanced Raman scattering (SERS) spectroscopy results, combined with toxicological parameters and environmental context information.
[0184] Specifically, the risk index calculation and fuzzification process include:
[0185] Toxicology-concentration fusion model:
[0186] The pollutant risk index R is jointly calculated by the detected concentration c (unit: ppm, precision 0.01 ppm) and the median lethal dose LD 50 (unit: mg / kg, sourced from the WHO database):
[0187]
[0188] Where:
[0189] The α smoothing factor (with a value of 1×10<D -6 ), to prevent a division-by-zero error when LD<D 50 approaches zero, and at the same time suppress the over-dilution of the risk index of low-toxicity substances (LD<D 50 is extremely large);
[0190] LD<D 50 Dynamic update: Obtain the latest toxicology data in real time through the API interface and cache it in the local database to handle network latency.
[0191] Fuzzy logic rule base design:
[0192] Input variable fuzzification:
[0193] The risk index R: Divided into three fuzzy sets of "low risk" (R ≤ 0.1), "medium risk" (0.1 < R < 0.3), and "high risk" (R ≥ 0.3). The Gaussian membership function is preferred:
[0194]
[0195] Concentration change trend Extract the slope through time series analysis of historical data and divide it into fuzzy sets of "stable", "fluctuating", and "rapid increase".
[0196] Rule trigger mechanism:
[0197] Exemplarily define the rule: "If R is high risk and the device fingerprint z indicates an abnormal ambient temperature, then the risk level is upgraded to emergency". The rule weight is dynamically adjusted based on the historical false alarm rate.
[0198] Defuzzification and report generation:
[0199] The area centroid method is used to convert the fuzzy output into an exact risk level. The formula
[0200]
[0201] Among them, A i The weights are preset (low = 1, medium = 2, high = 3). The final report is linked to the knowledge graph and dynamically generates structured content including threshold exceedance prompts, treatment measures (recall, sterilization) and regulatory basis.
[0202] In this embodiment, the interactive visualization unit maps complex spectral data into interactive visualization maps through high-dimensional data dimensionality reduction and dynamic association analysis technology, helping users quickly locate abnormal samples and understand classification logic.
[0203] t-SNE projection and visualization include:
[0204] Manifold Learning Algorithm:
[0205] The spectral characteristics Projecting into two-dimensional space preserves the local and global structure of the data:
[0206] High-dimensional similarity calculation:
[0207]
[0208] Among them, the perplexity is preferably 30, and σ is adjusted by binary search i Make the conditional probability distribution entropy satisfy log(Perplexity).
[0209] Low-dimensional space optimization:
[0210] Initialize the random distribution Y and iteratively update it by minimizing the KL divergence:
[0211]
[0212] The learning rate is preferably 200, the momentum term is set to 0.5 to avoid local optimality, and the number of iterations is set to 1000.
[0213] Dynamic interactive features:
[0214] Multi-view linkage: When the user clicks on a data point in the projection image, the original spectrum curve and characteristic peak markers (709cm -1 and 1580cm -1 ) and real-time risk level;
[0215] Outlier detection: Calculate the deviation of the sample from the historical distribution based on the Mahalanobis distance:
[0216]
[0217] Among them, μ and Σ are the mean and covariance matrix of the historical projection data, the deviation threshold is set to 3σ, and the value exceeding the threshold is marked in red.
[0218] Knowledge graph and traceability analysis:
[0219] A food safety knowledge graph is constructed, with nodes including contaminants, food matrices, treatment measures, and regulatory provisions. The strength of association is determined by co-occurrence frequencies and correlation coefficients in historical test data. For example, when excessive melamine levels are detected in dairy products, the graph automatically links to the "GB2760-2014 Food Safety Standard" node and generates treatment recommendations including batch traceability codes.
[0220] In this embodiment, the blockchain data evidence module is designed based on the characteristics of surface-enhanced Raman scattering (SERS) spectral data and adopts a multi-chain collaborative architecture to achieve data sharding storage and cross-chain anchoring. Specifically, to meet the storage requirements of high-dimensional spectral data (N = 1500 wavelength points), the original data is divided into publicly verifiable digests and encrypted shards, which are stored on the public chain and the consortium chain respectively, balancing data transparency and privacy protection.
[0221] Preferably, the data sharding and evidence storage unit includes:
[0222] Merkle tree construction:
[0223] For the original spectral data and classification results Construct a Merkle tree whose root hash is calculated as:
[0224] H root =MerkleRoot(H(S1),H(S2),…,H(S N ));
[0225] Among them, the leaf node hash H(S i )=SHA-256(S i ), the parent node hash is generated by concatenating the child node hashes and then performing a secondary hash, and a depth-first traversal is used to construct the tree structure.
[0226] Shard storage strategy:
[0227] Public chain storage: Merkle tree root hash H root , device fingerprint The timestamp T and classification result p are written to the Ethereum public chain through smart contracts to ensure that the data is publicly verifiable;
[0228] Alliance chain storage: original spectral data shards {S1, S2, ..., S N}After being encrypted by AES-256-GCM, it is stored in the industry alliance chain built on Hyperledger Fabric. Access rights are dynamically controlled by the CA certificate, and only authorized testing agencies and regulatory nodes can decrypt it.
[0229] Preferably, the sharding strategy uses Reed-Solomon erasure coding, splitting the data into kk data blocks and m redundancy blocks (exemplarily set as k=4 and m=2), ensuring complete data recovery in the event of a single chain failure or partial node unavailability. Furthermore, the redundancy blocks are distributed to consortium chain nodes in different geographical regions to improve disaster recovery capabilities.
[0230] In this embodiment, the cross-chain verification unit automatically verifies the consistency of the public chain and the consortium chain data through smart contracts, and anchors the timestamp to the tamper-resistant chain to ensure the integrity and timeliness of the data.
[0231] Preferably, the data consistency verification process includes:
[0232] Data integrity check:
[0233] Get encrypted shard data {S′1, S′2,…, S′ from the alliance chain node N}, after decryption, reconstruct the original spectrum data S′ and recalculate the Merkle tree root hash H′ root , and H stored in the public chain root Comparison:
[0234]
[0235] If the verification fails, an alarm is triggered and data access rights are frozen until manual verification is completed.
[0236] Timestamp tamper-resistant anchoring:
[0237] The public chain smart contract calls the off-chain Oracle service to synchronize the detection timestamp TT to the NTP (Network Time Protocol) server and write it into the OP_RETURN script of the Bitcoin blockchain, using the high computing power of the Bitcoin network to ensure that the time source cannot be tampered with.
[0238] The privacy protection unit uses zero-knowledge proof (ZKP) technology to achieve verifiable declaration of sensitive data, avoiding the leakage of original spectral data while meeting regulatory compliance requirements.
[0239] Preferably, the zk-SNARKs compliance proof process includes:
[0240] Constraint modeling:
[0241] The food safety detection logic (characteristic peak intensity threshold) is converted into an arithmetic circuit, and the characteristic peak of melamine (709cm -1 and 1580cm -1 ) strength constraint:
[0242] PeakIntensity(S,709)>τ1 and PeakIntensity(S,1580)>τ2;
[0243] Among them, τ1 and τ2 are preset intensity thresholds.
[0244] Proof Generation and Verification:
[0245] The prover generates a proof π, stating that “there exists spectral data S that satisfies the above constraints and H(S) = H root ”;
[0246] The verifier calls the verification function Verify of the public chain smart contract zk (π,H root ,τ1,τ2), the statement is true when the output result is 1.
[0247] Preferably, the Groth16 protocol is used to implement zk-SNARKs, with its verification key stored in the public chain smart contract, and the proof generation process is performed offline to reduce the computational load on the chain. Furthermore, the constraints support dynamic updates to adapt to the revision of food safety standards.
[0248] In this embodiment, the dynamic evidence storage strategy unit adaptively adjusts the evidence storage period and chain type according to the data type, compliance requirements and storage costs to optimize long-term storage efficiency.
[0249] Furthermore, the policy execution logic includes:
[0250] Permanent storage of key data:
[0251] When the confidence level p of a certain type of pollutant in the classification result is i When the threshold is exceeded (set to 0.9 for example), it is determined to be food safety incident data, permanently stored on the public chain, and timestamp anchored through the Bitcoin OP_RETURN script;
[0252] After the data storage period expires, the alliance chain data desensitization process is triggered, sensitive information of the enterprise identifier is deleted, and it is migrated to the IPFS low-cost storage chain.
[0253] Rolling evidence trigger conditions:
[0254] When the storage utilization rate of the alliance chain exceeds the preset threshold (set to 80% for example), data cleaning and migration will be automatically initiated;
[0255] Dynamically adjust sharding parameters k and m to optimize storage efficiency based on network load.
[0256] While embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions, and variations may be made to these embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the appended claims and their equivalents.
Claims
1. A SERS spectroscopy cloud-based deep learning platform for food safety testing, characterized by: Includes the following modules: Edge-end intelligent acquisition module: Connected to the SERS device via a USB / Bluetooth interface, it performs spectral signal acquisition, adaptive filtering, and edge classification. The edge-end intelligent acquisition module uploads high-entropy spectral data to the cloud via the MQTT protocol and simultaneously receives updated subnetwork weights and routing matrices from the cloud, achieving bidirectional synchronization of model parameters. A cloud-based deep learning platform receives the spectral data stream from the edge intelligent acquisition module and deploys a multimodal fusion classification model. The multimodal fusion classification model dynamically updates the fully connected layer parameters through an incremental learning algorithm and extracts sub-network weights based on knowledge distillation technology. Dynamic collaborative management engine: Deployed on a cloud server, it performs differential encoding and compression on uploaded spectral data, adopts the Zstandard compression algorithm with a compression ratio of ≥8:1, prioritizes data packets based on classification entropy, and dynamically allocates transmission bandwidth through a weighted fair queuing algorithm, where the weight coefficient is negatively correlated with the classification confidence.
2. The SERS spectroscopy cloud-based deep learning platform for food safety testing according to claim 1 is characterized in that: The edge intelligent acquisition module includes the following units: Multimodal data access unit: Generates a unique device fingerprint by extracting and compressing the frequency domain features of the device calibration spectrum, solving the detection bias problem caused by hardware differences; Adaptive nonlinear filtering unit: removes spectral baseline drift and noise through a learnable dynamic equation system, achieving local adaptive filtering and avoiding the over-smoothing or under-filtering problems of traditional fixed parameter filters; Dynamic routing inference unit: Generates routing weights based on device fingerprints and selects lightweight subnets for edge classification.
3. The SERS spectroscopy cloud-based deep learning platform for food safety testing according to claim 1 is characterized in that: The cloud-based deep learning platform includes the following units: High-precision inference unit: deploys a multimodal fusion classification model based on the Transformer architecture to perform fusion classification on the spliced original spectrum and filtered spectrum; Elastic incremental learning unit: Through an improved elastic weight solidification algorithm, only high-frequency activation parameters are constrained.
4. The SERS spectroscopy cloud-based deep learning platform for food safety testing according to claim 1, characterized in that: The dynamic collaborative management engine includes the following units: Bandwidth optimization transmission unit: Through differential encoding and Zstandard compression algorithm, it compresses uploaded data and reduces network bandwidth usage; Priority scheduling unit: allocates bandwidth based on entropy value through a weighted fair queuing algorithm, giving priority to transmitting highly uncertain data and improving system response efficiency; Device generalization monitoring unit: Detects device status deviations in real time through statistical analysis methods and triggers dynamic adaptation of cloud-based models to maintain detection accuracy.
5. The SERS spectroscopy cloud-based deep learning platform for food safety testing according to claim 3, characterized in that: The multimodal fusion classification model includes a spectral feature extraction sub-model, a time series-context association sub-model and a device topology embedding sub-model.
6. The SERS spectroscopy cloud-based deep learning platform for food safety testing according to claim 5, characterized in that: The deep learning model uses a multi-head self-attention mechanism to dynamically weight the features output by the spectral feature extraction sub-model, the time series-context association sub-model, and the device topology embedding sub-model. The calculation form is: Among them, Q, K, and V come from the characteristic matrices of the spectral, temporal, and topological sub-models respectively, and d k is the scaling factor, and this layer adaptively enhances the contribution of key modes and suppresses noise interference.
7. The SERS spectroscopy cloud-based deep learning platform for food safety testing according to claim 5, characterized in that: The knowledge of the multimodal fusion model is migrated to a lightweight quantum network deployable at the edge based on knowledge distillation technology. The output distribution of the cloud model and the sub-network is aligned using the KL divergence loss function: Among them, p cloud With p edge These are the classification probability distributions of the cloud multimodal model and the edge sub-network, respectively.
8. The SERS spectroscopy cloud-based deep learning platform for food safety testing according to claim 3, characterized in that: The elastic incremental learning unit applies dynamic constraints on high-frequency activation parameters by improving the elastic weight solidification algorithm, thereby suppressing catastrophic forgetting while adapting to new tasks. The specific improvements include the following steps: Set dynamic thresholds based on statistical quantiles to filter out high-frequency activation parameters; Improve incremental training efficiency by shielding the calculation of low-frequency parameters; Introducing a forgetting suppression verification mechanism to automatically test performance on historical task verification sets after incremental training; Balance model stability and adaptability through iterative optimization.
9. The SERS spectroscopy cloud-based deep learning platform for food safety testing according to claim 4, characterized in that: The differential encoding implementation in the bandwidth optimization transmission unit is as follows: For continuous spectral frame S t With S t-1 Compute the point-wise difference matrix: ΔS t =S t -S t-1 ; When there is a mutation point |ΔS t [i]|>δ, then switch to absolute value encoding: ΔS t =S t ; Coding optimization: The adaptive threshold δ is dynamically adjusted according to the standard deviation of historical data, δ = 2σ t-1 , to avoid the error accumulation caused by fixed thresholds.
10. The SERS spectroscopy cloud-based deep learning platform for food safety testing according to claim 2, characterized in that: The adaptive filtering equation in the adaptive nonlinear filtering unit is: in: Input spectrum signal, N is the number of wavelength points; φ i (·): a set of basis functions, including the Gaussian kernel Piecewise Polynomial and Mexican Hat Wavelet α i (x)∈[0,1]: dynamic weights, predicted by lightweight CNN; β(x)∈[0,1]: noise suppression coefficient, constrained by the Sigmoid function; Noise gating module, convolution kernel size 5, output channels 16.