Cigarette packet appearance defect detection method and system based on deep learning

Through deep learning technology and multi-angle and multi-light source image acquisition, combined with data preprocessing and self-supervised learning, the problems of image information distortion and low detection accuracy in traditional detection methods are solved, and the efficiency, accuracy and detection of cigarette pack appearance defects is achieved. Intelligent quality control.

CN119228779APending Publication Date: 2024-12-31CHINA TOBACCO ANHUI IND CO LTD
View PDF 0 Cites 9 Cited by

Patent Information

Application Number
CN202411435463.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-15
Publication Date
2024-12-31

AI Technical Summary

Technical Problem

Traditional template comparison and machine vision technology have image information distortion, limited detection accuracy, unrecognized defect categories, affected by lighting conditions and environmental changes, and the feature extraction design is complex and time-consuming, which cannot meet the production. Line detection requirements.

Method used

Using a deep learning-based cigarette pack appearance defect detection system, multi-angle and multi-light image acquisition is carried out through high-definition cameras and scanning devices, combined with data preprocessing and strength data enhancement technology, feature extractors and self-supervised learning are used for feature extraction and Defect identification, calculate the total loss function to optimize defect detection, and form a closed loop of real-time monitoring and feedback.

Benefits of technology

It improves the accuracy and efficiency of the appearance defect detection of cigarette bags, enhances the robustness and detection accuracy of the model, realizes intelligent and efficient quality control, and ensures the stability and reliability of appearance quality during the production process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119228779A_ABST
    Figure CN119228779A_ABST
Patent Text Reader

Abstract

The invention discloses a cigarette packet appearance defect detection method and system based on deep learning, and relates to the technical field of appearance detection.When the system runs, multi-angle and multi-light-source image acquisition is carried out through a high-definition camera and scanning equipment, it is ensured that appearance details of cigarette packets are comprehensively and accurately captured, and the detection accuracy of the appearance defects of the cigarette packets is improved. According to the method, firstly, the image quality and consistency are further improved through image cutting, graying processing, denoising processing, image enhancement and data standardization of the data preprocessing module, a solid foundation is laid for subsequent defect detection, secondly, the defect detection module carries out feature extraction through strong and weak data enhancement and a feature extractor, and the defect detection accuracy is improved. By calculating the similarity of positive and negative samples in a feature space and a total loss function # imgabs0 #, defect identification and optimization are performed in combination with MSE loss, the defect detection precision and robustness of the model are improved, the evaluation module evaluates appearance defects in real time by matching with a preset threshold, and a continuously optimized detection closed loop is formed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of appearance inspection, and specifically to a method and system for detecting appearance defects of cigarette packages based on deep learning. Background Art

[0002] With the continuous development of industrial automation and intelligent manufacturing technology, the digitalization and intelligence level of cigarette packaging equipment is also steadily improving. The online detection and rejection device for cigarette packaging defects is a quality inspection equipment that is widely used in the industry. It effectively solves the pain points of low coverage and low defect detection rate of traditional manual sampling in the era of high-speed packaging machines.

[0003] Traditional template-based matching technology performs grayscale processing on the appearance image of the small box to be inspected, compares it with the standard template, and determines whether the small box has defects by comparing the difference between the template and the image of the small box to be inspected. This method requires grayscale processing of the product appearance image, which will cause distortion of image information. Its technical principle leads to poor detection of materials such as laser packaging, and it is also impossible to identify the defect category during the detection process. At the same time, it is affected by factors such as lighting conditions and environmental changes, and the detection accuracy has certain limitations.

[0004] Traditional machine vision inspection mainly consists of two processes: image acquisition and defect detection. The feature extraction capabilities and image preprocessing methods of different image processing algorithms will directly affect the accuracy and false detection rate of defect detection. At present, most of the most advanced machine vision-based defect detection algorithms are pattern-based methods, involving feature extraction or modeling and classifiers (support vector machines, nearest neighbor classifiers, etc.). Feature extraction is a key step, which describes the correlation between an input image and a feature vector used for classification. Feature extractors are usually manually designed by experienced algorithm engineers on a case-by-case basis.

[0005] However, the wide variety of cigarette packages and short product upgrade and iteration cycles require the representative features to be redesigned from scratch. Traditional machine vision methods require special pre- and post-processing and feature extraction design for different examples in this process, making the development cycle relatively complex and time-consuming. In addition, due to the different imaging environments of each production line (lighting, color changes) and the large span of appearance defect feature changes, traditional template comparison and machine vision technology can no longer fully meet the defect detection rate and false rejection rate of production lines.

[0006] Therefore, a cigarette package appearance defect detection method based on convolutional neural network is proposed, aiming to improve the defects and problems existing in the application of traditional machine vision solutions. Summary of the invention

