A method and system for food packaging integrity detection based on convolutional neural network

By combining convolutional neural networks and deep learning algorithms with attention mechanisms, the problem of low accuracy in food packaging inspection has been solved, enabling efficient identification of subtle defects and dynamic risk assessment, thereby improving the accuracy and adaptability of food packaging integrity inspection.

CN119919352BActive Publication Date: 2026-05-29CSSC HAISHEN MEDICAL TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CSSC HAISHEN MEDICAL TECH CO LTD
Filing Date
2024-12-18
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

Existing methods for detecting the integrity of food packaging rely on traditional manual inspection or simple image processing, which suffer from low detection accuracy, poor adaptability, and slow response speed, making it difficult to effectively identify subtle or complex packaging defects.

Method used

A food packaging integrity detection method based on convolutional neural networks is adopted, which combines attention mechanism and deep learning algorithm. Through multi-level feature analysis and dynamic risk assessment, production control can be detected and optimized in real time.

Benefits of technology

It significantly improves detection accuracy and adaptability, enabling rapid identification of various packaging defects, enhancing the detection efficiency and quality of the production line, and strengthening the system's adaptability and response efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119919352B_ABST
    Figure CN119919352B_ABST
Patent Text Reader

Abstract

The application provides a food packaging integrity detection method and system based on a convolutional neural network. A high-definition camera deployed from multiple angles on a production line acquires food packaging images in real time to obtain a food packaging image dataset. Based on the food packaging image dataset, the food packaging images are subjected to anomaly detection processing to generate a preliminary anomaly detection result. According to the preliminary anomaly detection result, a deep reinforcement learning algorithm is used to dynamically assess the risk of abnormal conditions to obtain an anomaly confirmation report. Using the anomaly confirmation report, the cloud service platform feeds back the detection result to the production control system in real time, adaptively adjusts the speed of the production line, the selection of packaging materials, or early warning information, and generates an optimized production control scheme. The technical solution provided by the application significantly improves the detection accuracy of food packaging defects and effectively solves the problem of low detection accuracy in existing solutions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of food packaging integrity detection technology, and in particular to a food packaging integrity detection method and system based on convolutional neural networks. Background Technology

[0002] With the rapid development of the food industry, the requirements for product quality and safety are increasing. Food packaging, as a crucial link in ensuring food safety, directly affects the product's shelf life, safety, and brand image. In actual production, mechanical failures, material problems, or operational errors can lead to issues such as damaged packaging and inadequate sealing. This can not only affect food quality but also potentially result in serious consequences such as product recalls.

[0003] Existing methods for inspecting the integrity of food packaging mainly rely on traditional manual visual inspection or automated inspection systems based on simple image processing technology. While these methods can meet basic inspection needs to a certain extent, they have the following limitations: manual visual inspection is time-consuming and labor-intensive and easily affected by subjective factors, making it difficult to guarantee the consistency and accuracy of the inspection; automated inspection systems based on traditional image processing technology can usually only identify predefined specific types of defects and have poor adaptability to complex and varied packaging styles.

[0004] Traditional image processing algorithms are limited by their feature extraction capabilities, making it difficult to effectively identify subtle or complex packaging defects, resulting in low detection accuracy. Existing systems often use fixed rules for anomaly detection, which cannot adapt well to the impact of changes in conditions between different batches of products or within the same production line at different times. The time interval between discovering a problem and taking corresponding measures is long, making it impossible to prevent unqualified products from entering the market in a timely manner. Summary of the Invention

[0005] This application provides a method and system for detecting the integrity of food packaging based on convolutional neural networks, in order to solve the problem of low detection accuracy in the prior art.

[0006] In a first aspect, embodiments of this application provide a method for detecting the integrity of food packaging based on a convolutional neural network, including:

[0007] High-definition cameras deployed from multiple angles on the production line capture real-time images of food packaging. The image data is then transmitted to a cloud server using a secure and stable network protocol to obtain a food packaging image dataset.

[0008] Based on the aforementioned food packaging image dataset, a pre-constructed and deeply optimized convolutional neural network model combined with an attention mechanism algorithm is used to perform multi-level feature analysis on key region information in the images, and anomaly detection processing is performed on the food packaging images to generate preliminary anomaly detection results.

[0009] Based on the preliminary anomaly detection results, a deep reinforcement learning algorithm is used to dynamically assess the anomaly by combining Bayesian decision theory with historical detection data of food packaging and environmental parameters, resulting in an anomaly confirmation report.

[0010] Using the aforementioned anomaly confirmation report, the detection results are fed back to the production control system in real time through the cloud service platform. The system then adaptively adjusts the production line speed, packaging material selection, or early warning information to generate an optimized production control scheme.

[0011] Optionally, based on the food packaging image dataset, a pre-constructed and deeply optimized convolutional neural network model combined with an attention mechanism algorithm is used to perform multi-level feature analysis on key region information in the images, and anomaly detection processing is performed on the food packaging images to generate preliminary anomaly detection results, including:

[0012] Using the aforementioned food packaging image dataset, multi-level feature extraction processing is performed on the image data. Local and global features in the image are captured through convolutional layers, pooling layers, and fully connected layers to obtain multi-level feature information.

[0013] Based on the multi-level feature information, the key region information in the image is weighted by the attention mechanism algorithm to highlight potential abnormal regions, reduce background interference, and obtain an optimized feature representation.

[0014] Based on the optimized feature representation, anomaly detection rules are designed to automatically identify and process anomalies in food packaging images, and anomaly detection candidate results are obtained.

[0015] Using the anomaly detection candidate results, the detection model is tested multiple times using cross-validation technology to evaluate the accuracy of anomaly detection, ensure the stability and consistency of the model under different conditions, and generate optimized anomaly detection rules.

[0016] Based on the optimized anomaly detection rules, preliminary anomaly detection results are generated.

[0017] Optionally, the step of weighting key region information in the image based on the multi-level feature information and combining it with an attention mechanism algorithm to highlight potential abnormal regions, reduce background interference, and obtain an optimized feature representation includes:

[0018] In calculating attention weight A iBeforehand, it is necessary to aggregate feature information at different levels and apply normalization techniques to enhance meaningful features and reduce internal covariate shifts, thereby ensuring consistency between feature maps.

[0019]

[0020] Among them, A i F represents the attention weight of the i-th feature map; i W is the i-th feature map extracted from multi-level feature information; a and b a These are the weight matrix and bias vector in the attention mechanism, respectively; N is the total number of feature maps; W c and b c These are the weight matrix and bias vector used to enhance the nonlinear transformation of the feature map; α is a hyperparameter used to adjust the effect of the ReLU nonlinear transformation; W e and b e These are the weight matrix and bias vector used to introduce the softmax function; γ is a hyperparameter used to adjust the effect of the softmax function; ReLU is the activation function used to introduce nonlinearity; softmax is the activation function used to introduce normalization.

[0021] After calculating the attention weight A i Then, it is combined with the original feature map, and weighted and nonlinear transformations are used to reduce background noise, highlight the target region, and generate an optimized feature representation O. i ;

[0022] O i =σ(W o ·(A i +W b ·B i +β·tanh(W d ·(A i -B i )+b d )+δ·sigmoid(W f ·(A i +B i )+b f ))+b o )

[0023] Among them, O i It is the optimized i-th feature representation; W o and b o It is used to generate the weight matrix and bias vector for optimizing feature representations; W b It is a weight matrix used to reduce background interference; B i Based on F iThe calculated background feature map is obtained through a specific background extraction algorithm; σ is an activation function used to introduce nonlinearity; W d and b d These are the weight matrix and bias vector used to further process the attention weights and background feature map differences; β is a hyperparameter used to adjust the impact of background feature map differences; W f and b f δ is the weight matrix and bias vector used to introduce the sigmoid function; δ is a hyperparameter used to adjust the influence of the sigmoid function; tanh is the activation function used to enhance the contrast of the feature map; sigmoid is the activation function used to introduce nonlinear transformations and normalization processing.

[0024] After calculating the optimized feature representation O i Then, through steps such as feature dimensionality reduction, selection, and fusion, redundant information is removed, the most representative features are retained, and the generalization ability and feature representation efficiency of the model are improved.

[0025] Optionally, the step of designing anomaly detection rules based on the optimized feature representation to automatically identify anomalies in food packaging images and obtain anomaly detection candidate results includes:

[0026] Based on the optimized feature representation, common anomaly types in food packaging images are analyzed and processed to obtain a key feature set of anomaly types.

[0027] Based on the key feature set of the anomaly type, design detection rules for different anomaly types and generate an anomaly detection rule set;

