Cigarette packaging abnormity monitoring method

By using the technical means of memory network, deep mutual learning and personalized federated learning in cigarette packaging detection, the existing detection methods are solved, and more efficient and accurate monitoring of cigarette packaging abnormalities is achieved.

CN119991639APending Publication Date: 2025-05-13CHINA TOBACCO HENAN IND CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510146386.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-10
Publication Date
2025-05-13

AI Technical Summary

Technical Problem

The existing cigarette packaging detection methods are inefficient, have low accuracy, and are difficult to adapt to diverse defect types in complex industrial environments.

Method used

The unilateral end cigarette anomaly detection model based on memory network and the multilateral end cigarette packaging cloud edge collaborative anomaly detection model based on deep mutual learning are adopted, and the cigarette defect category segmentation model under the personalized federated learning framework is combined with the data collection, preprocessing and multiple iterative training to improve the adaptability and generalization capabilities of the detection model.

Benefits of technology

It improves the accuracy and efficiency of cigarette packaging detection, enhances the model's adaptability and generalization ability to different edge data, and can more accurately identify and classify the defects of cigarette packaging.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119991639A_ABST
    Figure CN119991639A_ABST
Patent Text Reader

Abstract

The invention specifically discloses a cigarette package abnormity monitoring method, which comprises the following steps of: preprocessing cigarette image data, determining the position of a cigarette package by utilizing edge detection, cutting and normalizing a picture; training a single-side cigarette anomaly detection model based on a memory network, dividing a data set, constructing a model containing a convolutional auto-encoder and the memory network, and training by adopting a stochastic gradient descent algorithm; multilateral cigarette packaging cloud edge collaborative anomaly detection model training based on deep mutual learning is carried out, and collaborative training is carried out through a cloud server and an edge end; training and applying a cigarette defect category subdivision model under a personalized federated learning framework, subdividing defect categories, and fusing knowledge at a cloud server side; and evaluating and optimizing the model by adopting a classification performance evaluation index and an AUC-ROC curve. The method can improve the detection efficiency and accuracy, and is suitable for the data characteristics of different edge ends.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of cigarette packaging, and more specifically, to a cigarette packaging abnormality monitoring method. Background Art

[0002] In the cigarette production process, the monitoring of packaging quality is crucial. Traditional cigarette packaging detection methods often have some limitations. Manual detection methods are inefficient and easily affected by subjective factors, making it difficult to ensure the accuracy and consistency of detection. With the continuous expansion of cigarette production scale and the increasing requirements for product quality, an efficient and accurate cigarette packaging abnormality monitoring method is urgently needed.

[0003] At the same time, although some existing machine vision-based detection methods have improved detection efficiency to a certain extent, they still have shortcomings when facing complex industrial environments and diverse types of cigarette packaging defects. On the one hand, the data collection and preprocessing methods may not be optimized enough, making it difficult for the model to effectively learn the key features of cigarette packaging; on the other hand, a single model structure and training method may not be able to fully adapt to the data characteristics of different edges and various complex abnormal situations, thus affecting the accuracy and reliability of detection. Summary of the invention

[0004] The present invention provides a cigarette packaging anomaly monitoring method, which solves the above-mentioned problems existing in the existing cigarette packaging detection, can improve the accuracy and efficiency of detection, enhance the adaptability and generalization ability of the detection model, and improve the performance of the detection model.

[0005] To achieve the above objectives, the present invention provides the following technical solutions:

[0006] A method for monitoring cigarette packaging abnormalities, comprising:

[0007] S100, cigarette image data acquisition and preprocessing;

[0008] S200, training a single-side cigarette anomaly detection model based on a memory network;

[0009] S300, Multi-end Cigarette Packaging Cloud-Edge Collaborative Anomaly Detection Model Training Based on Deep Mutual Learning;

[0010] S400, training and application of cigarette defect category segmentation model under personalized federated learning framework;

[0011] S500, model evaluation and optimization.

[0012] Preferably, the cigarette image data collection and preprocessing includes:

[0013] The edge detection method is used to determine the exact position of the cigarette pack, and the image is cropped based on the center position of the cigarette pack to remove irrelevant background information and make the cigarette outside;

[0014] The package is located in the center of the image, which enhances the model's learning of cigarette package features;

[0015] Normalize the cropped images and map the image pixel values ​​to a specific interval to enhance the stability of the image data and speed up the convergence of model training.

[0016] Preferably, the training of the single-side cigarette anomaly detection model based on the memory network includes:

[0017] S210, dividing the cigarette data set, dividing the obtained preprocessed cigarette data set in detail according to the edge, for each edge, dividing the normal samples into a training set and a validation set according to a specific ratio, and at the same time including all abnormal samples of the edge into the test set;

[0018] S220, constructing a cigarette anomaly detection model based on memory network;

[0019] S230: Perform model training.

[0020] Preferably, the construction of a cigarette anomaly detection model based on a memory network includes:

[0021] The structure of the cigarette anomaly detection model mainly consists of two parts: convolutional autoencoder and memory network;

[0022] The convolutional autoencoder function is to input the image Downsampling is performed, and then pooling is performed to obtain the latent vector , the calculation formula is ,in, is the mapping function, Represents the parameters of the encoder. The parameters of the encoder are continuously updated and optimized during the model training process so that the encoder can better extract image features and map them to the appropriate feature space;

[0023] The memory network pre-stores multiple prototype vectors , The artificially set hyperparameter represents the number of prototypes contained in the memory network;

[0024] By calculation formula: , which measures the latent vector With each prototype vector The degree of similarity between

[0025] According to the calculation formula , perform softmax operation on the obtained similarity to obtain the weight vector ;

[0026] For the weight vector Perform sparse processing to obtain the processed weight vector ;

[0027] Then, using the processed weight vector Prototype matrices in memory networks Calculate and get the new eigenvector ;

[0028] Finally, the decoder receives the feature vector And reconstruct it into an image with the same height and width as the input image ,in, is the mapping function of the decoder, is the decoder parameter. The task of the decoder is to accurately restore the original image based on the fused feature vector.

[0029] Preferably, during the model training process, the training objective function used includes:

[0030] Reconstruction loss function , used to evaluate the input image The reconstructed image obtained after model processing With the original picture the degree of difference between;

[0031] Sparse loss function , used to constrain the weight vector to prevent the model from overfitting;

[0032] Overall loss function ,in To control the parameters of the weight ratio of the two losses, by adjusting The value of is used to balance the impact of reconstruction loss and sparse loss on model training, so that the model can avoid overfitting while ensuring reconstruction accuracy.

[0033] Preferably, the model training comprises:

[0034] The stochastic gradient descent algorithm is used to optimize the model parameters. The stochastic gradient descent algorithm calculates the gradient of the loss function for each parameter and updates the parameters in the opposite direction of the gradient, so that the model parameters are gradually adjusted in the direction that minimizes the loss function.

[0035] During the training process, the performance of the model is monitored through the validation set, and the loss function value and related evaluation indicators on the validation set are calculated;

[0036] When it is found that the loss function value on the validation set no longer decreases or reaches the preset training round, the training process is stopped and the trained model is saved for subsequent common detection tasks.

[0037] Preferably, the multi-edge cigarette packaging cloud-edge collaborative anomaly detection model training based on deep mutual learning includes:

[0038] S310, entering the multi-edge cigarette packaging cloud edge collaborative anomaly detection model training stage;

[0039] S320, entering the federated model optimization phase, each edge uses its own private data to train the GSM received from the cloud. In this process, each edge performs multiple rounds of training operations. In each round of training, the edge calculates the gradient of the model parameters based on the local data and uses the optimization algorithm to update the model parameters.

[0040] S330, in the local parameter update stage, for each input cigarette packaging image I, GSM and LPM respectively perform encoding and decoding operations on it to obtain the latent space feature and reconstructed image , and calculate the reconstruction loss and feature loss to optimize the corresponding objective function;

[0041] S340, repeat the above steps of optimizing the federated model and updating the local parameters, iteratively advance, and gradually converge the model.

[0042] Preferably, the step of entering the multi-edge cigarette packaging cloud edge collaborative anomaly detection model training phase includes:

[0043] S311, model initialization, to initialize the global shared model GSM and the lightweight private model LPM;

[0044] S312. Construct an objective function to guide the training of the model.

[0045] Preferably, the training and application of the cigarette defect category segmentation model under the personalized federated learning framework includes:

[0046] S410, segment the defect categories, customize multiple local prototypes for each category at each edge, and build a local memory network to serve as the representative vector of each category in the feature space to accurately identify defects of different categories;

[0047] S420, the knowledge fusion is carried out on the cloud server side, and the Hungarian algorithm is used to make a one-to-one correspondence between prototypes according to feature similarity;

[0048] S430, after multiple rounds of iterative training, the model can more accurately classify different types of defects.