[0007] In view of the shortcomings of the prior art, the present invention provides a cigarette package appearance defect detection method and system based on deep learning, which solves the problems mentioned in the background technology.

[0008] To achieve the above objectives, the present invention is implemented through the following technical solutions: a cigarette package appearance defect detection system based on deep learning, including a data acquisition module, a data preprocessing module, a defect detection module and an evaluation module;

[0009] The data acquisition module uses a high-definition camera and a scanning device to collect images of cigarette packages to generate image data, and simultaneously uses a multi-angle and multi-light source method to obtain a three-dimensional image of the cigarette package to form an appearance image data group;

[0010] The data preprocessing module preprocesses the appearance image data set, including image cutting, grayscale processing, denoising, image enhancement and data standardization, to form a processed appearance image data set;

[0011] The defect detection module uses strong and weak data enhancement and feature extractors to extract features from the processed appearance image data set, obtains the model input sample training set D, and then uses the loss function formula to train the similarity of positive and negative samples in the feature space to obtain the total loss function , synchronously calculate the MSE loss to optimize defect identification;

[0012] The evaluation module obtains the total loss function It is matched with the preset appearance defect assessment threshold Q to obtain the appearance defect assessment result. At the same time, the model is adaptively adjusted according to the appearance defect assessment result, and then real-time monitoring and feedback of the detection results are carried out.

[0013] Preferably, the data acquisition module includes an acquisition unit;

[0014] The acquisition unit acquires images of cigarette packages by using a high-definition camera and a scanning device to generate image data, and simultaneously acquires a stereoscopic image of the cigarette package by using a multi-angle and multi-light source method, and marks the angle and light source in the stereoscopic image to form an appearance image data group;

[0015] The multi-angle acquisition method includes collecting images from six directions: front, back, left, right, top, and bottom. The multi-light source acquisition method includes illuminating the cigarette package with white light, yellow light, and infrared light to reduce the impact of lighting conditions on image quality.

[0016] The appearance image data group includes acquisition time, acquisition angle, light source type, image resolution, image file format and cigarette pack number.

[0017] Preferably, the data preprocessing module includes a processing unit;

[0018] The processing performs preprocessing on the appearance image data set, including image cutting, grayscale processing, denoising, image enhancement and data standardization, to generate a processed appearance image data set;

[0019] Among them, image cutting includes using ROI extraction technology to determine the target area in the image; grayscale processing includes converting the RGB image into a grayscale image using a grayscale conversion formula; denoising processing includes using median filtering and Gaussian filtering denoising algorithms to remove noise from the image; image enhancement includes using histogram equalization and contrast stretching enhancement algorithms to enhance the visual effect of the image; data standardization includes using a standardization formula to standardize the image data.

[0020] Preferably, the defect detection module training unit;

[0021] The training unit uses strong and weak data enhancement techniques to obtain positive samples from the processed appearance image data set: and negative samples , where the positive sample The same weak data enhancement acquisition as SimCLR is used, including color jitter, random grayscale, cropping, resizing, and Gaussian blur enhancement acquisition, negative samples Strong data augmentation generated by the CutPaste method, where the brightness, contrast, hue, and saturation of the image transformed by the strong data augmentation use the same hyperparameters as the weak data augmentation, and then use the feature extractor Obtain the original sample x to form a model input sample training set D to establish a defect detection model;

[0022] An effective way to use self-supervised learning to improve the feature extraction ability of pre-trained networks, including contrastive learning and proxy learning, and use two proxy tasks to constrain contrastive distribution learning. Two proxy tasks are used to constrain contrastive distribution learning. In order to optimize the distinction between image categories with strong and weak data enhancement, a self-supervised classification constraint proxy task is added to classify strong images, and further constrained to learn more non-uniform feature representations, and a proxy task of constrained contrastive distribution learning is used to optimize the prediction of the relative position of image blocks. The proxy task of relative position prediction of image blocks aims to learn fine-grained features in images and achieve more accurate defect location, and then the self-supervised classification constraint proxy task and the constrained contrastive distribution learning proxy task are used to perform constrained contrastive distribution learning.

[0023] Then, by using the loss function formula to train the cosine similarity of the original sample and the positive sample and negative sample in the feature space, the total loss function is obtained. , and the MSE loss is calculated synchronously to optimize defect recognition.

[0024] Preferably, the total loss function Computational reduction via constrained contrastive distribution learning:

[0025] ;

[0026] In the formula, represents the total loss function, Represents the contrast constrained distribution loss function, which is specifically used to measure the similarity of positive and negative samples in the feature space. represents the loss function of the self-supervised classification constraint proxy task, Represents the loss function for the location prediction proxy task.

[0027] Preferably, the contrast constraint distribution loss function Obtained through the following calculation formula:

[0028] ;