[0028] Using the aforementioned anomaly detection rule set, anomalies in food packaging images are automatically identified and processed. By comparing the features in the image with preset rules, possible abnormal areas are marked, and anomaly detection marks are generated.

[0029] Based on the anomaly detection markers, and combined with the probability and confidence assessment of anomaly occurrence, a comprehensive evaluation is performed on each suspected anomaly region to obtain anomaly detection candidate results.

[0030] Optionally, the step of using the anomaly detection candidate results to test the detection model multiple times through cross-validation to evaluate the accuracy of anomaly detection, ensure the stability and consistency of the model under different conditions, and generate optimized anomaly detection rules includes:

[0031] Using the anomaly detection candidate results, the detection results are compared with the real labels. The detection model is tested multiple times using cross-validation technology to ensure that a different subset of data is used as the validation set for each test, and a model performance evaluation report is generated.

[0032] Based on the model performance evaluation report, analyze the model's performance under different conditions and evaluate the accuracy of anomaly detection;

[0033] Based on the accuracy assessment of the anomaly detection, weaknesses of the model under specific conditions are identified, anomaly detection rules are adjusted accordingly, key feature indicators of anomaly types are optimized, and optimization suggestions are generated.

[0034] Using the aforementioned optimization suggestions, the anomaly detection rules are iteratively optimized to ensure the stability and consistency of the model under different conditions, and to generate optimized anomaly detection rules.

[0035] Optionally, based on the preliminary anomaly detection results, a deep reinforcement learning algorithm is used to dynamically assess the risk of the anomaly by combining Bayesian decision theory with historical detection data of food packaging and environmental parameters, resulting in an anomaly confirmation report, including:

[0036] Based on the preliminary anomaly detection results, combined with historical detection data of food packaging and current environmental parameters, a risk assessment model for the anomaly is constructed, and an initial risk assessment framework is generated.

[0037] Using Bayesian decision theory, a probability analysis is performed on the location, type, and confidence level of the anomalies in the preliminary anomaly detection results to quantify the probability of anomalies occurring and generate an anomaly probability assessment.

[0038] Based on the aforementioned anomaly probability assessment, a deep reinforcement learning algorithm is used to simulate the long-term impact of different processing strategies, dynamically adjust the anomaly processing strategy to reduce the negative impact of anomalies, and generate a strategy optimization scheme.

[0039] Using the aforementioned strategy optimization scheme, dynamic risk assessment and processing of abnormal situations are carried out, taking into account the probability of the abnormality, the degree of impact, and the processing cost factors, and an abnormality confirmation report is generated.

[0040] Optionally, based on the anomaly probability assessment, the step of using a deep reinforcement learning algorithm to simulate the long-term effects of different processing strategies, dynamically adjusting the anomaly processing strategy to reduce the negative impact of anomalies, and generating a strategy optimization scheme includes:

[0041] In calculating future return R t Previously, a comprehensive analysis of the anomaly detection results and the current state was required to ensure that the model could fully consider the long-term impact.

[0042]

[0043] Among them, R t r represents the total future returns starting from time t; t+kγ is the immediate reward obtained at time t+k; T is the total length of the time series; γ is a discount factor used to reduce the importance of future rewards; γ k λ is a discount factor used to make the model focus more on short-term gains without excessively ignoring long-term gains; λ is a hyperparameter used to adjust the impact of changes in state value; V(s) t+k ) is in state s t+k The state value under the following conditions; V(s) t ) is in the current state s t The state value is determined by ReLU, an activation function used to introduce nonlinearity to ensure that positive changes in state value have a positive impact on the reward; μ is a hyperparameter used to adjust the effect of state distance; D(s) t+k s t ) is state s t+k and state s t The distance metric between the two values; sigmoid is an activation function used to introduce non-linear transformations and normalization processes to ensure that a positive value of the distance metric has a positive impact on the reward.

[0044] After calculating the future return R t Then, update the state-action value function Q(s). t a t ), introducing the heuristic function H(s) t a t ) and conflict metric C(s) t a t ), generate the optimal action selection probability π θ (a t |s t This ensures that the chosen actions maximize returns while avoiding potential risks.

[0045]

[0046] Where, π θ (a t |s t ) indicates that in state s t Choose action a t The probability of Q(s) is determined by the policy network parameter θ; t a t ;θ) is the state-action value function, representing the state-action value in state s. t Take action a t The expected return; β is a hyperparameter used to adjust the heuristic function H(s). t a t The influence of ); H(s t a t) is a heuristic function used to provide additional policy guidance; tanh is an activation function used to introduce nonlinearity and enhance policy flexibility; η is a hyperparameter used to adjust the influence of conflict metrics; C(s) t a t ) is to take action a in state st. t The conflict metric is used to assess the feasibility and potential risks of actions; ReLU is an activation function used to introduce nonlinearity to ensure that a positive value of the conflict metric has a positive impact on the policy; τ is a temperature parameter used to control the balance between exploration and exploitation in the policy; softmax is an activation function used to transform the state-action value function into a probability distribution.

[0047] After calculating the optimal action selection probability π θ (a t |s t After that, the optimal action is selected and executed. The parameters of the policy network are updated through online or offline learning. The policy performance is evaluated and dynamically adjusted regularly. Finally, a solution that can dynamically optimize the anomaly handling strategy is generated, reducing the negative impact of anomalies and improving system performance and stability.

[0048] Optionally, the step of using Bayesian decision theory to perform probabilistic analysis on the anomaly location, type, and confidence level in the preliminary anomaly detection results, quantifying the probability of anomaly occurrence, and generating an anomaly probability assessment includes:

[0049] Based on the preliminary anomaly detection results, key information such as anomaly location, type, and confidence level are extracted to construct a probability model of the anomaly event.

[0050] Using Bayesian decision theory and historical inspection data of food packaging, a priori estimation of the probability of abnormal events is performed to form a prior probability distribution.

[0051] Based on the prior probability distribution, and combined with the anomaly location, type and confidence level in the current detection results, the probability of the anomaly event actually occurring under the current detection conditions is calculated to obtain the posterior probability.

[0052] Using the posterior probability, the actual probability of an abnormal event is quantitatively analyzed to generate an anomaly probability assessment.

[0053] Optionally, the step of using the anomaly confirmation report to provide real-time feedback of detection results to the production control system via a cloud service platform, adaptively adjusting the production line speed, packaging material selection, or early warning information, and generating an optimized production control scheme includes:

[0054] Using the aforementioned anomaly confirmation report, the detection results are organized and analyzed, and the detection results are fed back to the production control system in real time through the cloud service platform to obtain production control instructions;

[0055] Based on the production control instructions, the production parameters of the production line are evaluated to determine a list of production parameters that need to be adjusted.

[0056] Based on the list of production parameters that need to be adjusted, an adaptive adjustment strategy is designed and implemented, and automated control technology is used to precisely adjust the production process to generate the adjusted production state.

[0057] Based on the adjusted production status, when an abnormal situation is detected, an early warning message is issued immediately to remind operators to take corresponding measures and generate an optimized production control plan.

[0058] Secondly, embodiments of this application provide a food packaging integrity detection system based on a convolutional neural network, comprising:

[0059] The transmission module is used to capture food packaging images in real time from high-definition cameras deployed from multiple angles on the production line, and transmit the image data to the cloud server using a secure and stable network protocol to obtain a food packaging image dataset.

[0060] The analysis module is used to perform multi-level feature analysis on key region information in the images based on the food packaging image dataset, using a pre-built and deeply optimized convolutional neural network model combined with an attention mechanism algorithm, to perform anomaly detection processing on the food packaging images and generate preliminary anomaly detection results.

[0061] The evaluation module is used to perform dynamic risk assessment of the abnormal situation based on the preliminary anomaly detection results, combining Bayesian decision theory with historical detection data of food packaging and environmental parameters, and using deep reinforcement learning algorithms to obtain an anomaly confirmation report.

[0062] The adjustment module is used to use the anomaly confirmation report to feed back the detection results to the production control system in real time through the cloud service platform, and to adaptively adjust the speed of the production line, the selection of packaging materials or early warning information to generate an optimized production control scheme.

[0063] Thirdly, embodiments of this application provide a computing device, including a processing component and a storage component; the storage component stores one or more computer instructions; the one or more computer instructions are to be invoked and executed by the processing component to implement a food packaging integrity detection method based on a convolutional neural network as described in the first aspect.

[0064] Fourthly, embodiments of this application provide a computer storage medium, characterized in that it stores a computer program, which, when executed by a computer, implements a food packaging integrity detection method based on a convolutional neural network as described in the first aspect.

[0065] In this embodiment, high-definition cameras deployed from multiple angles on the production line capture food packaging images in real time. The image data is transmitted to a cloud server using a secure and stable network protocol, resulting in a food packaging image dataset. Based on this dataset, a pre-built and deeply optimized convolutional neural network model combined with an attention mechanism algorithm is used to perform multi-level feature analysis on key areas in the images, performing anomaly detection processing on the food packaging images to generate preliminary anomaly detection results. According to these preliminary anomaly detection results, a deep reinforcement learning algorithm is used to dynamically assess the risks of anomalies using Bayesian decision theory combined with historical detection data and environmental parameters of the food packaging, resulting in an anomaly confirmation report. Using this anomaly confirmation report, the detection results are fed back to the production control system in real time through a cloud service platform, allowing for adaptive adjustments to the production line speed, packaging material selection, or early warning information, generating an optimized production control scheme.

[0066] The technical solution of this application has the following beneficial effects:

[0067] By employing a food packaging integrity detection method based on convolutional neural networks and incorporating an attention mechanism, the feature analysis capability and anomaly identification accuracy during the detection process can be significantly improved. Specifically addressing the "low detection accuracy" deficiency mentioned in existing solutions, this invention utilizes the powerful feature representation capabilities of deep learning models to more effectively capture subtle differences in images, thereby improving the recognition rate for various types of packaging defects. Furthermore, this method introduces a risk assessment mechanism combining Bayesian decision theory and deep reinforcement learning, making the entire detection process more intelligent and flexible, capable of dynamically adjusting strategies based on actual conditions, further enhancing the system's practical value and economic benefits.

[0068] Furthermore, this application provides an anomaly detection method based on a food packaging image dataset. It utilizes a pre-constructed and deeply optimized convolutional neural network model combined with an attention mechanism algorithm to perform multi-level feature analysis on key regions in the image. First, the method captures local and global features of the image using convolutional layers, pooling layers, and fully connected layers to obtain multi-level feature information. Then, it combines an attention mechanism algorithm to weight key regions, highlighting potential anomaly areas, reducing background interference, and generating optimized feature representations. Next, based on the optimized feature representations, anomaly detection rules are designed to automatically identify anomalies and obtain candidate anomaly detection results. Finally, the model is tested multiple times using cross-validation to evaluate its accuracy, ensuring stability and consistency under different conditions, and ultimately generating preliminary anomaly detection results. This method significantly improves the detection accuracy of food packaging defects through multi-level feature extraction and an attention mechanism, effectively solving the problem of low detection accuracy in existing solutions and enhancing the stability and consistency of the model under different conditions.

[0069] Furthermore, this application provides a dynamic risk assessment method based on preliminary anomaly detection results. By combining historical detection data of food packaging with current environmental parameters, a risk assessment model is constructed. This method utilizes Bayesian decision theory to perform probabilistic analysis on the location, type, and confidence level of anomalies, generating an anomaly probability assessment. Then, a deep reinforcement learning algorithm is used to simulate the long-term impact under different handling strategies, dynamically adjusting the anomaly handling strategy to reduce negative impacts and generating a strategy optimization scheme. Finally, considering the probability of the anomaly, its impact degree, and handling cost factors, an anomaly confirmation report is generated. This method, through Bayesian decision theory and deep reinforcement learning algorithms, achieves dynamic risk assessment and optimization of handling strategies for anomalies, effectively solving the problems of lack of flexibility and slow response speed in existing solutions, and improving the system's adaptability and response efficiency.

[0070] These or other aspects of this application will become more apparent in the following description of the embodiments. Attached Figure Description

[0071] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0072] Figure 1 A flowchart illustrating a food packaging integrity detection method based on a convolutional neural network, provided for embodiments of this application;