[0049] Preferably, the model evaluation and optimization includes:

[0050] The classification performance evaluation indicators and AUC-ROC curve are used to comprehensively evaluate the performance of the model. The classification performance evaluation indicators include true positive TP, true negative TN, false positive FP, and false negative FN.

[0051] Based on the classification performance evaluation index, the true positive rate is calculated , and the false positive rate ;

[0052] The AUC-ROC curve is drawn with the false positive rate FPR as the horizontal axis and the true positive rate TPR as the vertical axis. For the prediction results of the model at different thresholds, the corresponding FPR and TPR values ​​are calculated, and the corresponding points are connected to form the ROC curve. The AUC value is the area under the ROC curve, and the calculation formula is: ,in is the coordinate point on the ROC curve.

[0053] The present invention provides a method for monitoring cigarette packaging abnormalities, which has the following beneficial effects:

[0054] 1. The present invention adopts a variety of advanced model structures and training methods. The single-edge cigarette anomaly detection model based on memory network has a unique structural design that enables the model to better extract and fuse image features; the multi-edge cigarette packaging cloud-edge collaborative anomaly detection model based on deep mutual learning enhances the model's adaptability and generalization capabilities to different edge data through collaborative training of cloud servers and edge terminals; the cigarette defect category segmentation model under the personalized federated learning framework improves the model's ability to accurately identify different types of defects by constructing local memory networks and knowledge fusion operations to address the problem of multiple cigarette defect categories and uneven sample distribution in industrial scenarios.

[0055] 2. Effective optimization algorithms and strategies were used in the model training process. For example, the single-side cigarette anomaly detection model based on memory network uses the stochastic gradient descent algorithm to optimize the model parameters, which can converge quickly and reduce training time. The multi-side cigarette packaging cloud edge collaborative anomaly detection model based on deep mutual learning gradually converges through iterative training, improving the training efficiency of the model. The cigarette defect category segmentation model under the personalized federated learning framework has undergone multiple rounds of iterative training. The prototypes under each category will adaptively change their positions in the feature space according to the training data. As the training progresses, the prototypes cover more category feature information, enabling the model to classify cigarette defects more quickly and accurately, thereby improving the overall detection efficiency.

[0056] 3. The multi-edge cigarette packaging cloud-edge collaborative anomaly detection model based on deep mutual learning can adapt to the data characteristics of different edge ends through collaborative training of cloud servers and edge ends, as well as comprehensive consideration of reconstruction loss and feature loss, and enhance the generalization ability of the model. The cigarette defect category segmentation model under the personalized federated learning framework can better cope with the problem of multiple cigarette defect categories and uneven sample distribution in industrial scenarios by constructing local memory networks and knowledge fusion operations, further enhancing the adaptability and generalization ability of the model.

[0057] 4. In the model evaluation and optimization stage, classification performance evaluation indicators (such as true positive, true negative, false positive, false negative) and AUC-ROC curve are used to comprehensively evaluate the performance of the model. By analyzing these indicators, we can accurately understand the advantages and disadvantages of the model, so as to optimize the model in a targeted manner and further improve the performance of the model. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] In order to more clearly illustrate the specific embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below.

[0059] Figure 1 It is a schematic diagram of the process framework of a cigarette packaging abnormality monitoring method provided by the present invention. DETAILED DESCRIPTION

[0060] In order to enable persons skilled in the art to better understand the solutions of the embodiments of the present invention, the embodiments of the present invention are further described in detail below in conjunction with the accompanying drawings and implementation modes.

[0061] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.

[0062] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The term "in one embodiment" that appears in different places in this specification does not necessarily refer to the same embodiment, nor does it refer to a separate or selective embodiment that is mutually exclusive with other embodiments.

[0063] As a preferred embodiment of the present invention, the present invention provides a method for monitoring cigarette packaging abnormalities, which comprises the following steps:

[0064] S100, cigarette image data acquisition and preprocessing;

[0065] S200, single-side cigarette anomaly detection model training based on memory network;

[0066] S300, Multi-end Cigarette Packaging Cloud-Edge Collaborative Anomaly Detection Model Training Based on Deep Mutual Learning;

[0067] S400, training and application of cigarette defect category segmentation model under personalized federated learning framework;

[0068] S500, model evaluation and optimization.