[0029] In the formula, represents the contrast constrained distribution loss function, which is specifically used to measure the similarity of positive and negative samples in the feature space. D represents the training set, which contains the original samples. , positive sample and negative samples , represents the parameters of the feature extractor, It represents the expected value operator, which specifically indicates the expected value calculation for all samples. exp represents the exponential function, which is specifically used to calculate the similarity index. Represents the temperature parameter, which is used to scale the similarity. Represents the feature vector and The cosine similarity of Indicates the number of batches, specifically the number of samples included in each training. and Represent weak data enhancement operations and strong data enhancement operations, respectively, used to generate positive samples and negative samples , and They represent the enhanced samples, Represents a feature extractor.

[0030] Preferably, the loss function of the self-supervised classification constraint proxy task is Obtained by calculation formula:

[0031] ;

[0032] In the formula, The loss function of the self-supervised classification constraint proxy task is used to classify strong and weak data enhancement. D represents the training set, which contains the original samples. , positive sample and negative samples , Represents the parameters of the classifier, specifically the parameters of the neural network used for the classification task, Represents the expected value operator, specifically representing the expected value calculation for all samples. represents the sample label, represents the natural logarithm function, specifically the logarithmic probability used to calculate the classification loss, represents a classifier, specifically a neural network for classification tasks, represents the feature extractor, represents the sample x after data enhancement, specifically including the sample x after strong data enhancement and weak data enhancement;

[0033] The loss function of the location prediction agent task is Obtained through the following calculation formula:

[0034] ;

[0035] In the formula, represents the loss function of the position prediction proxy task, which is used to measure the position relationship between image blocks. D represents the training set, which contains the original samples. , positive sample and negative samples , represents the parameters of the location prediction classifier, specifically the parameters of the neural network used for the location prediction task, Represents the expected value operator, specifically representing the expected value calculation for all image block pairs, Represents the position relationship label of the image block pair, represents the natural logarithm function, specifically the logarithmic probability used to calculate the classification loss, represents a location prediction classifier, specifically a neural network for the location prediction task, represents a feature extractor, specifically a neural network used to extract image features, Represents a fixed-size image block at the center of the image, specifically a reference image block for comparison with adjacent image blocks. Represents one of the randomly selected adjacent image blocks, specifically representing it as a comparison image block to be compared with the central image block.

[0036] Preferably, the MSE loss is calculated and optimized by the following calculation formula:

[0037] ;

[0038] In the formula, Represents the reconstruction loss function, which is used to measure the difference between the autoencoder reconstructed image and the original input image. represents the autoencoder, specifically the neural network used to reconstruct the image, including the encoder and the decoder, y represents the original input image, specifically the original image used to train and evaluate the autoencoder as the reconstruction target, Represents the Euclidean distance, which is specifically used to measure the distance between two vectors.

[0039] Preferably, the evaluation module comprises a matching unit;

[0040] The matching unit obtains the total loss function Match with the preset appearance defect assessment threshold Q to obtain the appearance defect assessment result, and notify relevant personnel and cigarette pack records according to the appearance defect assessment result. At the same time, according to the confirmation of the appearance defect assessment result, the adaptive control model is carried out, and then the real-time monitoring and feedback of the test results are carried out to form a closed loop of detection optimization;

[0041] The appearance defect assessment result is obtained by the following matching method:

[0042] Total loss function <Appearance defect assessment threshold Q, obtain appearance defect-free assessment result;

[0043] Total loss function ≥ Appearance defect assessment threshold Q, obtain appearance defect assessment result.

[0044] A method for detecting cigarette package appearance defects based on deep learning, comprising the following steps:

[0045] Step 1: The data acquisition module uses a high-definition camera and a scanning device to collect images of cigarette packages to generate image data, and simultaneously uses a multi-angle and multi-light source method to obtain a three-dimensional image of the cigarette package to form an appearance image data group;

[0046] Step 2: The data preprocessing module preprocesses the appearance image data set, including image segmentation, grayscale processing, denoising, image enhancement and data standardization, to form a processed appearance image data set;

[0047] Step 3: The defect detection module uses strong and weak data enhancement and feature extractors to extract features from the processed appearance image data set, obtains the model input sample training set D, and then uses the loss function formula to train the similarity of positive and negative samples in the feature space to obtain the total loss function , synchronously calculate the MSE loss to optimize defect identification;

[0048] Step 4: Evaluation module obtains the total loss function It is matched with the preset appearance defect assessment threshold Q to obtain the appearance defect assessment result. At the same time, the model is adaptively adjusted according to the appearance defect assessment result, and then real-time monitoring and feedback of the detection results are carried out.

[0049] The present invention provides a method and system for detecting cigarette package appearance defects based on deep learning, which have the following beneficial effects:

[0050] (1) When the system is running, high-definition cameras and scanning equipment are used to collect images from multiple angles and multiple light sources to ensure that the appearance details of the cigarette package are captured comprehensively and accurately. The image quality and consistency are further improved through image cutting, grayscale processing, denoising, image enhancement and data standardization in the data preprocessing module, laying a solid foundation for subsequent defect detection. Secondly, the defect detection module uses strong and weak data enhancement and feature extractors to extract features. By calculating the similarity of positive and negative samples in the feature space and the total loss function , combined with MSE loss for defect identification and optimization, the model's detection accuracy and robustness for defects are improved. The evaluation module evaluates appearance defects in real time by matching with preset thresholds, and adaptively adjusts the model according to the evaluation results to form a continuously optimized detection closed loop. This comprehensive detection system not only greatly improves the accuracy and efficiency of cigarette package appearance defect detection, but also can adjust and optimize the model in time to ensure the stability and reliability of appearance quality during the production process, ultimately realizing intelligent and efficient quality control.

[0051] (2) By combining strong and weak data augmentation techniques, self-supervised learning, and multiple proxy tasks, the model is optimized to distinguish between strong and weak data augmented image categories, and learns richer non-uniform feature representations and fine-grained features. By calculating the total loss function , including contrast constrained distribution loss function , the loss function of the self-supervised classification constraint proxy task And the loss function of the location prediction agent task , combined with MSE loss for defect recognition optimization, the model has higher accuracy and robustness in the detection of defects of different sizes, ensuring the stability of appearance quality during the production process.

[0052] (3) The reconstruction performance is optimized by minimizing the reconstruction error (MSE), so that the system can accurately reconstruct and identify defects under various complex input images. Secondly, the evaluation module uses the matching unit to evaluate the total loss function. Compare with the preset threshold to accurately evaluate appearance defects. When the total loss is lower than the threshold, the system determines that there is no defect; when the total loss is higher than or equal to the threshold, the system determines that there is a defect, notifies relevant personnel and records defect information, and adaptively adjusts model parameters, monitors and feedbacks test results in real time, forming an efficient closed loop of detection optimization. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] Figure 1 This is a flowchart diagram of a cigarette package appearance defect detection system based on deep learning according to the present invention;

[0054] Figure 2 This is a schematic diagram of the steps of a method for detecting appearance defects of cigarette packages based on deep learning according to the present invention. DETAILED DESCRIPTION

[0055] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0056] Example 1

[0057] The present invention provides a cigarette package appearance defect detection system based on deep learning, please refer to Figure 1 , including data acquisition module, data preprocessing module, defect detection module and evaluation module;

[0058] The data acquisition module uses a high-definition camera and a scanning device to collect images of cigarette packages to generate image data, and simultaneously uses a multi-angle and multi-light source method to obtain a three-dimensional image of the cigarette package to form an appearance image data group;

[0059] The data preprocessing module preprocesses the appearance image data set, including image cutting, grayscale processing, denoising, image enhancement and data standardization, to form a processed appearance image data set;

[0060] The defect detection module uses strong and weak data enhancement and feature extractors to extract features from the processed appearance image data set, obtains the model input sample training set D, and then uses the loss function formula to train the similarity of positive and negative samples in the feature space to obtain the total loss function , synchronously calculate the MSE loss to optimize defect identification;

[0061] The evaluation module obtains the total loss function It is matched with the preset appearance defect assessment threshold Q to obtain the appearance defect assessment result. At the same time, the model is adaptively adjusted according to the appearance defect assessment result, and then real-time monitoring and feedback of the detection results are carried out.

[0062] In this embodiment, high-definition cameras and scanning equipment are used to collect images from multiple angles and multiple light sources to ensure that the appearance details of the cigarette package are captured comprehensively and accurately. The image quality and consistency are further improved through image cutting, grayscale processing, denoising, image enhancement and data standardization in the data preprocessing module, laying a solid foundation for subsequent defect detection. Secondly, the defect detection module uses strong and weak data enhancement and feature extractors to extract features, and calculates the similarity of positive and negative samples in the feature space and the total loss function. , combined with MSE loss for defect identification and optimization, the model's detection accuracy and robustness for defects are improved. The evaluation module evaluates appearance defects in real time by matching with preset thresholds, and adaptively adjusts the model according to the evaluation results to form a continuously optimized detection closed loop. This comprehensive detection system not only greatly improves the accuracy and efficiency of cigarette package appearance defect detection, but also can adjust and optimize the model in time to ensure the stability and reliability of appearance quality during the production process, ultimately realizing intelligent and efficient quality control.

[0063] Example 2

[0064] This embodiment is explained in Example 1, please refer to Figure 1 ,Specifically: the data acquisition module includes an acquisition unit;