[0073] Figure 2 A schematic diagram of the structure of a food packaging integrity detection system based on a convolutional neural network, provided in an embodiment of this application;

[0074] Figure 3 This is a schematic diagram of the structure of a computing device provided in an embodiment of this application. Detailed Implementation

[0075] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.

[0076] In some of the processes described in the specification, claims, and accompanying drawings of this application, multiple operations appearing in a specific order are included. However, it should be clearly understood that these operations may not be executed in the order they appear herein, or may be executed in parallel. The operation numbers, such as 101, 102, etc., are merely used to distinguish different operations and do not themselves represent any execution order. Furthermore, these processes may include more or fewer operations, and these operations may be executed sequentially or in parallel. It should be noted that the descriptions such as "first," "second," etc., in this document are used to distinguish different messages, devices, modules, etc., and do not represent a chronological order, nor do they limit "first" and "second" to different types.

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

[0078] Figure 1 A flowchart of a food packaging integrity detection method based on a convolutional neural network is provided in this application embodiment, as shown below. Figure 1 As shown, the method includes:

[0079] 101. High-definition cameras deployed from multiple angles on the production line capture food packaging images in real time, and use a secure and stable network protocol to transmit the image data to a cloud server to obtain a food packaging image dataset;

[0080] High-definition cameras are video recording devices capable of providing high-resolution images, used to capture detailed visual information of food packaging. Secure and stable network protocols are technical standards that ensure data is not tampered with or lost during transmission, such as HTTPS and TLS. Cloud servers are computing resources located on the internet, used to store and process large amounts of data. A food packaging image dataset is a collection of food packaging images captured by high-definition cameras and transmitted to a cloud server.

[0081] In this embodiment, multiple high-definition cameras are installed on the production line to capture images of food packaging in real time from different angles. These images are transmitted to a cloud server via a secure and stable network protocol, forming a dataset containing various food packaging images, providing basic data for subsequent anomaly detection and analysis.

[0082] Suppose a food processing plant has two production lines, each equipped with four high-definition cameras positioned above, below, and on either side of the production line. These cameras continuously capture images of the food packaging at 10 frames per second. The captured images are uploaded to an Alibaba Cloud server via the factory's internal local area network, encrypted using the HTTPS protocol. The server receives and stores these images, forming a dataset of thousands of food packaging images, which is then used for subsequent deep learning model training and anomaly detection.

[0083] 102. Based on the food packaging image dataset, a pre-constructed and deeply optimized convolutional neural network model combined with an attention mechanism algorithm is used to perform multi-level feature analysis on key region information in the image, and anomaly detection processing is performed on the food packaging image to generate preliminary anomaly detection results.

[0084] Convolutional Neural Networks (CNNs) are deep learning models particularly well-suited for processing image data, automatically extracting features from images. Attention mechanisms are techniques that enhance a model's focus on specific regions, helping it more accurately identify key areas. Multi-level feature analysis refers to a model's ability to simultaneously capture both local details and global structure of an image.

[0085] In this step, a pre-trained convolutional neural network model, combined with an attention mechanism algorithm, is used to analyze images in the food packaging image dataset. The model extracts multi-level features from the images through convolutional layers, pooling layers, and fully connected layers, and highlights potential abnormal regions through the attention mechanism. Finally, the model generates preliminary anomaly detection results, indicating the possible locations and types of defects.

[0086] Optionally, in step 102, based on the food packaging image dataset, a pre-constructed and deeply optimized convolutional neural network model combined with an attention mechanism algorithm is used to perform multi-level feature analysis on key region information in the image, and anomaly detection processing is performed on the food packaging image to generate preliminary anomaly detection results, including:

[0087] Using the aforementioned food packaging image dataset, multi-level feature extraction processing is performed on the image data. Local and global features in the images are captured through convolutional layers, pooling layers, and fully connected layers to obtain multi-level feature information. Based on this multi-level feature information, an attention mechanism algorithm is used to weight key regions in the image, highlighting potential abnormal areas and reducing background interference, resulting in an optimized feature representation. Based on the optimized feature representation, anomaly detection rules are designed to automatically identify anomalies in the food packaging images, obtaining anomaly detection candidate results. Using these anomaly detection candidate results, the detection model is tested multiple times using cross-validation technology to evaluate the accuracy of anomaly detection, ensuring the model's stability and consistency under different conditions, and generating optimized anomaly detection rules. Based on the optimized anomaly detection rules, preliminary anomaly detection results are finally generated.

[0088] The step of designing anomaly detection rules based on the optimized feature representation to automatically identify anomalies in food packaging images and obtain anomaly detection candidate results includes:

[0089] Based on the optimized feature representation, common anomaly types in food packaging images are analyzed and processed to obtain key feature sets for each anomaly type. Based on these key feature sets, detection rules for different anomaly types are designed, generating an anomaly detection rule set. Using this rule set, anomalies in food packaging images are automatically identified. By comparing features in the image with preset rules, potentially abnormal regions are marked, generating anomaly detection markers. Based on these anomaly detection markers, and combined with anomaly probability and confidence assessment, each suspected anomaly region is comprehensively evaluated to obtain anomaly detection candidate results.