[0069] As a preferred solution described in the present invention, in the cigarette image data collection and preprocessing, the collected cigarette image is first preprocessed, and the specific operation is as follows: the edge detection method is used to determine the precise position of the cigarette package, and the image is cropped based on the center position of the cigarette package, and irrelevant background information is removed, so that the cigarette outer package is located in the center of the picture, and the model's learning of cigarette package features is enhanced. A certain margin is left during cropping to ensure that the cigarette outer package can be completely cropped and the model input size of each edge is consistent, and the cropped image size is adjusted to 3256418.

[0070] Normalize the cropped image and map the image pixel values ​​to a specific interval, such as [0,1] or [-1,1], to enhance the stability of the image data and speed up the convergence of the model training. , the normalized pixel value is , using the formula Normalize, where and are the minimum and maximum values ​​of the image pixels, respectively.

[0071] As a preferred solution of the present invention, the S200, the training of the single-side cigarette anomaly detection model based on the memory network, comprises the following steps:

[0072] S210, dividing the cigarette data set;

[0073] S220, constructing a cigarette anomaly detection model based on memory network;

[0074] S230: Perform model training.

[0075] In S210, dividing the cigarette data set, the obtained pre-processed cigarette data set is divided into fine divisions according to the edges. For each edge, its normal samples are divided into a training set and a validation set according to a specific ratio, and all abnormal samples of the edge are included in the test set.

[0076] In S220, in building a cigarette anomaly detection model based on a memory network, the model structure mainly consists of two parts: a convolutional autoencoder and a memory network.

[0077] First, in the encoder part, its function is to convert the input image Downsampling is performed, and then pooling is performed to obtain the latent vector This process is done through a specific mapping function To achieve this, the specific calculation formula is: ,in Represents the parameters of the encoder, which are continuously updated and optimized during the model training process so that the encoder can better extract image features and map them to the appropriate feature space.

[0078] Next, the memory network comes into play, which pre-stores multiple prototype vectors ,here is a manually set hyperparameter representing the number of prototypes contained in the memory network. The cosine similarity will be calculated with these prototype vectors respectively, and the calculation formula is , this formula can measure With each prototype vector The similarity between them. Then, the obtained similarity is subjected to softmax operation to obtain the weight vector , and its calculation formula is Through the softmax operation, the similarity is converted into weights, so that the model can perform reasonable weighted fusion of prototype vectors according to these weights.

[0079] Then, in order to avoid the problem of overfitting the model due to too many prototype vector fusion, the weight vector Here, the ReLU activation function is used to replace the traditional hard threshold shrinkage operation. The specific formula is: ,in Represents the hard threshold, which is an artificially set parameter used to determine which weights need to be sparsely processed; is a very small value, and its main function is to prevent the denominator from being zero. After such sparse processing, the processed weight vector is obtained .

[0080] Then, using the processed weight vector Prototype matrices in memory networks Calculate and get the new eigenvector , this new feature vector combines the feature information of multiple prototype vectors. Finally, the decoder receives And reconstruct it into an image with the same height and width as the input image ,in is the mapping function of the decoder, is the decoder parameter. The task of the decoder is to restore the original image as accurately as possible based on the fused feature vector.

[0081] During the model training process, it is necessary to define a suitable loss function to measure the difference between the model's predicted results and the actual results, thereby guiding the optimization of model parameters. The training objective function of this model consists of two parts, namely the reconstruction loss function , which is used to evaluate the input image The reconstructed image obtained after model processing With the original picture The smaller the difference, the stronger the model's ability to reconstruct the image; the other part is the sparse loss function , which is mainly used to constrain the weight vector to prevent the model from overfitting. Overall loss function ,in To control the parameters of the weight ratio of the two losses, by adjusting The value of can balance the impact of reconstruction loss and sparse loss on model training, so that the model can avoid overfitting problems while ensuring reconstruction accuracy.

[0082] In the S200 and S230 of the single-side cigarette anomaly detection model training based on the memory network, the model parameters are optimized by the stochastic gradient descent algorithm. The stochastic gradient descent algorithm calculates the gradient of the loss function for each parameter and updates the parameters in the opposite direction of the gradient, so that the model parameters are gradually adjusted in the direction of minimizing the loss function. During the training process, the performance of the model is monitored by the validation set, and the loss function value on the validation set and other related evaluation indicators (such as accuracy, recall rate, etc.) are calculated. When it is found that the loss function value on the validation set no longer decreases or reaches the preset training rounds, the training process is stopped, and the trained model is saved at this time for subsequent regular detection tasks. The model trained in this way can effectively detect cigarette packaging anomalies in a single-side scenario, laying the foundation for subsequent multilateral collaborative detection and defect category segmentation.