[0065] The acquisition unit acquires images of cigarette packages by using a high-definition camera and a scanning device to generate image data, and simultaneously acquires a stereoscopic image of the cigarette package by using a multi-angle and multi-light source method, and marks the angle and light source in the stereoscopic image to form an appearance image data group;

[0066] The multi-angle acquisition method includes collecting images from six directions: front, back, left, right, top, and bottom. The multi-light source acquisition method includes illuminating the cigarette package with white light, yellow light, and infrared light to reduce the impact of lighting conditions on image quality.

[0067] The appearance image data group includes acquisition time, acquisition angle, light source type, image resolution, image file format and cigarette pack number.

[0068] The data preprocessing module includes a processing unit;

[0069] The processing performs preprocessing on the appearance image data set, including image cutting, grayscale processing, denoising, image enhancement and data standardization, to generate a processed appearance image data set;

[0070] Among them, image cutting includes using ROI extraction technology to determine the target area in the image; grayscale processing includes converting the RGB image into a grayscale image using a grayscale conversion formula; denoising processing includes using median filtering and Gaussian filtering denoising algorithms to remove noise from the image; image enhancement includes using histogram equalization and contrast stretching enhancement algorithms to enhance the visual effect of the image; data standardization includes using a standardization formula to standardize the image data.

[0071] Example 3

[0072] This embodiment is explained in Example 1, please refer to Figure 1 , specifically: the defect detection module training unit;

[0073] The training unit uses strong and weak data enhancement techniques to obtain positive samples from the processed appearance image data set: and negative samples , where the positive sample The same weak data enhancement acquisition as SimCLR is used, including color jitter, random grayscale, cropping, resizing, and Gaussian blur enhancement acquisition, negative samples Strong data augmentation generated by the CutPaste method, where the brightness, contrast, hue, and saturation of the image transformed by the strong data augmentation use the same hyperparameters as the weak data augmentation, and then use the feature extractor Obtain the original sample x to form a model input sample training set D to establish a defect detection model;

[0074] An effective way to use self-supervised learning to improve the feature extraction capability of pre-trained networks, including contrastive learning and proxy learning, and using two proxy tasks to constrain contrastive distribution learning. Two proxy tasks are used to constrain contrastive distribution learning. In order to optimize the distinction between image categories with strong and weak data enhancement, a self-supervised classification constraint proxy task is added to perform strong classification, and further constraints are used to learn more non-uniform feature representations, and a proxy task of constrained contrastive distribution learning is used to optimize the prediction of the relative position of image blocks. The proxy task of relative position prediction of image blocks aims to learn fine-grained features in images and achieve more accurate defect location, and then the self-supervised classification constraint proxy task and the constrained contrastive distribution learning proxy task are used to perform constrained contrastive distribution learning;

[0075] Then, by using the loss function formula to train the cosine similarity of the original sample and the positive sample and negative sample in the feature space, the total loss function is obtained. , and the MSE loss is calculated synchronously to optimize defect recognition.

[0076] The total loss function Computational reduction via constrained contrastive distribution learning:

[0077] ;

[0078] In the formula, represents the total loss function, Represents the contrast constrained distribution loss function, which is specifically used to measure the similarity of positive and negative samples in the feature space. represents the loss function of the self-supervised classification constraint proxy task, Represents the loss function for the location prediction proxy task.

[0079] The contrast constrained distribution loss function Obtained through the following calculation formula:

[0080] ;

[0081] In the formula, represents the contrast constrained distribution loss function, which is specifically used to measure the similarity of positive and negative samples in the feature space. D represents the training set, which contains the original samples. , positive sample and negative samples , represents the parameters of the feature extractor, It represents the expected value operator, which specifically indicates the expected value calculation for all samples. exp represents the exponential function, which is specifically used to calculate the similarity index. Represents the temperature parameter, which is used to scale the similarity. Represents the feature vector and The cosine similarity of Indicates the number of batches, specifically the number of samples included in each training. and Represent weak data enhancement operations and strong data enhancement operations, respectively, used to generate positive samples and negative samples , and They represent the enhanced samples, Represents a feature extractor.

[0082] The self-supervised classification constraint proxy task loss It can be obtained by the calculation formula:

[0083] ;

[0084] In the formula, The loss function of the self-supervised classification constraint proxy task is used to classify strong and weak data enhancement. D represents the training set, which contains the original samples. , positive sample and negative samples , Represents the parameters of the classifier, specifically the parameters of the neural network used for the classification task, Represents the expected value operator, specifically representing the expected value calculation for all samples. represents the sample label, represents the natural logarithm function, specifically the logarithmic probability used to calculate the classification loss, represents a classifier, specifically a neural network for classification tasks, represents the feature extractor, represents the sample x after data enhancement, specifically including the sample x after strong data enhancement and weak data enhancement;