[0090] The process of utilizing the anomaly detection candidate results to conduct multiple tests on the detection model using cross-validation techniques to evaluate the accuracy of anomaly detection, ensure the stability and consistency of the model under different conditions, and generate optimized anomaly detection rules includes:

[0091] Using the anomaly detection candidate results, the detection results are compared with the true labels. The detection model is tested multiple times using cross-validation, ensuring that a different subset of data is used as the validation set for each test, generating a model performance evaluation report. Based on the performance evaluation report, the model's performance under different conditions is analyzed to assess the accuracy of anomaly detection. Based on the accuracy assessment, weaknesses of the model under specific conditions are identified, and the anomaly detection rules are adjusted accordingly, optimizing key feature indicators of anomaly types and generating optimization suggestions. Using these optimization suggestions, the anomaly detection rules are iteratively optimized to ensure the model's stability and consistency under different conditions, generating optimized anomaly detection rules.

[0092] In this embodiment, firstly, multi-level feature extraction processing is performed using a food packaging image dataset, capturing local and global features in the image through convolutional layers, pooling layers, and fully connected layers; secondly, an attention mechanism algorithm is used to weight key region information in the image, highlighting potential abnormal regions and reducing background interference to obtain optimized feature representations; thirdly, based on the optimized feature representations, anomaly detection rules are designed to automatically identify anomalies in food packaging images, obtaining anomaly detection candidate results; finally, the detection model is tested multiple times using cross-validation technology to evaluate the accuracy of anomaly detection, ensuring the stability and consistency of the model under different conditions, and generating optimized anomaly detection rules.

[0093] Suppose a food processing plant wants to improve the accuracy of packaging integrity detection on its production line. First, a large number of food packaging images are collected from high-definition cameras installed on the production line and transmitted to a cloud server via a secure and stable network protocol, forming a dataset containing thousands of images. Second, a pre-built and deeply optimized convolutional neural network model is used. This model extracts multi-level features from the images through convolutional layers, pooling layers, and fully connected layers, capturing local and global features such as packaging edges and color changes. Next, an attention mechanism algorithm is used to weight key areas in the images, such as seals, highlighting potential anomalies and reducing background noise, resulting in optimized feature representations. Then, based on these optimized feature representations, common anomaly types (such as loose seals, damage, etc.) are analyzed, and detection rules for different anomaly types are designed, generating an anomaly detection rule set. This set of rules is then used to... The system automatically identifies and processes new food packaging images, marking potentially abnormal areas. It then combines the probability and confidence of anomalies to generate candidate anomaly detection results. Finally, cross-validation is used to test the detection model multiple times, each time using a different subset of data as the validation set. A model performance evaluation report is generated, analyzing the model's performance under different conditions, identifying weaknesses in specific conditions, and adjusting anomaly detection rules accordingly. Key feature indicators for anomaly types are optimized, generating optimization suggestions. These suggestions are then used to iteratively optimize the anomaly detection rules, ensuring the model's stability and consistency under different conditions, and generating the final preliminary anomaly detection results. Through these steps, food processing plants can detect packaging defects on the production line in real time and efficiently, improving production quality and efficiency.

[0094] This application addresses the need for attention mechanisms in food packaging integrity detection methods based on convolutional neural networks. To enhance focus on key regions in images and reduce background interference, an attention mechanism algorithm is introduced. By calculating the attention weights for each feature map, potential abnormal regions can be highlighted, thereby generating optimized feature representations and further improving the model's detection accuracy and robustness.

[0095] Optionally, the step of weighting key region information in the image based on the multi-level feature information and combining it with an attention mechanism algorithm to highlight potential abnormal regions, reduce background interference, and obtain an optimized feature representation includes:

[0096] In calculating attention weight A i Beforehand, it is necessary to aggregate feature information at different levels and apply normalization techniques to enhance meaningful features and reduce internal covariate shifts, thereby ensuring consistency between feature maps.

[0097]

[0098] Among them, Ai F represents the attention weight of the i-th feature map; i W is the i-th feature map extracted from multi-level feature information; a and b a These are the weight matrix and bias vector in the attention mechanism, respectively; N is the total number of feature maps; W c and b c These are the weight matrix and bias vector used to enhance the nonlinear transformation of the feature map; α is a hyperparameter used to adjust the effect of the ReLU nonlinear transformation; W e and b e These are the weight matrix and bias vector used to introduce the softmax function; γ is a hyperparameter used to adjust the effect of the softmax function; ReLU is the activation function used to introduce nonlinearity; softmax is the activation function used to introduce normalization.

[0099] After calculating the attention weight A i Then, it is combined with the original feature map, and weighted and nonlinear transformations are used to reduce background noise, highlight the target region, and generate an optimized feature representation O. i ;

[0100] O i =σ(W o ·(A i +W b ·B i +β·tanh(W d ·(A i -B i )+b d )+δ·sigmoid(W f ·(A i +B i )+b f ))+b o )

[0101] Among them, O i It is the optimized i-th feature representation; W o and b o It is used to generate the weight matrix and bias vector for optimizing feature representations; W b It is a weight matrix used to reduce background interference; B i Based on F i The calculated background feature map is obtained through a specific background extraction algorithm; σ is an activation function used to introduce nonlinearity; W d and b d These are the weight matrix and bias vector used to further process the attention weights and background feature map differences; β is a hyperparameter used to adjust the impact of background feature map differences; W f and bf δ is the weight matrix and bias vector used to introduce the sigmoid function; δ is a hyperparameter used to adjust the influence of the sigmoid function; tanh is the activation function used to enhance the contrast of the feature map; sigmoid is the activation function used to introduce nonlinear transformations and normalization processing.

[0102] After calculating the optimized feature representation O i Then, through steps such as feature dimensionality reduction, selection, and fusion, redundant information is removed, the most representative features are retained, and the generalization ability and feature representation efficiency of the model are improved.

[0103] This formula aims to introduce an attention mechanism in the design of an algorithm for food packaging integrity detection. This mechanism helps the model focus more on key regions in the image while reducing the impact of background noise. Through a series of carefully designed steps, including feature extraction, nonlinear transformation, and normalization, we calculate the importance weight of each image portion. These weights are then used to emphasize important features while relatively weakening the role of irrelevant background information. This process not only enhances the model's sensitivity to potential problem areas but also improves the accuracy and reliability of the detection results. In short, this design aims to improve the performance of the entire detection system by optimizing feature representation.

[0104] The following is a brief introduction to the design rationale behind each term of the formula:

[0105]

[0106] Linear transformation part: W a ·F i +b a : Used for basic linear transformations to extract features;

[0107] Nonlinear transformation part: α·ReLU(W) c ·F i +b c ): Introducing nonlinearity to enhance feature representation ability;

[0108] Normalization process: γ·softmax(W) e ·F i +b e ): Normalization is performed using the softmax function to ensure a reasonable weight distribution;

[0109] The following is a brief introduction to how the parameters of this formula are obtained:

[0110] W a b a W c b c We b e These are the weight matrix and bias vector learned during training; α and γ are hyperparameters, whose optimal values ​​are usually determined through methods such as cross-validation; F i It is the i-th feature map extracted from multi-level feature information;

[0111] The following is a brief introduction to the design rationale behind each term of the formula:

[0112] O i =σ(W o ·(A i +W b ·B i +β·tanh(W d ·(A i -B i )+b d )+δ·sigmoid(W f ·(A i +B i )+b f ))+b o )

[0113] Background feature map processing part: β·tanh(W d ·(A i -B i )+b d ): The tanh function is used to handle the difference between attention weights and background feature maps, reducing background interference;

[0114] Feature fusion part: δ·σ(W f ·(A i +B i )+b f ): Enhance feature representation by fusing attention weights and background feature maps using the sigmoid function;

[0115] Final activation part: σ(W) o ·(...)+b o ): The final optimized feature representation is generated through the activation function σ;

[0116] The following is a brief introduction to how the parameters of this formula are obtained:

[0117] W o b o W b W d b d W f b f Similarly, β and δ are learned during training; they are hyperparameters and also need to be adjusted using a similar method; Bi Based on F i Background feature map obtained through a specific background extraction algorithm;

[0118] Suppose a feature map F i =[1, 2, 3, 4], W a = [0.5, 0.5, 0.5, 0.5], b a =0.1, W c = [0.2, 0.2, 0.2, 0.2], b c =0.05, α=1.0, W e = [0.3, 0.3, 0.3, 0.3], b e =0.15, γ=0.5;

[0119] First, calculate the linear transformation part: W a ·F i +b a =0.5×1+0.5×2+0.5×3+0.5×4+0.1=5.1; Nonlinear transformation part: ReLU(W c ·F i +b c )=max(0,0.2×1+0.2×2+0.2×3+0.2×4+0.05)=1.85;