[0083] As a preferred solution of the present invention, the multi-edge cigarette packaging cloud-edge collaborative anomaly detection model training based on deep mutual learning includes:

[0084] S310, entering the multi-edge cigarette packaging cloud edge collaborative anomaly detection model training stage;

[0085] S320, entering the federated model optimization phase;

[0086] S330, in the local parameter update phase;

[0087] S340: Repeat the above steps of optimizing the federated model and updating the local parameters.

[0088] In S310, entering the multi-edge cigarette packaging cloud edge collaborative anomaly detection model training phase includes the following steps:

[0089] S311, model initialization, the cloud server first initializes the global shared model (GSM). Let the model parameters of GSM be , then GSM can be expressed as a function ,in is the input cigarette packaging image. This GSM is a basic model framework, which contains the initial model parameters After initialization is completed, the cloud server will distribute GSM to each edge terminal.

[0090] At the same time, each edge terminal will also initialize a lightweight private model (LPM). Let the model parameters of LPM be , then LPM can be expressed as LPM has a convolutional autoencoder structure similar to GSM, and its hidden space feature dimension is consistent with GSM. Assume that the hidden space feature dimensions of GSM and LPM are , that is, for the input image , the latent space feature vectors obtained after passing through the GSM and LPM encoders are and ,in and Represent the encoder parts of GSM and LPM respectively. The purpose of this design is to enable LPM to learn edge-specific features to better cope with data heterogeneity problems.

[0091] S312, construct the objective function. During the training process, it is necessary to define a suitable objective function to guide the training of the model. For GSM and LPM, consider the reconstruction loss and feature loss.

[0092] (1) Reconstruction loss:

[0093] For the input image, the image reconstructed by GSM is , the image reconstructed by LPM is The reconstruction loss function can be measured using the mean square error (MSE), namely:

[0094] ;

[0095] ;

[0096] in is the number of training samples, and , Respectively The original image of the sample and the image reconstructed by GSM and LPM.

[0097] (2) Feature loss:

[0098] In order to make the latent space features of GSM and LPM as similar as possible, we introduce feature loss. Feature loss can be measured by calculating the difference between the latent space feature vectors of GSM and LPM, where smoothing is used. The loss is:

[0099] ;

[0100] Combining the reconstruction loss and feature loss, we get the overall objective function as: in It is an adjustable hyperparameter used to balance the weight of reconstruction loss and feature loss. By optimizing this objective function, the collaborative training of GSM and LPM can be achieved, and the model's adaptability and generalization ability to different edge data can be enhanced.