[0085] The loss function of the location prediction agent task is Obtained through the following calculation formula:

[0086] ;

[0087] In the formula, represents the loss function of the position prediction proxy task, which is used to measure the position relationship between image blocks. D represents the training set, which contains the original samples. , positive sample and negative samples , represents the parameters of the location prediction classifier, specifically the parameters of the neural network used for the location prediction task, Represents the expected value operator, specifically representing the expected value calculation for all image block pairs, Represents the position relationship label of the image block pair, represents the natural logarithm function, specifically the logarithmic probability used to calculate the classification loss, represents a location prediction classifier, specifically a neural network for the location prediction task, represents a feature extractor, specifically a neural network used to extract image features, Represents a fixed-size image block at the center of the image, specifically a reference image block for comparison with adjacent image blocks. Represents one of the randomly selected adjacent image blocks, specifically representing it as a comparison image block to be compared with the central image block.

[0088] In this embodiment, by using a combination of strong and weak data enhancement technology, self-supervised learning and multiple proxy tasks, the model's ability to distinguish between strong and weak data enhanced image categories is optimized, and richer non-uniform feature representations and fine-grained features are learned. By calculating the total loss function , including contrast constrained distribution loss function , the loss function of the self-supervised classification constraint proxy task And the loss function of the location prediction agent task , combined with MSE loss for defect recognition optimization, the model has higher accuracy and robustness in the detection of defects of different sizes, ensuring the stability of appearance quality during the production process.

[0089] Example 4

[0090] This embodiment is explained in Example 1, please refer to Figure 1 Specifically, the MSE loss is calculated and optimized by the following formula:

[0091] ;

[0092] In the formula, Represents the reconstruction loss function, which is used to measure the difference between the autoencoder reconstructed image and the original input image. represents the autoencoder, specifically the neural network used to reconstruct the image, including the encoder and the decoder, y represents the original input image, specifically the original image used to train and evaluate the autoencoder as the reconstruction target, Represents the Euclidean distance, which is specifically used to measure the distance between two vectors.

[0093] The evaluation module includes a matching unit;

[0094] The matching unit obtains the total loss function Match with the preset appearance defect assessment threshold Q to obtain the appearance defect assessment result, and notify relevant personnel and cigarette pack records according to the appearance defect assessment result. At the same time, according to the confirmation of the appearance defect assessment result, the adaptive control model is carried out, and then the real-time monitoring and feedback of the test results are carried out to form a closed loop of detection optimization;

[0095] The appearance defect assessment result is obtained by the following matching method:

[0096] Total loss function <Appearance defect assessment threshold Q, obtain appearance defect-free assessment result;

[0097] Total loss function ≥ Appearance defect assessment threshold Q, obtain appearance defect assessment result.

[0098] In this embodiment, the reconstruction performance is optimized by minimizing the reconstruction error (MSE), so that the system can accurately reconstruct and identify defects under various complex input images. Secondly, the evaluation module uses the matching unit to evaluate the total loss function. Compare with the preset threshold to accurately evaluate appearance defects. When the total loss is lower than the threshold, the system determines that there is no defect; when the total loss is higher than or equal to the threshold, the system determines that there is a defect, notifies relevant personnel and records defect information, and adaptively adjusts model parameters, monitors and feedbacks test results in real time, forming an efficient closed loop of detection optimization.

[0099] Example 5

[0100] A method for detecting cigarette package appearance defects based on deep learning, please refer to Figure 2 , specifically: including the following steps:

[0101] Step 1: The data acquisition module uses a high-definition camera and a scanning device to collect images of cigarette packages to generate image data, and simultaneously uses a multi-angle and multi-light source method to obtain a three-dimensional image of the cigarette package to form an appearance image data group;

[0102] Step 2: The data preprocessing module preprocesses the appearance image data set, including image segmentation, grayscale processing, denoising, image enhancement and data standardization, to form a processed appearance image data set;

[0103] Step 3: The defect detection module uses strong and weak data enhancement and feature extractors to extract features from the processed appearance image data set, obtains the model input sample training set D, and then uses the loss function formula to train the similarity of positive and negative samples in the feature space to obtain the total loss function , synchronously calculate the MSE loss to optimize defect identification;

[0104] Step 4: Evaluation module obtains the total loss function It is matched with the preset appearance defect assessment threshold Q to obtain the appearance defect assessment result. At the same time, the model is adaptively adjusted according to the appearance defect assessment result, and then real-time monitoring and feedback of the detection results are carried out.

[0105] The above formulas are all dimensionless and numerical calculations. The formula is a formula for the most recent real situation obtained by collecting a large amount of data and performing software simulation. The preset parameters in the formula are set by technicians in this field according to actual conditions.