[0120] Normalization process: softmax(W) e ·F i +b e )=softmax([0.3×1+0.3×2+0.3×3+0.3×4+0.15])=softmax([3.15])=[1.0];

[0121] Attention weight

[0122] Background Feature Map B i = [-1, -2, -3, -4], W b = [0.4, 0.4, 0.4, 0.4], W d =[0.1, 0.1, 0.1, 0.1], b d =0.2, β=0.8, W f =[0.15, 0.15, 0.15, 0.15], b f =0.1, δ=0.6;

[0123] Background feature map processing part: tanh(W) d ·(A i -B i )+b d)=tanh([0.1×(1-(-1))+0.2])=tanh([0.4])=0.3799;

[0124] Feature fusion part: σ(W) j ·(A i +B i )+b f )=σ([0.15×(1+(-1))+0.1])=σ([0.1])=0.5249;

[0125] Final optimized feature representation O i =σ(W o ·(1.0+0.4×(-1)+0.8×0.3799+0.6×0.5249)+b o );

[0126] Assume W o = [0.6, 0.6, 0.6, 0.6], b o =0.3, then O i =σ([0.6×(1.0-0.4+0.304+0.315)+0.3])=σ([0.6×1.219+0.3])=σ([1.0314])=0.736;

[0127] Through the above steps, we obtained the optimized feature representation O. i =0.736, this value indicates that after the attention mechanism is applied, the information in the key regions is significantly enhanced, while background noise is effectively suppressed, thereby improving the model's ability to identify anomalies. Suppose we set a threshold to distinguish between normal and abnormal situations, for example, a threshold of 0.5. Since O i =0.736 is greater than the set threshold of 0.5, so this indicates that the area is a potential abnormal area and needs to be closely monitored.

[0128] 103. Based on the preliminary anomaly detection results, using Bayesian decision theory combined with historical detection data of food packaging and environmental parameters, a deep reinforcement learning algorithm is used to perform dynamic risk assessment of the anomaly and obtain an anomaly confirmation report.

[0129] Bayesian decision theory is a statistical method used to make optimal decisions based on prior knowledge and current observation data. Historical detection data includes various anomalies recorded in past detections and their handling results. Environmental parameters refer to external factors that affect the detection results, such as temperature and humidity. Deep reinforcement learning algorithms are machine learning techniques that learn optimal behavioral patterns by simulating different strategies.

[0130] In this step, based on the preliminary anomaly detection results, combined with historical detection data and current environmental parameters, Bayesian decision theory is used to quantify the probability of anomaly occurrence. Then, deep reinforcement learning algorithms are used to simulate the long-term impact of different handling strategies, dynamically adjusting the anomaly handling strategy to reduce the negative impact of anomalies. Finally, considering the probability of the anomaly, its impact, and the handling cost, an anomaly confirmation report is generated.

[0131] Optionally, in step 103, based on the preliminary anomaly detection results, a deep reinforcement learning algorithm is used to dynamically assess the risk of the anomaly by combining Bayesian decision theory with historical detection data of food packaging and environmental parameters, resulting in an anomaly confirmation report, including:

[0132] Based on the preliminary anomaly detection results, combined with historical detection data of food packaging and current environmental parameters, a risk assessment model for the anomaly is constructed, generating an initial risk assessment framework. Using Bayesian decision theory, a probability analysis is performed on the anomaly location, type, and confidence level in the preliminary anomaly detection results to quantify the likelihood of anomaly occurrence and generate an anomaly probability assessment. Based on the anomaly probability assessment, a deep reinforcement learning algorithm is used to simulate the long-term impact under different handling strategies, dynamically adjusting the anomaly handling strategy to reduce the negative impact of the anomaly and generating a strategy optimization scheme. Using the strategy optimization scheme, a dynamic risk assessment is performed on the anomaly, comprehensively considering the anomaly's probability, impact, and handling cost factors, generating an anomaly confirmation report.

[0133] The step of using Bayesian decision theory to perform probabilistic analysis on the location, type, and confidence level of anomalies in the preliminary anomaly detection results, quantifying the probability of anomalies occurring, and generating an anomaly probability assessment includes:

[0134] Based on the preliminary anomaly detection results, key information such as anomaly location, type, and confidence level are extracted to construct a probability model of the anomaly event. Using Bayesian decision theory and historical detection data of food packaging, a priori estimation of the probability of the anomaly event is performed, forming a prior probability distribution. Based on the prior probability distribution and the anomaly location, type, and confidence level in the current detection results, the actual probability of the anomaly event occurring under the current detection conditions is calculated, yielding the posterior probability. Using the posterior probability, the actual likelihood of the anomaly event is quantitatively analyzed, generating an anomaly probability assessment.

[0135] In this embodiment, firstly, based on preliminary anomaly detection results, combined with historical detection data of food packaging and current environmental parameters, a risk assessment model for the anomaly is constructed, generating an initial risk assessment framework. Secondly, Bayesian decision theory is used to perform probabilistic analysis on the anomaly location, type, and confidence level, quantifying the likelihood of the anomaly occurring and generating an anomaly probability assessment. Thirdly, based on the anomaly probability assessment, a deep reinforcement learning algorithm is used to simulate the long-term impact under different processing strategies, dynamically adjusting the anomaly processing strategy to reduce the negative impact of the anomaly and generating a strategy optimization scheme. Finally, the strategy optimization scheme is used to perform dynamic risk assessment processing on the anomaly, comprehensively considering the anomaly's probability, impact, and processing cost factors, and generating an anomaly confirmation report.

[0136] Suppose a food processing plant wants to conduct a dynamic risk assessment of packaging anomalies on its production line. First, based on preliminary anomaly detection results (e.g., loose seals, damage, etc.), combined with historical food packaging inspection data from the past year (including various anomalies and their handling results) and current environmental parameters (e.g., workshop temperature 25℃, humidity 60%), a risk assessment model is constructed, generating an initial risk assessment framework. Second, using Bayesian decision theory, the location (e.g., at the seal), type (e.g., loose seal), and confidence level (e.g., 90%) of the anomaly are extracted to construct a probability model of the anomaly event. This model is then combined with historical inspection data to perform a priori estimation of the probability of the anomaly event, forming a prior probability distribution. Then, based on the prior probability distribution and the anomaly location, type, and confidence level in the current inspection results, the actual probability of the anomaly event occurring under the current inspection conditions is calculated, yielding the posterior probability. Next… The process involves several steps. First, posterior probability is used to quantify the actual likelihood of anomalies, generating an anomaly probability assessment. Second, based on this assessment, deep reinforcement learning algorithms are used to simulate the long-term impact of different handling strategies (e.g., immediate shutdown for inspection, continued production with enhanced monitoring), dynamically adjusting the anomaly handling strategy to reduce its negative impact and generating an optimized strategy plan. Finally, the optimized strategy plan is used to dynamically assess the risk of anomalies, comprehensively considering their probability, impact, and handling costs, generating an anomaly confirmation report. This report details the anomaly's location, type, probability of occurrence, and recommended handling strategy. Through these steps, food processing plants can accurately and in real-time assess packaging anomaly risks on the production line and take optimal measures to improve production efficiency and product quality.

[0137] This application considers using deep reinforcement learning algorithms in food packaging integrity detection methods based on convolutional neural networks to simulate the long-term effects of different processing strategies and dynamically adjust anomaly handling strategies to reduce the negative impact of anomalies. This is achieved by calculating the future reward R. t State-action value function Q(s)t a t By combining heuristic functions and conflict metrics, the optimal action selection probability π is generated. θ (a t |s t This allows for the optimization of exception handling strategies.

[0138] Optionally, based on the anomaly probability assessment, the step of using a deep reinforcement learning algorithm to simulate the long-term effects of different processing strategies, dynamically adjusting the anomaly processing strategy to reduce the negative impact of anomalies, and generating a strategy optimization scheme includes:

[0139] In calculating future return R t Previously, a comprehensive analysis of the anomaly detection results and the current state was required to ensure that the model could fully consider the long-term impact.

[0140]

[0141] Among them, R t r represents the total future returns starting from time t; t+k γ is the immediate reward obtained at time t+k; T is the total length of the time series; γ is a discount factor used to reduce the importance of future rewards; γ k λ is a discount factor used to make the model focus more on short-term gains without excessively ignoring long-term gains; λ is a hyperparameter used to adjust the impact of changes in state value; V(s) t+k ) is in state s t+k The state value under the following conditions; V(s) t ) is in the current state s t The state value is determined by ReLU, an activation function used to introduce nonlinearity to ensure that positive changes in state value have a positive impact on the reward; μ is a hyperparameter used to adjust the effect of state distance; D(s) t+k s t ) is state s t+k and state s t The distance metric between the two values; sigmoid is an activation function used to introduce non-linear transformations and normalization processes to ensure that a positive value of the distance metric has a positive impact on the reward.