[0101] In S320, when entering the federated model optimization phase, each edge uses its own private data to train the GSM received from the cloud. In this process, each edge performs multiple rounds (assuming Wheel, such as In each round of training, the edge calculates the gradient of the model parameters based on the local data and uses an optimization algorithm (such as the stochastic gradient descent algorithm) to update the model parameters. Training is completed After the round, each edge end uploads the updated model parameters to the cloud server. After receiving the model parameters uploaded by each edge end, the cloud server calculates the weighted average weight according to the pre-set weight aggregation rule (here, it is assumed to be the average weight, that is, the formula middle , Indicates the edge number, Represents the training round), aggregates these parameters, and updates the global shared model GSM. This process enables GSM to integrate the learning results of each edge end, gradually learn the common features and patterns of each edge end, and improve the generalization ability of the model.

[0102] At S330, in the local parameter update stage, for each input cigarette packaging image , GSM and LPM respectively encode and decode it. GSM uses its encoder to convert the image Map to the latent space and get the latent space features , while the decoder Decode and get the reconstructed image ; LPM also applies to images Encode and decode to obtain latent space features and reconstructed image Based on these results, the reconstruction loss is calculated, and the reconstruction loss of GSM is , the reconstruction loss of LPM , the overall reconstruction loss , the reconstruction loss reflects the model's ability to reconstruct the image. The smaller its value, the better the model reconstruction effect. At the same time, in order to make the latent space features of GSM and LPM as similar as possible, the feature loss is calculated. , through feature loss to constrain the feature representation of the two models, so that they can influence and learn from each other during the learning process. Ultimately, the training goal ( is an adjustable hyperparameter). By optimizing this objective function, the collaborative training of GSM and LPM is achieved, and the adaptability and generalization ability of the model to different edge data are enhanced.

[0103] In S340, the steps of repeatedly performing the above-mentioned federated model optimization and local parameter update are repeated. In each round of iteration, GSM continuously absorbs information from each edge end for optimization, and LPM continuously adjusts its own parameters in the process of mutual learning with GSM. As the iteration proceeds, the model gradually converges, that is, the model parameters no longer change significantly or the loss function value no longer decreases significantly. After the training is completed, the LPM at the edge will be used for real-time anomaly detection. In the inference stage, it is first necessary to determine a suitable reconstruction error threshold based on the distribution of reconstruction errors on the training data set. After the input image is processed by LPM, its reconstruction error is calculated. If the reconstruction error is less than or equal to , then the cigarette packaging corresponding to the image is judged to be normal; otherwise, if the reconstruction error exceeds , it is judged as abnormal. This design enables the model to accurately and efficiently detect cigarette packaging anomalies based on multi-edge collaboration, and can adapt to the data characteristics of different edge ends, improving the accuracy and robustness of the entire system for cigarette packaging anomaly detection. At the same time, compared with single-edge model training, multi-edge collaborative training can make full use of data information from multiple edge ends, further improve the performance of the model, and better meet the needs of cigarette packaging anomaly detection in complex production environments.

[0104] As a preferred solution of the present invention, the training and application of the cigarette defect category segmentation model under the personalized federated learning framework includes the following steps:

[0105] S410, defect category breakdown;

[0106] S420, knowledge fusion is performed on the cloud server side;

[0107] S430, after multiple rounds of iterative training.

[0108] In S410, defect category segmentation, in response to the problem that there are many categories of cigarette defects and uneven sample distribution in industrial scenarios, this step customizes multiple local prototypes for each category on each edge and builds a local memory network. These local prototypes will serve as representative vectors of each category in the feature space, which will help the model to more accurately identify defects of different categories. During the training phase, the memory network and other layers of the model jointly participate in the gradient backpropagation algorithm. The core idea of ​​introducing InfoNCELoss in contrastive learning is to learn effective feature representations by comparing the similarities between samples and positive and negative samples. Specifically, prototypes belonging to the same category as the training samples are regarded as positive samples, and prototypes of different categories are regarded as negative samples. The model parameters are adjusted by calculating InfoNCELoss so that the feature vector (query) is closer to the positive sample and away from the negative sample in the embedded space. The calculation formula is: ,in is the total number of prototypes. In each training iteration, the model calculates the gradient according to this loss function and updates the parameters of the memory network and other related layers, so that the model gradually learns the characteristic differences between different types of defects and improves the ability to distinguish defect categories.

[0109] In S420, knowledge fusion is being performed on the cloud server. The Hungarian algorithm is used to perform one-to-one correspondence between prototypes based on feature similarity. The specific operations are as follows:

[0110] First, calculate the feature similarity matrix between prototypes , where the elements , is a similarity calculation function. This function can select a suitable calculation method according to actual needs, such as cosine similarity, Euclidean distance, etc. Here, cosine similarity is taken as an example. Then, the Hungarian algorithm is used to calculate the similarity matrix The Hungarian algorithm can maximize the total similarity while ensuring a one-to-one match, thereby finding the best matching prototype pair. Finally, the matched prototypes are feature fused to obtain a new fused prototype .

[0111] In this way, the prototype features of the same category learned by different edge terminals are fused, so that the fused prototype can more comprehensively represent the characteristics of defects in this category and enhance the model's ability to recognize various types of defects.

[0112] In S430, after multiple rounds of iterative training, the prototype under each category will adaptively change its position in the feature space according to the training data. As the training progresses, the prototype gradually covers more categories of feature information, so that the prototype can be more accurately classified when facing different types of defects. The algorithm model was verified on the cigarette dataset and the public dataset commonly used for personalized federated learning. The results show that it can effectively improve the accuracy of cigarette package defect classification. At the same time, due to the use of the federated learning framework, the model only transmits model parameters during the training process without involving the original data, which ensures the security of the data, and reduces the amount of data transmission to a certain extent, improving communication efficiency. In practical applications, the cigarette image to be tested is input into the trained model. The model will output the defect category segmentation results based on the previously learned feature representation and classification rules, thereby realizing the accurate classification and identification of cigarette packaging defects, providing strong support for quality control in the cigarette production process, further improving the quality of cigarette packaging, reducing the defective rate, and improving production efficiency and economic benefits.

[0113] As a preferred solution of the present invention, in the model evaluation and optimization, after completing the training and application of the cigarette defect category segmentation model under the personalized federated learning framework, the model evaluation and optimization stage is entered. This stage mainly uses classification performance evaluation indicators and AUC-ROC curves to comprehensively evaluate the performance of the model.

[0114] For the classification performance evaluation indicators, the four key indicators are true positive TP, true negative TN, false positive FP and false negative FN. True positive TP means the number of samples predicted by the model as defective samples and whose actual labels are also defective; true negative TN means the number of samples predicted as normal samples and whose actual labels are also normal; false positive FP means the number of samples predicted as defective samples but whose actual labels are normal; false negative FN means the number of samples predicted as normal samples but whose actual labels are defective. Based on these indicators, the true positive rate is calculated. , which reflects the model's ability to correctly predict defect samples, that is, the defect detection rate; calculate the false positive rate , which indicates the probability that the model mistakenly predicts a normal sample as a defective sample, that is, the false positive rate. By analyzing TPR and FPR, we can intuitively understand the accuracy of the model in distinguishing defects from normal samples.

[0115] The process of drawing the AUC-ROC curve is as follows: the false positive rate FPR is the horizontal axis and the true positive rate TPR is the vertical axis. For the prediction results of the model at different thresholds, the corresponding FPR and TPR values ​​are calculated, and the points corresponding to these values ​​are connected to form the ROC curve. The AUC value is the area under the ROC curve, and its calculation formula is ,in is the coordinate point on the ROC curve. The AUC value is independent of the classifier threshold and can effectively reflect the sensitivity and stability of the classification type in distinguishing defective and normal samples. The larger the AUC value, the better the model performance and the more accurately it can distinguish defective and normal samples. According to the evaluation results, the model is optimized and adjusted. If it is found that the model performs poorly in some aspects, such as low TPR, it may mean that the model is insufficient in detecting defective samples. At this time, you can consider adjusting the model structure, such as increasing the number of network layers, adjusting the convolution kernel size, etc., to enhance the model's ability to extract features; you can also increase the amount of training data so that the model can learn more sample features; you can also adjust the model's hyperparameters, such as learning rate, regularization parameters, etc., to optimize the model's training process. If the FPR is high, it may mean that the model is prone to misjudge normal samples as missing samples. At this time, you can adjust the decision threshold or regularize the model to prevent overfitting and improve the generalization ability of the model. Through continuous evaluation and optimization, the model performance is gradually improved, and the task of abnormal cigarette packaging monitoring is completed more accurately to meet the quality control needs in actual production.

[0116] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.

Claims

1. A method for monitoring abnormality of cigarette packaging, characterized in that: include: S100, cigarette image data acquisition and preprocessing; S200, training a single-side cigarette anomaly detection model based on a memory network; S300, multi-edge cigarette packaging cloud-edge collaborative anomaly detection model training based on deep mutual learning, through collaborative training between cloud servers and edge terminals; S400, training and application of cigarette defect category segmentation model under personalized federated learning framework; S500, model evaluation and optimization.

2. The cigarette packaging abnormality monitoring method according to claim 1, characterized in that: The cigarette image data collection and preprocessing includes: The edge detection method is used to determine the exact position of the cigarette pack, and the image is cropped based on the center position of the cigarette pack to remove irrelevant background information and make the cigarette outside; The package is located in the center of the image, which enhances the model's learning of cigarette package features; Normalize the cropped images and map the image pixel values ​​to a specific interval to enhance the stability of the image data and speed up the convergence of model training.

3. The cigarette packaging abnormality monitoring method according to claim 1, characterized in that: The training of the single-side cigarette anomaly detection model based on the memory network includes: S210, dividing the cigarette data set, dividing the obtained preprocessed cigarette data set in detail according to the edge, for each edge, dividing the normal samples into a training set and a validation set according to a specific ratio, and at the same time including all abnormal samples of the edge into the test set; S220, constructing a cigarette anomaly detection model based on memory network; S230: Perform model training.

4. The cigarette packaging abnormality monitoring method according to claim 3, characterized in that: The construction of a cigarette anomaly detection model based on a memory network includes: The structure of the cigarette anomaly detection model mainly consists of two parts: convolutional autoencoder and memory network; The convolutional autoencoder function is to input the image Downsampling is performed, and then pooling is performed to obtain the latent vector , the calculation formula is ,in, is the mapping function, Represents the parameters of the encoder. The parameters of the encoder are continuously updated and optimized during the model training process so that the encoder can better extract image features and map them to the appropriate feature space; The memory network pre-stores multiple prototype vectors , The artificially set hyperparameter represents the number of prototypes contained in the memory network; By calculation formula: , which measures the latent vector With each prototype vector The degree of similarity between According to the calculation formula , perform softmax operation on the obtained similarity to obtain the weight vector ; For the weight vector Perform sparse processing to obtain the processed weight vector ; Then, using the processed weight vector Prototype matrices in memory networks Calculate and get the new eigenvector ; Finally, the decoder receives the feature vector And reconstruct it into an image with the same height and width as the input image ,in, is the mapping function of the decoder, is the decoder parameter. The task of the decoder is to accurately restore the original image based on the fused feature vector.

5. The cigarette packaging abnormality monitoring method according to claim 4, characterized in that: During the model training process, the training objective functions used include: Reconstruction loss function , used to evaluate the input image The reconstructed image obtained after model processing With the original picture the degree of difference between; Sparse loss function , used to constrain the weight vector to prevent the model from overfitting; Overall loss function ,in To control the parameters of the weight ratio of the two losses, by adjusting The value of is used to balance the impact of reconstruction loss and sparse loss on model training, so that the model can avoid overfitting while ensuring reconstruction accuracy.

6. The cigarette packaging abnormality monitoring method according to claim 5, characterized in that: The model training comprises: The stochastic gradient descent algorithm is used to optimize the model parameters. The stochastic gradient descent algorithm calculates the gradient of the loss function for each parameter and updates the parameters in the opposite direction of the gradient, so that the model parameters are gradually adjusted in the direction that minimizes the loss function. During the training process, the performance of the model is monitored through the validation set, and the loss function value and related evaluation indicators on the validation set are calculated; When it is found that the loss function value on the validation set no longer decreases or reaches the preset training round, the training process is stopped and the trained model is saved for subsequent common detection tasks.

7. The method for monitoring cigarette packaging abnormality according to claim 1, characterized in that: The multi-edge cigarette packaging cloud-edge collaborative anomaly detection model training based on deep mutual learning includes: S310, entering the multi-edge cigarette packaging cloud edge collaborative anomaly detection model training stage; S320, entering the federated model optimization phase, each edge uses its own private data to train the GSM received from the cloud. In this process, each edge performs multiple rounds of training operations. In each round of training, the edge calculates the gradient of the model parameters based on the local data and uses the optimization algorithm to update the model parameters. S330, in the local parameter update stage, for each input cigarette packaging image I, GSM and LPM respectively perform encoding and decoding operations on it to obtain the latent space feature and reconstructed image , and calculate the reconstruction loss and feature loss to optimize the corresponding objective function; S340, repeat the above steps of optimizing the federated model and updating the local parameters, iteratively advance, and gradually converge the model.

8. The method for monitoring cigarette packaging abnormality according to claim 7, characterized in that: The multi-edge cigarette packaging cloud edge collaborative anomaly detection model training phase includes: S311, model initialization, to initialize the global shared model GSM and the lightweight private model LPM; S312. Construct an objective function to guide the training of the model.

9. The cigarette packaging abnormality monitoring method according to claim 1, characterized in that: The training and application of the cigarette defect category segmentation model under the personalized federated learning framework includes: S410, segment the defect categories, customize multiple local prototypes for each category at each edge, and build a local memory network to serve as the representative vector of each category in the feature space to accurately identify defects of different categories; S420, the knowledge fusion is carried out on the cloud server side, and the Hungarian algorithm is used to make a one-to-one correspondence between prototypes according to feature similarity; S430, after multiple rounds of iterative training, the model can more accurately classify different types of defects.

10. The cigarette packaging abnormality monitoring method according to claim 1, characterized in that: The model evaluation and optimization includes: The classification performance evaluation indicators and AUC-ROC curve are used to comprehensively evaluate the performance of the model. The classification performance evaluation indicators include true positive TP, true negative TN, false positive FP, and false negative FN. Based on the classification performance evaluation index, the true positive rate is calculated , and the false positive rate ; The AUC-ROC curve is drawn with the false positive rate FPR as the horizontal axis and the true positive rate TPR as the vertical axis. For the prediction results of the model at different thresholds, the corresponding FPR and TPR values ​​are calculated, and the corresponding points are connected to form the ROC curve. The AUC value is the area under the ROC curve, and the calculation formula is: ,in is the coordinate point on the ROC curve.

Citation Information

Cited By

  • Industrial anomaly detection method and device based on cloud edge collaboration

    CN120388379A

  • Substation equipment anomaly detection method based on confidence element learning framework

    CN121121320A