[0106] The above description is only by way of illustration of certain exemplary embodiments of the present invention. It is undoubted that those skilled in the art can modify the described embodiments in various ways without departing from the spirit and scope of the present invention. Therefore, the above drawings and descriptions are illustrative in nature and should not be construed as limiting the scope of protection of the claims of the present invention.

[0107] It should be noted that, in this article, if there are first and second, etc., relational terms are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or still includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0108] It should be understood that in the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0109] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

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

[0111] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0112] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0113] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0114] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc., various media that can store program codes.

[0115] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A cigarette package appearance defect detection system based on deep learning, characterized by: It includes data acquisition module, data preprocessing module, defect detection module and evaluation module; The data acquisition module uses a high-definition camera and a scanning device to collect images of cigarette packages to generate image data, and simultaneously uses a multi-angle and multi-light source method to obtain a three-dimensional image of the cigarette package to form an appearance image data group; The data preprocessing module preprocesses the appearance image data set, including image cutting, grayscale processing, denoising, image enhancement and data standardization, to form a processed appearance image data set; The defect detection module uses strong and weak data enhancement and feature extractors to extract features from the processed appearance image data set, obtains the model input sample training set D, and then uses the loss function formula to train the similarity of positive and negative samples in the feature space to obtain the total loss function , synchronously calculate the MSE loss to optimize defect identification; The evaluation module obtains the total loss function It is matched with the preset appearance defect assessment threshold Q to obtain the appearance defect assessment result. At the same time, the model is adaptively adjusted according to the appearance defect assessment result, and then real-time monitoring and feedback of the detection results are carried out.

2. The cigarette package appearance defect detection system based on deep learning according to claim 1, characterized in that: The data acquisition module includes an acquisition unit; The acquisition unit acquires images of cigarette packages by using a high-definition camera and a scanning device to generate image data, and simultaneously acquires a stereoscopic image of the cigarette package by using a multi-angle and multi-light source method, and marks the angle and light source in the stereoscopic image to form an appearance image data group; The multi-angle acquisition method includes collecting images from six directions: front, back, left, right, top, and bottom. The multi-light source acquisition method includes illuminating the cigarette package with white light, yellow light, and infrared light to reduce the impact of lighting conditions on image quality. The appearance image data group includes acquisition time, acquisition angle, light source type, image resolution, image file format and cigarette pack number.

3. The cigarette package appearance defect detection system based on deep learning according to claim 1, characterized in that: The data preprocessing module includes a processing unit; The processing performs preprocessing on the appearance image data set, including image cutting, grayscale processing, denoising, image enhancement and data standardization, to generate a processed appearance image data set; Among them, image cutting includes using ROI extraction technology to determine the target area in the image; grayscale processing includes converting the RGB image into a grayscale image using a grayscale conversion formula; denoising processing includes using median filtering and Gaussian filtering denoising algorithms to remove noise from the image; image enhancement includes using histogram equalization and contrast stretching enhancement algorithms to enhance the visual effect of the image; data standardization includes using a standardization formula to standardize the image data.

4. The cigarette package appearance defect detection system based on deep learning according to claim 1, characterized in that: The defect detection module training unit; The training unit uses strong and weak data enhancement techniques to obtain positive samples from the processed appearance image data set: and negative samples , where the positive sample The same weak data enhancement acquisition as SimCLR is used, including color jitter, random grayscale, cropping, resizing, and Gaussian blur enhancement acquisition, negative samples Strong data augmentation generated by the CutPaste method, where the brightness, contrast, hue, and saturation of the image transformed by the strong data augmentation use the same hyperparameters as the weak data augmentation, and then use the feature extractor Obtain the original sample x to form a model input sample training set D to establish a defect detection model; By using the loss function formula to train the cosine similarity of the original sample and the positive sample and negative sample in the feature space, the total loss function is obtained. , and the MSE loss is calculated synchronously to optimize defect recognition.

5. The cigarette package appearance defect detection system based on deep learning according to claim 4, characterized in that: The total loss function Computational reduction via constrained contrastive distribution learning: ; In the formula, represents the total loss function, Represents the contrast constrained distribution loss function, which is specifically used to measure the similarity of positive and negative samples in the feature space. represents the loss function of the self-supervised classification constraint proxy task, Represents the loss function for the location prediction proxy task.

6. The cigarette package appearance defect detection system based on deep learning according to claim 5, characterized in that: The contrast constrained distribution loss function Obtained through the following calculation formula: ; In the formula, represents the contrast constrained distribution loss function, which is specifically used to measure the similarity of positive and negative samples in the feature space. D represents the training set, which contains the original samples. , positive sample and negative samples , represents the parameters of the feature extractor, It represents the expected value operator, which specifically indicates the expected value calculation for all samples. exp represents the exponential function, which is specifically used to calculate the similarity index. Represents the temperature parameter, which is used to scale the similarity. Represents the feature vector and The cosine similarity of Indicates the number of batches, specifically the number of samples included in each training. and Represent weak data enhancement operations and strong data enhancement operations, respectively, used to generate positive samples and negative samples , and They represent the enhanced samples, Represents a feature extractor.