[0142] After calculating the future return R t Then, update the state-action value function Q(s). t a t ), introducing the heuristic function H(s) t a t ) and conflict metric C(s) t a t ), generate the optimal action selection probability π θ (at |s t This ensures that the chosen actions maximize returns while avoiding potential risks.

[0143]

[0144] Where, π θ (a t |s t ) indicates that in state s t Choose action a t The probability of Q(s) is determined by the policy network parameter θ; t a t ;θ) is the state-action value function, representing the state-action value in state s. t Take action a t The expected return; β is a hyperparameter used to adjust the heuristic function H(s). t a t The influence of ); H(s t a t ) is a heuristic function used to provide additional policy guidance; tanh is an activation function used to introduce nonlinearity and enhance policy flexibility; η is a hyperparameter used to adjust the influence of conflict metrics; C(s) t a t ) is in state s t Take action a t The conflict metric is used to assess the feasibility and potential risks of actions; ReLU is an activation function used to introduce nonlinearity to ensure that a positive value of the conflict metric has a positive impact on the policy; τ is a temperature parameter used to control the balance between exploration and exploitation in the policy; softmax is an activation function used to transform the state-action value function into a probability distribution.

[0145] After calculating the optimal action selection probability π θ (a t |s t After that, the optimal action is selected and executed. The parameters of the policy network are updated through online or offline learning. The policy performance is evaluated and dynamically adjusted regularly. Finally, a solution that can dynamically optimize the anomaly handling strategy is generated, reducing the negative impact of anomalies and improving system performance and stability.

[0146] The purpose of this formula is to use deep reinforcement learning algorithms to dynamically adjust anomaly handling strategies, taking into account long-term future impacts, in order to maximize system performance and reduce the negative impact of anomalies.

[0147] The following is a brief introduction to the design rationale behind each term of the formula:

[0148]

[0149] Instant rewards section r t+k : Represents the immediate reward obtained at time t+k, used to evaluate the effect of the current action;

[0150] Discount factor part γ k This is used to reduce the importance of future rewards and ensure that near-term rewards have a greater impact on decision-making.

[0151] State value change part: λ·ReLU(V(s) t+k )-V(s t ): By introducing nonlinearity through the ReLU activation function, we ensure that positive values ​​of state value changes have a positive impact on rewards;

[0152] The state distance metric part μ·sigmoid(D(s) t+k s t By introducing nonlinear transformation and normalization through the sigmoid activation function, we ensure that positive values ​​of the distance metric have a positive impact on the reward.

[0153] Instant rewards section r t+k : Represents the immediate reward obtained at time t+k, used to evaluate the effect of the current action;

[0154] Discount factor part γ k This is used to reduce the importance of future rewards and ensure that near-term rewards have a greater impact on decision-making.

[0155] The following is a brief introduction to how the parameters of this formula are obtained:

[0156] r t+k It is the immediate reward obtained through simulation or actual operation; γ is the discount factor, usually set to a value between 0.95 and 0.99; λ and μ are hyperparameters, determined through methods such as cross-validation; V(s t+k ) and V(s t ) is the state-value function obtained through training; D(s) t+k s t () is a distance metric between states, which can be Euclidean distance or other metric methods;

[0157] The following is a brief introduction to the design rationale behind each term of the formula:

[0158]

[0159] State value change part: λ·ReLU(V(s) t+k )-V(s t ): By introducing nonlinearity through the ReLU activation function, we ensure that positive values ​​of state value changes have a positive impact on rewards;

[0160] State distance metric part μ·σ(D(s) t+k s t By introducing nonlinear transformation and normalization through the sigmoid activation function, we ensure that positive values ​​of the distance metric have a positive impact on the reward.

[0161] State-action value function part: Q(s) t a t ;θ): indicates that in state s t Take action a t The expected return is the foundation for strategy optimization;

[0162] Heuristic function part β·tanh(H(s) t a t ): Introducing nonlinearity through the tanh activation function provides additional policy guidance;

[0163] Conflict measurement part η·ReLU(C(s) t a t ): By introducing nonlinearity through the ReLU activation function, we ensure that a positive value of the conflict metric has a positive impact on the policy;

[0164] Temperature parameter τ: used to balance the exploration and utilization of control strategies, ensuring that the model finds a suitable balance between exploring new strategies and utilizing existing strategies;

[0165] The following is a brief introduction to how the parameters of this formula are obtained:

[0166] θ represents the parameters of the policy network, which are learned through the training process; Q(s) t a t ;θ) is the state-action value function obtained through training; β and η are hyperparameters, determined through methods such as cross-validation; H(s) t a t C(s) is a heuristic function, designed based on domain knowledge; t a t ) is the conflict metric, designed based on domain knowledge; τ is the temperature parameter, usually set to around 1.0;

[0167] Suppose we want to optimize the anomaly handling strategy on the production line for food packaging integrity inspection. First, let's set some parameters:

[0168] γ=0.95, λ=0.1, μ=0.05, β=0.2, η=0.1, τ=1.0

[0169] Calculate future return R t :

[0170] Assume the current state is st and future states s t+1 s t+2 , ..., s t+T The state values ​​are V(s) t ) = 0.5, V(s) t+1 ) = 0.6, V(s) t+2 =0.7, ...; Instant reward r t+1 =0.1, r t+2 =0.2, ...; State distance metric D(s) t+1 s t ) = 0.1, D(s) t+2 s t ) = 0.2, ...

[0171]

[0172] R t =0.95 0 ·(0.1+0.1·ReLU(0.6-0.5)+0.05·σ(0.1))+0.95 1 ·(0.2+0.1·ReLU(0.7-0.5)+0.05·σ(0.2))+...

[0173] R t = 0.1 + 0.01 + 0.005 + 0.95 * (0.2 + 0.02 + 0.01) + ...

[0174] R t =0.115 + 0.95 * 0.23 + ...

[0175] R t =0.115+0.2185+...

[0176] R t =0.3335+...

[0177] Assume the final calculation result is R t =1.0

[0178] Update state-action value function Q(s) t a t ):

[0179] Assume Q(s) t a t ;θ)=0.8,H(s) t a t ) = 0.1, C(s) t a t ) = 0.05

[0180] Q(s t a t ;θ)+β·tanh(H(s t ,a t ))+η·ReLU(C(s t ,a t ))=0.8+0.2·tanh(0.1)+0.1·ReLU(0.05)

[0181] = 0.8 + 0.2 * 0.0996 + 0.1 * 0.05

[0182] = 0.8 + 0.01992 + 0.005

[0183] =0.82492

[0184] Calculate the optimal action selection probability π θ (a t |s t ):

[0185]

[0186] Assuming there is only one action, then π θ (a t |s t ) = 1.0

[0187] The future return R was obtained through calculation. t =1.0 and the optimal action selection probability π θ (a t |s t = 1.0. This means that in the current state, the chosen action a is... t This action is optimal, maximizing the system's long-term returns, and will yield significant positive effects in future time series. Therefore, this action can be performed, and the parameters of the policy network can be further optimized through online or offline learning to further improve the system's performance and stability.

[0188] 104. Using the aforementioned anomaly confirmation report, the detection results are fed back to the production control system in real time through the cloud service platform. The speed of the production line, the selection of packaging materials, or early warning information are adaptively adjusted to generate an optimized production control scheme.

[0189] A cloud service platform refers to a platform that provides remote computing and data processing services, enabling real-time data processing and feedback. A production control system is a system used to monitor and control the operation of a production line, capable of adjusting production parameters based on feedback information. Adaptive adjustment processing refers to automatically adjusting parameters in the production process based on real-time feedback information to optimize production efficiency and quality.

[0190] In this step, anomaly confirmation reports are used to feed the detection results back to the production control system in real time via a cloud service platform. Based on the feedback information, the control system adaptively adjusts the production line speed, packaging material selection, or issues early warnings to generate an optimized production control plan, ensuring high efficiency in the production process and product quality.

[0191] Optionally, step 104, which utilizes the anomaly confirmation report to provide real-time feedback of detection results to the production control system via a cloud service platform, adaptively adjusts the production line speed, packaging material selection, or early warning information to generate an optimized production control scheme, includes:

[0192] Using the aforementioned anomaly confirmation report, the detection results are organized and analyzed, and fed back to the production control system in real time through the cloud service platform to obtain production control instructions. Based on the production control instructions, the production parameters of the production line are evaluated to determine a list of production parameters that need to be adjusted. Based on the list of production parameters that need to be adjusted, an adaptive adjustment strategy is designed and implemented, and the production process is precisely adjusted using automated control technology to generate an adjusted production state. Combining the adjusted production state, when an anomaly is detected, an early warning message is issued immediately to remind operators to take corresponding measures, generating an optimized production control scheme.

[0193] In this embodiment, firstly, the detection results are organized and analyzed using an anomaly confirmation report, and these results are fed back to the production control system in real time through a cloud service platform to obtain corresponding production control instructions; secondly, the production parameters of the production line are evaluated based on the production control instructions to determine a list of specific parameters that need to be adjusted; thirdly, based on the list of production parameters that need to be adjusted, an adaptive adjustment strategy is designed and implemented, and the production process is precisely adjusted using automated control technology to generate the adjusted production state; finally, combined with the adjusted production state, when an anomaly is detected, an early warning message is issued in real time to remind operators to take corresponding measures and generate an optimized production control scheme.

[0194] Suppose a food processing plant wants to monitor and adaptively adjust packaging anomalies on its production line in real time. First, the inspection results are compiled and analyzed using anomaly confirmation reports (e.g., loose seals, damage), and these results are fed back to the production control system in real time through the Alibaba Cloud service platform, generating production control instructions (e.g., reducing production line speed, changing packaging materials, etc.). Second, based on the production control instructions, the current production parameters, such as the production line speed and the selection of packaging materials, are evaluated to determine a list of specific parameters that need adjustment (e.g., reducing the production line speed from 100 packs per minute to 80 packs per minute, using more durable packaging materials). Third, based on the list of production parameters that need adjustment, an adaptive adjustment strategy is designed and implemented, using automated control technology to precisely adjust the production process, generating the adjusted production status (e.g., the production line speed has been reduced to 80 packs per minute, and new packaging materials have been put into use). Finally, combined with the adjusted production status, when an anomaly is detected (e.g., loose seals), an early warning message is issued immediately to remind operators to take corresponding measures (e.g., checking whether the sealing equipment is working properly), generating an optimized production control plan. Through these steps, the food processing plant can monitor the production line status in real time and dynamically adjust production parameters according to anomalies, ensuring high efficiency in the production process and product quality.

[0195] Figure 2 This application provides a schematic diagram of the structure of a food packaging integrity detection system based on a convolutional neural network, as shown in the embodiment of the present application. Figure 2 As shown, the device includes:

[0196] Transmission module 21 is used to capture food packaging images in real time from high-definition cameras deployed from multiple angles on the production line, and transmit the image data to the cloud server using a secure and stable network protocol to obtain a food packaging image dataset.

[0197] Analysis module 22 is used to perform multi-level feature analysis on key region information in the image based on the food packaging image dataset, using a pre-built and deeply optimized convolutional neural network model combined with an attention mechanism algorithm, to perform anomaly detection processing on the food packaging image and generate preliminary anomaly detection results.

[0198] The evaluation module 23 is used to perform dynamic risk assessment of the abnormal situation based on the preliminary anomaly detection results, by combining Bayesian decision theory with historical detection data of food packaging and environmental parameters, and using a deep reinforcement learning algorithm to obtain an anomaly confirmation report.

[0199] The adjustment module 24 is used to use the anomaly confirmation report to feed back the detection results to the production control system in real time through the cloud service platform, and to adaptively adjust the speed of the production line, the selection of packaging materials or early warning information to generate an optimized production control scheme.

[0200] Figure 2 The aforementioned food packaging integrity detection system based on convolutional neural networks can perform... Figure 1 The implementation principle and technical effects of the food packaging integrity detection method based on convolutional neural networks described in the illustrated embodiment will not be repeated here. The specific methods by which each module and unit of the food packaging integrity detection system based on convolutional neural networks in the above embodiments are performed have been described in detail in the embodiments related to this method, and will not be elaborated upon here.

[0201] In one possible design, Figure 2 The food packaging integrity detection system based on convolutional neural networks shown in the embodiment can be implemented as a computing device, such as... Figure 3 As shown, the computing device may include a storage component 31 and a processing component 32;

[0202] The storage component 31 stores one or more computer instructions, wherein the one or more computer instructions are invoked and executed by the processing component 32.

[0203] The processing component 32 is used for: acquiring food packaging images in real time from high-definition cameras deployed from multiple angles on the production line; transmitting the image data to a cloud server using a secure and stable network protocol to obtain a food packaging image dataset; based on the food packaging image dataset, performing multi-level feature analysis on key region information in the images using a pre-built and deeply optimized convolutional neural network model combined with an attention mechanism algorithm to perform anomaly detection processing on the food packaging images and generate preliminary anomaly detection results; based on the preliminary anomaly detection results, using Bayesian decision theory combined with historical detection data of food packaging and environmental parameters, using a deep reinforcement learning algorithm to perform dynamic risk assessment processing on the anomaly situation and obtain an anomaly confirmation report; using the anomaly confirmation report, feeding back the detection results to the production control system in real time through the cloud service platform, adaptively adjusting the production line speed, packaging material selection, or early warning information, and generating an optimized production control scheme.

[0204] The processing component 32 may include one or more processors to execute computer instructions to complete all or part of the steps in the above-described method. Alternatively, the processing component may be implemented as one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above-described method.

[0205] Storage component 31 is configured to store various types of data to support operations at the terminal. The storage component can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.

[0206] Of course, computing devices may also include other components, such as input / output interfaces, display components, communication components, etc.

[0207] Input / output interfaces provide interfaces between processing components and peripheral interface modules, which can be output devices, input devices, etc.

[0208] The communication components are configured to facilitate wired or wireless communication between computing devices and other devices.

[0209] The computing device can be a physical device or an elastic computing host provided by a cloud computing platform. In this case, the computing device can refer to a cloud server, and the aforementioned processing components, storage components, etc., can be basic server resources rented or purchased from the cloud computing platform.

[0210] This application also provides a computer storage medium storing a computer program, which, when executed by a computer, can perform the above-described functions. Figure 1 The illustrated embodiment presents a food packaging integrity detection method based on a convolutional neural network.

[0211] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0212] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0213] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0214] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.

Claims

1. A method for detecting the integrity of food packaging based on convolutional neural networks, characterized in that, include: High-definition cameras deployed from multiple angles on the production line capture real-time images of food packaging. The image data is then transmitted to a cloud server using a secure and stable network protocol to obtain a food packaging image dataset. Based on the aforementioned food packaging image dataset, a pre-constructed and deeply optimized convolutional neural network model combined with an attention mechanism algorithm is used to perform multi-level feature analysis on key region information in the images, and anomaly detection processing is performed on the food packaging images to generate preliminary anomaly detection results. Based on the preliminary anomaly detection results, a deep reinforcement learning algorithm is used to dynamically assess the anomaly by combining Bayesian decision theory with historical detection data of food packaging and environmental parameters, resulting in an anomaly confirmation report. Using the aforementioned anomaly confirmation report, the detection results are fed back to the production control system in real time through the cloud service platform, and adaptive adjustments are made to the production line speed, packaging material selection, or early warning information to generate an optimized production control scheme. Specifically, based on the food packaging image dataset, a pre-constructed and deeply optimized convolutional neural network model combined with an attention mechanism algorithm is used to perform multi-level feature analysis on key region information in the images, and anomaly detection processing is performed on the food packaging images to generate preliminary anomaly detection results, including: Using the aforementioned food packaging image dataset, multi-level feature extraction processing is performed on the image data. Local and global features in the images are captured through convolutional layers, pooling layers, and fully connected layers to obtain multi-level feature information. Based on this multi-level feature information, an attention mechanism algorithm is used to weight key regions in the image, highlighting potential abnormal areas and reducing background interference, resulting in an optimized feature representation. Based on the optimized feature representation, anomaly detection rules are designed to automatically identify anomalies in the food packaging images, obtaining anomaly detection candidate results. Using these candidate results, the detection model is tested multiple times using cross-validation technology to evaluate the accuracy of anomaly detection, ensuring the model's stability and consistency under different conditions, and generating optimized anomaly detection rules. Based on the optimized anomaly detection rules, preliminary anomaly detection results are finally generated. The step of weighting key region information in the image based on the multi-level feature information and combining it with an attention mechanism algorithm to highlight potential abnormal regions, reduce background interference, and obtain an optimized feature representation includes: In calculating attention weights Previously, feature information at different levels was aggregated and normalization techniques were applied; ; in, Indicates the first Attention weights for each feature map; The first is extracted from multi-level feature information. Each feature map; and These are the weight matrix and bias vector in the attention mechanism, respectively. It represents the total number of feature maps; and These are the weight matrix and bias vector used to enhance the nonlinear transformation of the feature map; It is a hyperparameter used to adjust the effect of the ReLU nonlinear transformation; and These are the weight matrix and bias vector used to introduce the softmax function; is a hyperparameter used to adjust the effect of the softmax function; ReLU is an activation function used to introduce nonlinearity; softmax is an activation function used to introduce normalization. After calculating attention weights Then, it is combined with the original feature map, and weighted and nonlinear transformations are used to reduce background noise, highlight the target region, and generate an optimized feature representation. ; in, It is the optimized version of the first Each feature is represented; and These are the weight matrix and bias vector used to generate optimized feature representations; It is a weight matrix used to reduce background interference; Based on The calculated background feature map is then obtained through a background extraction algorithm. It is an activation function used to introduce nonlinearity; and It is a weight matrix and bias vector used to handle the difference between attention weights and background feature maps; It is a hyperparameter used to adjust the impact of differences in background feature maps; and These are the weight matrix and bias vector used to introduce the sigmoid function; is a hyperparameter used to adjust the effect of the sigmoid function; tanh is an activation function used to enhance the contrast of the feature map; sigmoid is an activation function used to introduce nonlinear transformations and normalization processes. After calculating the optimized feature representation Then, through feature dimensionality reduction, selection and fusion steps, redundant information is removed, representative features are retained, and the generalization ability and feature representation efficiency of the model are improved. The process involves using Bayesian decision theory combined with historical detection data of food packaging and environmental parameters, along with a deep reinforcement learning algorithm, to dynamically assess the risk of anomalies and obtain an anomaly confirmation report. This report includes: Based on the preliminary anomaly detection results, combined with historical detection data of food packaging and current environmental parameters, a risk assessment model for the anomaly is constructed, generating an initial risk assessment framework. Using Bayesian decision theory, probabilistic analysis is performed on the anomaly location, type, and confidence level in the preliminary anomaly detection results, generating an anomaly probability assessment. Based on the anomaly probability assessment, a deep reinforcement learning algorithm is used to simulate the long-term impact under different processing strategies, dynamically adjusting the anomaly processing strategy and generating a strategy optimization scheme. Using the strategy optimization scheme, dynamic risk assessment processing is performed on the anomaly, generating an anomaly confirmation report.