7. The cigarette package appearance defect detection system based on deep learning according to claim 5, characterized in that: The loss function of the self-supervised classification constraint proxy task is Obtained by calculation formula: ; In the formula, The loss function of the self-supervised classification constraint proxy task is used to classify strong and weak data enhancements. D represents the training set, which contains the original samples. , positive sample and negative samples , Represents the parameters of the classifier, specifically the parameters of the neural network used for the classification task, Represents the expected value operator, specifically representing the expected value calculation for all samples. represents the sample label, represents the natural logarithm function, specifically the logarithmic probability used to calculate the classification loss, represents a classifier, specifically a neural network used for classification tasks, represents the feature extractor, represents the sample x after data enhancement, specifically including the sample x after strong data enhancement and weak data enhancement; The loss function of the location prediction agent task is Obtained through the following calculation formula: ; In the formula, represents the loss function of the position prediction proxy task, which is used to measure the position relationship between image blocks. D represents the training set, which contains the original samples. , positive sample and negative samples , represents the parameters of the location prediction classifier, specifically the parameters of the neural network used for the location prediction task, Represents the expected value operator, specifically representing the expected value calculation for all image block pairs, Represents the position relationship label of the image block pair, represents the natural logarithm function, specifically the logarithmic probability used to calculate the classification loss, represents a location prediction classifier, specifically a neural network for location prediction tasks, represents a feature extractor, specifically a neural network used to extract image features, Represents a fixed-size image block at the center of the image, specifically a reference image block for comparison with adjacent image blocks. Represents one of the randomly selected adjacent image blocks, specifically representing it as a comparison image block to be compared with the central image block.

8. The cigarette package appearance defect detection system based on deep learning according to claim 4, characterized in that: The MSE loss is calculated and optimized by the following calculation formula: ; In the formula, Represents the reconstruction loss function, which is used to measure the difference between the autoencoder reconstructed image and the original input image. represents the autoencoder, specifically the neural network used to reconstruct the image, including the encoder and the decoder, y represents the original input image, specifically the original image used to train and evaluate the autoencoder as the reconstruction target, Represents the Euclidean distance, which is specifically used to measure the distance between two vectors.

9. The cigarette package appearance defect detection system based on deep learning according to claim 1, characterized in that: The evaluation module includes a matching unit; The matching unit obtains the total loss function Match with the preset appearance defect assessment threshold Q to obtain the appearance defect assessment result, and notify relevant personnel and cigarette pack records according to the appearance defect assessment result. At the same time, according to the confirmation of the appearance defect assessment result, the adaptive control model is carried out, and then the real-time monitoring and feedback of the test results are carried out to form a closed loop of detection optimization; The appearance defect assessment result is obtained by the following matching method: Total loss function <Appearance defect assessment threshold Q, obtain appearance defect-free assessment result; Total loss function ≥ Appearance defect assessment threshold Q, obtain appearance defect assessment result.

10. A method for detecting appearance defects of cigarette packages based on deep learning, comprising a cigarette package appearance defect detection system based on deep learning as claimed in any one of claims 1 to 9, characterized in that: The following steps are involved: Step 1: The data acquisition module uses a high-definition camera and a scanning device to collect images of cigarette packages to generate image data, and simultaneously uses a multi-angle and multi-light source method to obtain a three-dimensional image of the cigarette package to form an appearance image data set; Step 2: The data preprocessing module preprocesses the appearance image data set, including image segmentation, grayscale processing, denoising, image enhancement and data standardization, to form a processed appearance image data set; Step 3: The defect detection module uses strong and weak data enhancement and feature extractors to extract features from the processed appearance image data set, obtains the model input sample training set D, and then uses the loss function formula to train the similarity of positive and negative samples in the feature space to obtain the total loss function , synchronously calculate the MSE loss to optimize defect identification; Step 4: Evaluation module obtains the total loss function It is matched with the preset appearance defect assessment threshold Q to obtain the appearance defect assessment result. At the same time, the model is adaptively adjusted according to the appearance defect assessment result, and then real-time monitoring and feedback of the detection results are carried out.

Citation Information

Cited By

  • Building material production quality evaluation and prediction method and system based on data feedback

    CN119579014A

  • A method and system for evaluating and predicting building material production quality based on data feedback

    CN119579014B

  • Article packaging defect detection method and system

    CN119762488A

  • A method and system for detecting defects in item packaging

    CN119762488B

  • Steel ball appearance defect detection method and system based on deep learning

    CN120876489A