2. The method according to claim 1, characterized in that, The step involves designing anomaly detection rules based on the optimized feature representation, automatically identifying anomalies in food packaging images, and obtaining anomaly detection candidate results, including: Based on the optimized feature representation, common anomaly types in food packaging images are analyzed and processed to obtain a key feature set of anomaly types. Based on the key feature set of the anomaly type, design detection rules for different anomaly types and generate an anomaly detection rule set; Using the aforementioned anomaly detection rule set, anomalies in food packaging images are automatically identified and processed. By comparing the features in the image with preset rules, suspected abnormal areas are marked and anomaly detection marks are generated. Based on the anomaly detection markers, and combined with the probability and confidence assessment of anomaly occurrence, a comprehensive evaluation is performed on each suspected anomaly region to obtain anomaly detection candidate results.

3. The method according to claim 1, characterized in that, The process involves using the anomaly detection candidate results to test the detection model multiple times using cross-validation technology, evaluating the accuracy of anomaly detection, ensuring the stability and consistency of the model under different conditions, and generating optimized anomaly detection rules, including: Using the anomaly detection candidate results, the detection results are compared with the real labels. The detection model is tested multiple times using cross-validation technology to ensure that a different subset of data is used as the validation set for each test, and a model performance evaluation report is generated. Based on the model performance evaluation report, analyze the model's performance under different conditions and evaluate the accuracy of anomaly detection; Based on the accuracy assessment of the anomaly detection, the anomaly detection rules are adjusted, the key feature indicators of the anomaly type are optimized, and optimization suggestions are generated. Using the aforementioned optimization suggestions, the anomaly detection rules are iteratively optimized to ensure the stability and consistency of the model under different conditions, and to generate optimized anomaly detection rules.

4. The method according to claim 1, characterized in that, The process of using deep reinforcement learning algorithms to simulate the long-term effects of different handling strategies based on the anomaly probability assessment, dynamically adjusting the anomaly handling strategy, and generating a strategy optimization scheme includes: Calculating future returns Previously, a comprehensive analysis was conducted on the anomaly detection results and the current status; ; in, Indicates from time The sum of future returns at the beginning; It is in time The instant reward received; It is the total length of the time series; It is a discount factor used to reduce the importance of future rewards; It is a discount factor used to make the model focus on short-term returns; It is a hyperparameter used to adjust the impact of changes in state value; It is in state The value of the state under the following conditions; In the current state The state value is determined by ReLU, which is an activation function used to introduce nonlinearity to ensure that positive changes in state value have a positive impact on the reward. It is a hyperparameter used to adjust the effect of state distance; It is a state and state The distance metric between the two values; sigmoid is an activation function used to introduce non-linear transformations and normalization processes to ensure that a positive value of the distance metric has a positive impact on the reward. After calculating future returns Then, update the state-action value function. Introducing heuristic functions and conflict measurement Generate the optimal action selection probability , ; in, Indicates the state Select action The probability is determined by the policy network parameters. Decide; It is a state-action value function, representing the state... Take action below Expected returns; It is a hyperparameter used to adjust the heuristic function. The impact; It is a heuristic function used to provide strategy guidance; It is an activation function used to introduce nonlinearity and enhance the flexibility of the policy; It is a hyperparameter used to adjust the impact of conflict metrics; It is in state Take action below The conflict metric is used to assess the feasibility and potential risks of actions; ReLU is an activation function used to introduce nonlinearity to ensure that a positive value of the conflict metric has a positive impact on the policy. Temperature is a parameter used to balance the exploration and utilization of the control strategy; softmax is an activation function used to convert the state-action value function into a probability distribution. After calculating the optimal action selection probability Then, the optimal action is selected and executed, the parameters of the policy network are updated through online or offline learning, the policy performance is evaluated periodically and dynamically adjusted, and a scheme for dynamically optimizing the anomaly handling policy is generated.

5. The method according to claim 1, characterized in that, The process utilizes Bayesian decision theory to perform probabilistic analysis on the anomaly location, type, and confidence level in the preliminary anomaly detection results, generating an anomaly probability assessment, including: Based on the preliminary anomaly detection results, key information such as anomaly location, type, and confidence level is extracted to construct a probability model of the anomaly event. Using Bayesian decision theory and historical inspection data of food packaging, a priori estimation of the probability of abnormal events is performed to form a prior probability distribution. Based on the prior probability distribution, and combined with the anomaly location, type and confidence level in the current detection results, the probability of the anomaly event actually occurring under the current detection conditions is calculated to obtain the posterior probability. The anomaly probability assessment is generated using the posterior probability.

6. The method according to claim 1, characterized in that, The process of utilizing the anomaly confirmation report to provide real-time feedback of detection results to the production control system via a cloud service platform, adaptively adjusting the production line speed, packaging material selection, or early warning information, and generating an optimized production control scheme includes: Using the aforementioned anomaly confirmation report, the detection results are organized and analyzed, and the detection results are fed back to the production control system in real time through the cloud service platform to obtain production control instructions; Based on the production control instructions, the production parameters of the production line are evaluated to determine a list of production parameters that need to be adjusted. Based on the list of production parameters that need to be adjusted, an adaptive adjustment strategy is designed and implemented, and automated control technology is used to precisely adjust the production process to generate the adjusted production state. Based on the adjusted production status, when an abnormal situation is detected, an early warning message is issued immediately to remind operators to take corresponding measures and generate an optimized production control plan.

7. A food packaging integrity detection system based on convolutional neural networks, used to execute the food packaging integrity detection method based on convolutional neural networks as described in any one of claims 1 to 6, characterized in that, include: The transmission module is used to capture food packaging images in real time from high-definition cameras deployed from multiple angles on the production line, and transmit the image data to the cloud server using a secure and stable network protocol to obtain a food packaging image dataset. The analysis module is used to perform multi-level feature analysis on key region information in the images based on the food packaging image dataset, using a pre-built and deeply optimized convolutional neural network model combined with an attention mechanism algorithm, to perform anomaly detection processing on the food packaging images and generate preliminary anomaly detection results. The evaluation module is used to perform dynamic risk assessment of the abnormal situation based on the preliminary anomaly detection results, combining Bayesian decision theory with historical detection data of food packaging and environmental parameters, and using deep reinforcement learning algorithms to obtain an anomaly confirmation report. The adjustment module is used to use the anomaly confirmation report to feed back the detection results to the production control system in real time through the cloud service platform, and to adaptively adjust the speed of the production line, the selection of packaging materials or early warning information to generate an optimized production control scheme.