Cigarette decoration printing defect detection method and system based on student and teacher network

By constructing a student-teacher network and utilizing unsupervised learning to enable the student network to imitate the teacher network and learn the feature distribution of normal cigarette packaging printing images, the problem of diverse defect types and small sample size in existing technologies is solved, and high-precision defect detection and localization are achieved.

CN121147148APending Publication Date: 2025-12-16ZHENGZHOU TOBACCO RES INST OF CNTC +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511275825.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-08
Publication Date
2025-12-16

AI Technical Summary

Technical Problem

Existing unsupervised methods for detecting defects in cigarette packaging and printing cannot effectively identify multiple types of defects, and defect samples are difficult to obtain, resulting in low detection accuracy.

Method used

A student-teacher network is constructed using two identical network models. The teacher network is pre-trained for image classification, while the student network is not pre-trained. Through unsupervised learning, the student network imitates the teacher network, learns the feature distribution of normal cigarette packaging printing images, and detects defects through feature matching.

Benefits of technology

It improves the accuracy of defect detection in cigarette packaging printing, solves the problems of diverse defect types and small sample size, and achieves high-precision defect detection and location.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121147148A_ABST
    Figure CN121147148A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of cigarette decoration printing defect detection, in particular to a cigarette decoration printing defect detection method and system based on a student-teacher network, and the student-teacher network is constructed and comprises a teacher network and a student network which have the same network structure. The teacher network is a network subjected to image classification pre-training, and the student network is a network which is not subjected to pre-training; the training set is used for training the student-teacher network, so that the student network simulates the teacher network, the trained student-teacher network is obtained, and the training set is composed of normal cigarette decoration printing images; and inputting a to-be-detected cigarette decoration printing image into the trained student-teacher network, performing feature matching on the feature maps of different scales output by the student network and the teacher network, and determining a defect detection result of the to-be-detected cigarette decoration printing image according to a feature matching result. According to the invention, the detection precision of the cigarette decoration printing defects is effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of cigarette packaging printing defect detection technology, specifically to a method and system for detecting cigarette packaging printing defects based on a student-teacher network. Background Technology

[0002] The outer packaging of cigarette products not only protects the quality of the tobacco inside but also serves as a medium for conveying brand image and enhancing purchasing competitiveness. During the cigarette packaging printing process, unexpected situations such as environmental changes, machine malfunctions, and human error can lead to defects in the outer packaging. Currently, in actual production, defects are mostly detected by manual visual inspection. However, this method is time-consuming and highly subjective, resulting in low consistency, efficiency, and reliability of the inspection results. In recent years, with the development of computer technology, the emergence of numerous computer vision-based methods has provided new perspectives and approaches for detecting defects in cigarette packaging printing.

[0003] There are two main types of computer vision-based methods for detecting defects in cigarette packaging printing. The first method involves manually extracting or labeling features from existing defect samples, then designing targeted algorithms or using supervised learning methods such as object detection. However, this approach requires a large number of defect samples and corresponding manual feature extraction or labeling, and it can only detect known defect types, making it impractical for real-world industrial applications. The second method involves training a network using unsupervised learning on normal samples, then inputting defect samples into the network. By comparing the feature distributions obtained from the same network for both types of samples, a threshold is used to determine the presence and location of defects. Because cigarette packaging printing defects in actual production are often of uncertain types, forms, and sizes, and the number of samples is limited, defect samples are difficult to obtain, making unsupervised algorithms more suitable. However, existing unsupervised cigarette packaging detection methods can only identify defect types that cause changes in grayscale values, which still falls short of the need to identify multiple types of defects in practice.

[0004] STPM (Student-Teacher Feature Pyramid Matching) employs a student-teacher network framework to perform anomaly detection through pyramid feature matching, providing a novel approach for cigarette packaging printing defect detection. The STPM method uses two structurally identical network models to form the student-teacher network framework for multi-scale feature matching. During training, normal images are input to enable the student network to mimic the teacher network's knowledge; during testing, anomaly detection is achieved by comparing the feature distributions of abnormal and normal images. However, this method is trained and tested on the publicly available MVTec dataset and cannot be directly applied to cigarette packaging defect detection datasets. How to apply the student-teacher network to cigarette packaging defect detection datasets, address the issue of diverse defect types, and improve the accuracy of defect detection and localization is a key problem requiring in-depth research. Summary of the Invention

[0005] To address the aforementioned technical problems, the present invention aims to provide a method and system for detecting defects in cigarette packaging printing based on a student-teacher network. The specific technical solution adopted is as follows: In a first aspect, the present invention provides a method for detecting defects in cigarette packaging printing based on a student-teacher network, comprising the following steps: Construct a student-teacher network, which includes a teacher network and a student network with the same network structure. The teacher network is a network pre-trained for image classification, and the student network is a network that has not been pre-trained for image classification. The student-teacher network is trained using a training set to make the student network mimic the teacher network, resulting in a well-trained student-teacher network. The training set consists of normal cigarette packaging printing images. The cigarette packaging printing image to be detected is input into a trained student-teacher network. Feature maps of different scales output by the student network and feature maps of different scales output by the teacher network are matched. Based on the feature matching results, the defect detection result of the cigarette packaging printing image to be detected is determined.

[0006] In conjunction with the first aspect mentioned above, in some possible implementations, both the teacher network and the student network consist of the first few layers of Wide RestNet 50. The first few layers of Wide RestNet 50 are used to extract feature maps of different scales from the input image. The feature maps of different scales from the input image extracted by the student network and the teacher network are enhanced with attention through an attention module before feature matching is performed.

[0007] In conjunction with the first aspect mentioned above, in some possible implementations, the attention module is a triple attention module, which enhances the attention of feature maps at different scales by respectively enhancing the attention of three aspects: channel and width, channel and height, and height and width.

[0008] In conjunction with the first aspect above, in some possible implementations, the step of performing feature matching between the feature maps of different scales output by the student network and the feature maps of different scales output by the teacher network includes: Based on the similarity between the feature maps of different scales output by the student network and the feature maps of different scales output by the teacher network, defect feature maps of different scales are determined. Upsampling and fusion of defect feature maps at different scales yields the final defect feature map. The final defect feature map is segmented by a threshold to obtain a predicted binary map, which is then used as the feature matching result.

[0009] In conjunction with the first aspect above, in some possible implementations, the calculation formula for determining defect feature maps at different scales is as follows: in: Defect feature maps representing different scales; and Feature maps representing different scales of student networks and teacher networks, respectively; It is the minimum boundary value to prevent the denominator from being 0; This represents the function that takes the maximum value.

[0010] In conjunction with the first aspect above, in some possible implementations, the upsampling and fusion of defect feature maps at different scales to obtain the final defect feature map is calculated using the following formula: in: This represents the final defect feature map; This represents the number of defect feature maps at different scales. Indicates upsampling, Indicates the first Defect feature maps at various scales.

[0011] In conjunction with the first aspect above, in some possible implementations, the method further includes determining an optimal threshold for threshold segmentation of the final defect feature map.

[0012] In conjunction with the first aspect above, in some possible implementations, the step of determining the optimal threshold includes: The dataset containing normal cigarette packaging printing images and defective cigarette packaging printing images was used as test images. The test image is simultaneously input into the student network and teacher network of the trained student-teacher network to obtain the final defect feature map corresponding to the test image; The optimal threshold is determined based on the final defect feature map corresponding to the test image.

[0013] In conjunction with the first aspect above, in some possible implementations, the step of determining the optimal threshold based on the final defect feature map corresponding to the test image includes: An initial set of thresholds is determined, which consists of all non-repeating values ​​of the final defect feature map corresponding to the test image; The final defect feature map corresponding to the test image is segmented using different thresholds from the initial set of thresholds to obtain the threshold segmentation result; Based on the detection results determined by the threshold segmentation results and the actual defect situation corresponding to the test image, the F1 score under different thresholds in the initial set of thresholds is determined, and the threshold corresponding to the largest F1 score is taken as the optimal threshold.

[0014] Secondly, the present invention also provides a cigarette packaging printing defect detection system based on a student-teacher network, including a memory, a processor, and an executable computer program stored in the memory and executable on the processor. When the processor executes the computer program, it performs the method in the first aspect or any possible implementation thereof.

[0015] This invention offers the following advantages: It constructs a student-teacher network using two identical network models. The pre-trained image classification model serves as the teacher network, while the untrained model serves as the student network. During training, the student-teacher network is trained using a training set of normal cigarette packaging printing images. Multi-scale knowledge obtained from the teacher network is extracted into the student network, allowing it to mimic the teacher network and learn the feature distribution of normal cigarette packaging printing images. When detecting defects in cigarette packaging printing images, defective images passing through the student network will exhibit different feature distributions at a certain scale compared to those obtained through the teacher network. By comparing and analyzing the feature maps obtained from the two networks, the feature distribution of the defect is determined, ultimately enabling defect detection and localization. This invention effectively solves the problems of uncertain types, forms, and sizes of cigarette packaging printing defects, as well as the scarcity and difficulty in obtaining defect samples, thus improving the accuracy of cigarette packaging printing defect detection. Attached Figure Description

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

[0017] Figure 1 This is a flowchart illustrating the steps of the cigarette packaging printing defect detection method based on a student-teacher network according to an embodiment of the present invention. Figure 2 This is a schematic diagram of the student-teacher network model structure according to an embodiment of the present invention; Figure 3 This is a structural diagram of the Wide Resnet module according to an embodiment of the present invention; Figure 4 This is a structural diagram of the triple attention module in an embodiment of the present invention. Detailed Implementation

[0018] To clearly illustrate the technical features of this solution, the invention will be described in detail below through specific embodiments and in conjunction with the accompanying drawings.

[0019] Embodiments of the present invention will now be described in more detail with reference to the accompanying drawings. While some embodiments of the invention are shown in the drawings, it should be understood that the invention can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the invention. It should be understood that the accompanying drawings and embodiments are for illustrative purposes only and are not intended to limit the scope of protection of the invention.

[0020] It should be understood that the various steps described in the method embodiments of the present invention may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present invention is not limited in this respect.

[0021] The term "comprising" and its variations as used herein are open-ended inclusions, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below.

[0022] It should be noted that the concepts of "first" and "second" mentioned in this invention are only used to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.

[0023] Although operations or steps are described in a specific order in the accompanying drawings in the embodiments of the present invention, this should not be construed as requiring these operations or steps to be performed in the specific order or serial order shown, or requiring all of the shown operations or steps to be performed to obtain the desired result. In the embodiments of the present invention, these operations or steps may be performed serially; they may be performed in parallel; or a portion of these operations or steps may be performed.

[0024] Furthermore, it is understood that the data involved in the technical solutions of this invention (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and related provisions. Unless otherwise defined, all technical and scientific terms used in this invention have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains, and all parameters or indicators in the formulas involved in this invention are normalized values ​​that have eliminated the influence of dimensions.

[0025] To address the issue of low detection accuracy in existing cigarette packaging printing defect detection processes due to the uncertainty of actual defect types, this invention provides a method and system for detecting cigarette packaging printing defects based on a student-teacher network. This method constructs a student-teacher network using two identical networks: a student network and a teacher network. The student-teacher network is trained using only normal cigarette packaging printing images, allowing it to mimic the teacher network. During defect detection, feature matching is performed on the feature maps identified by the two networks, ensuring that any anomalies can be detected. This ultimately achieves the goal of defect detection and effectively improves the accuracy of cigarette packaging printing defect detection.

[0026] The following will provide a detailed description of a method and system for detecting defects in cigarette packaging printing based on a student-teacher network, provided by an embodiment of the present invention, with reference to the accompanying drawings.

[0027] Figure 1 This diagram illustrates the basic flowchart of a method for detecting defects in cigarette packaging printing based on a student-teacher network, as provided in an embodiment of the present invention. Figure 1 As shown, the method specifically includes the following steps: Step S100: Construct a student-teacher network, which includes a teacher network and a student network with the same network structure. The teacher network is a network pre-trained for image classification, and the student network is a network that has not been pre-trained for image classification.

[0028] Specifically, a student-teacher network is constructed using teacher and student networks with identical network structures. The weights of the teacher network are pre-trained on a large number of publicly available classification datasets, while the weights of the student network are randomly initialized. The model structure of the constructed student-teacher network is as follows: Figure 2 As shown.

[0029] Furthermore, both the student and teacher networks consist of the first few consecutive layers of Wide ResNet 50. Wide ResNet is a high-performance backbone network that combines width and depth, possessing strong feature extraction capabilities. The Wide ResNet network is mainly composed of multiple Wide ResNet blocks. Figure 3 The diagram shows the block structure of Wide ResNet, where k represents the kernel size, c represents the number of output channels, w represents the widening factor, and N represents the number of block repetitions. The first three consecutive layers of the Wide ResNet 50 network can extract features at three scales, from low to high, enabling defect detection at different scales.

[0030] Step S200: Train the student-teacher network using the training set so that the student network imitates the teacher network, thereby obtaining a trained student-teacher network. The training set consists of normal cigarette packaging printing images.

[0031] Specifically, during the training phase, the student-teacher network is trained using a training set consisting of normal cigarette packaging printing images. This involves inputting the normal cigarette packaging printing images from the training set into the student-teacher network. Both networks perform feature recognition on the input images, and the difference between the output features of the two networks is calculated using a loss function. By minimizing the difference, the parameters of the student network are updated, forcing the student network to reduce the overall gap with the teacher network and achieving multi-scale imitation of the teacher model.

[0032] Because the training phase only uses normal cigarette packaging images to train the student-teacher network through unsupervised learning, without needing to prepare defective cigarette packaging printing images for training, it can effectively solve the problem of diverse and difficult-to-obtain types of cigarette packaging printing defects in actual production, and ultimately improve the detection accuracy of cigarette packaging printing defects.

[0033] Furthermore, a student network and a teacher network, constructed using the first three consecutive layers of a Wide ResNet 50 network, were selected to extract multi-scale features from the input image. Simultaneously, to enhance the attention given to feature maps at different scales of defects, an attention module was added before feature matching between the student and teacher networks to enhance the focus on feature maps at different scales. For example... Figure 4As shown, the attention module is specifically a triple attention module. This triple attention module enhances the attention to three aspects—channel and width, channel and height, and height and width—through three branches, thereby establishing the relationship between the channel and spatial position to improve the sensitivity to defects in cigarette packaging printing.

[0034] The triple attention module regularizes feature maps at different scales to prevent overfitting and improve the model's generalization ability. The specific regularization calculation formula is as follows: in: and These represent the feature maps before and after regularization, respectively. This represents the minimum boundary value to prevent the denominator from being 0; the default value is 0. ; This represents the function that takes the maximum value.

[0035] After regularizing the feature maps at different scales, to enable the student network to learn from the teacher network, a loss is calculated on the feature maps extracted from both the student and teacher networks. The specific loss function expression is as follows: Where: Loss represents the loss corresponding to feature maps of different scales; and These represent the width and height of the feature map, respectively. Indicates the number of pixels in the feature map; and Let represent the i-th pixel in the regularized feature maps of the student network and the teacher network, respectively.

[0036] Based on the losses corresponding to the feature maps at different scales determined above, the total loss is determined, which is the sum of the losses corresponding to the feature maps at different scales. By minimizing the loss function, the feature differences extracted by the two networks are reduced, enabling the student network to imitate the teacher network and learn its knowledge. This ensures that for normal cigarette packaging printing images, the student network can extract a multi-scale feature distribution consistent with that of the teacher network.

[0037] Step S300: Input the cigarette packaging printing image to be detected into the trained student-teacher network, perform feature matching between the feature maps of different scales output by the student network and the feature maps of different scales output by the teacher network, and determine the defect detection result of the cigarette packaging printing image to be detected based on the feature matching result.

[0038] Specifically, the cigarette packaging printing image to be detected is simultaneously input into both a student network and a teacher network, resulting in feature maps of different scales output by the student and teacher networks. For normal cigarette packaging printing images, the features extracted by the two networks are consistent, and the similarity of image pixels is high. However, for defective cigarette packaging printing images, since the student network is trained only on normal image datasets, it cannot mimic the feature representation of the teacher network, resulting in different feature distributions between the two networks. Therefore, the similarity of pixels in the defective parts is low. Thus, by performing feature matching on the feature maps of different scales output by the student and teacher networks, defect detection of the cigarette packaging printing image can be achieved.

[0039] Furthermore, the feature maps of different scales extracted from the student network and the teacher network are regularized using a triple attention module. Then, the similarity between the regularized feature maps of the two networks at different scales is calculated by calculating cosine similarity.

[0040] In actual testing, the checkpoints with the minimum total loss during training were selected for testing. That is, after the entire training process was completed, all saved checkpoints were reviewed, and their respective "total loss" values ​​were compared to identify and ultimately select the model version that achieved the lowest total loss. For feature maps of different scales after network regularization, defect feature maps of different scales were calculated by calculating similarity. The specific expression is as follows: in: and Feature maps representing different scales of student networks and teacher networks, respectively; It is the minimum boundary value to prevent the denominator from being 0, and the default value is 0. ; This represents the function that takes the maximum value.

[0041] Next, the defect feature maps at different scales are upsampled using bilinear interpolation to achieve image scaling, ensuring that all defect feature maps have a consistent size. Finally, the corresponding pixels of the multi-scale defect feature maps are multiplied together to obtain the final defect feature map. The specific expression is as follows: in: This represents the number of defect feature maps at different scales. Indicates upsampling, Indicates the first Defect feature maps at various scales.

[0042] After obtaining the final defect feature map, defect detection can be achieved through optimal threshold estimation. Further, a dataset containing both normal and defective cigarette packaging printing images is used as test images. These test images are simultaneously input into both the student and teacher networks of a pre-trained student-teacher network to obtain the final defect feature map corresponding to the test image. Based on this final defect feature map, the optimal threshold is determined.

[0043] Furthermore, in determining the optimal threshold, an initial set of thresholds is first determined, which consists of all non-repeating values ​​of the final defect feature map corresponding to the test image. Then, different thresholds from this initial set are used to perform threshold segmentation on the final defect feature map corresponding to the test image, yielding the threshold segmentation results. Next, based on the detection results determined by the threshold segmentation results and the actual defect situation corresponding to the test image, the corresponding F1 score is calculated for different thresholds from the initial set, as shown in the following expression: in: and represents precision and recall at different thresholds, respectively. Precision is the proportion of samples that are both positive and have a true positive value among all samples that are positive, and recall is the proportion of samples that are both positive and have a true positive value among all samples that have a true positive value.

[0044] Finally, based on the F1 scores corresponding to different thresholds, the optimal threshold is determined, which is the threshold corresponding to the highest F1 score. This optimal threshold is then used to binarize the final defect feature map corresponding to the cigarette packaging printing image to be detected, obtaining a predicted binary map, thereby completing the defect detection and localization.

[0045] The aforementioned method for detecting defects in cigarette packaging printing based on a student-faculty network was tested and evaluated using AUROC (Area Under the Receiver Operating Characteristic Curve) and PRO (PerRegion Overlap Score) as evaluation metrics. AUROC is the most commonly used evaluation metric in the field of anomaly detection, and it is divided into image-level and pixel-level. Image-level AUROC is an indicator for assessing the presence or absence of defects, while pixel-level AUROC is an indicator for assessing defect localization. A higher AUROC value indicates higher model detection accuracy.

[0046] During testing and evaluation, normal cigarette packaging images (referred to as normal images) were marked as negative, while defective cigarette packaging images (referred to as defective images) were marked as positive. The True Positive Rate (TPR) is the percentage of images correctly classified as defective, while the False Positive Rate (FPR) is the percentage of images incorrectly classified as defective, expressed as follows: Wherein: TP, FP, TN, and FN represent true positive, false positive, true negative, and false negative, respectively; TP (True Positive) indicates that both the predicted result and the actual value are positive, indicating a correct prediction; FP (False Positive) indicates that the predicted result is positive, but the actual pixel value is negative, indicating a wrong prediction; TN (True Negative) indicates that both the predicted result and the actual value are negative, indicating a correct prediction; FN (False Negative) indicates that the predicted result is negative, but the actual pixel value is positive, indicating a wrong prediction. The AUROC value represents the area enclosed by the curves formed by the TPR and FPR pairs and the FPR axis at different thresholds within the threshold range [0,1].

[0047] PRO is a performance evaluation metric for anomaly detection models, especially for evaluating the model's ability to locate anomalies. It is expressed as follows: Where: N represents the total number of abnormal regions; Indicates the predicted abnormal region; This represents the actual abnormal area. A higher PRO value indicates a better ability of the model to locate defects.

[0048] In the quantitative evaluation, classic unsupervised anomaly detection models, including PaDiM, DFR, SOM, CFLOW, and STPM, were compared. All images showed an AUROC of 1, indicating that all tested networks could classify whether cigarette packaging printing had defects. Table 1 presents the pixel AUROC and PRO indices of the student-teacher network detection model (the detection model used in the student-teacher network-based cigarette packaging printing defect detection method, i.e., the OUR model in Table 1) compared with classic unsupervised anomaly detection models. The comparison results show that the student-teacher network detection model has the best defect detection and localization accuracy in defect localization.

[0049] Table 1: Comparison of Evaluation Results between Classic Unsupervised Algorithms and Cigarette Packaging Defect Detection Dataset In the aforementioned student-teacher network-based method for detecting defects in cigarette packaging printing, a student-teacher network is constructed using two identical network models. The pre-trained image classification model within the student-teacher network serves as the teacher network, while the untrained model serves as the student network. During training, the student-teacher network is trained using a training set composed of normal cigarette packaging printing images. Multi-scale knowledge obtained from the teacher network is extracted into the student network, allowing it to mimic the teacher network and learn the feature distribution of normal cigarette packaging printing images. During the testing period, when a defective cigarette packaging printing image passes through the student network, the defect will produce a different feature distribution at a certain scale compared to when it passes through the teacher network. By comparing and analyzing the feature maps obtained from the two networks, the feature distribution of the defect is obtained, ultimately enabling defect detection and localization. This method addresses the problems of uncertain types, forms, and sizes of cigarette packaging printing defects, as well as the scarcity and difficulty in obtaining defect samples, thus improving the accuracy of cigarette packaging printing defect detection. Furthermore, extensive implementations on multiple network models using a cigarette packaging printing defect detection dataset demonstrate that the aforementioned student-teacher network detection model exhibits excellent performance in defect detection.

[0050] Based on the same inventive concept, this invention also provides a cigarette packaging printing defect detection system based on a student-teacher network. The system includes a memory, a processor, and an executable computer program stored in the memory and run on the processor. When the processor executes the computer program, it executes any of the aforementioned cigarette packaging printing defect detection methods based on a student-teacher network.

[0051] In this embodiment of the invention, the system can be divided into functional modules according to the above method example. For example, each module can correspond to a separate functional module, or two or more functions can be integrated into one processing module. The integrated module can be implemented in hardware. It should be noted that the module division in this embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods.

[0052] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.

Claims

1. A method for detecting defects in cigarette packaging printing based on a student-teacher network, characterized in that, Includes the following steps: Construct a student-teacher network, which includes a teacher network and a student network with the same network structure. The teacher network is a network pre-trained for image classification, and the student network is a network that has not been pre-trained for image classification. The student-teacher network is trained using a training set to make the student network mimic the teacher network, resulting in a well-trained student-teacher network. The training set consists of normal cigarette packaging printing images. The cigarette packaging printing image to be detected is input into a trained student-teacher network. Feature maps of different scales output by the student network and feature maps of different scales output by the teacher network are matched. Based on the feature matching results, the defect detection result of the cigarette packaging printing image to be detected is determined.

2. The method for detecting defects in cigarette packaging printing based on a student-teacher network according to claim 1, characterized in that, Both the teacher network and the student network consist of the first few layers of WideRestNet 50. The first few layers of WideRestNet 50 are used to extract feature maps of different scales from the input image. The feature maps of different scales of the input image extracted by the student network and the teacher network are enhanced with attention through an attention module before feature matching is performed.

3. The method for detecting defects in cigarette packaging printing based on a student-teacher network according to claim 2, characterized in that, The attention module is a triple attention module, which enhances the attention of feature maps at different scales by respectively enhancing the attention of three aspects: channel and width, channel and height, and height and width.

4. A method for detecting defects in cigarette packaging printing based on a student-teacher network according to any one of claims 1-3, characterized in that, The step of performing feature matching between feature maps of different scales output by the student network and feature maps of different scales output by the teacher network includes: Based on the similarity between the feature maps of different scales output by the student network and the feature maps of different scales output by the teacher network, defect feature maps of different scales are determined. Upsampling and fusion of defect feature maps at different scales yields the final defect feature map. The final defect feature map is segmented by a threshold to obtain a predicted binary map, which is then used as the feature matching result.

5. The method for detecting defects in cigarette packaging printing based on a student-teacher network according to claim 4, characterized in that, The calculation formula for determining defect feature maps at different scales is as follows: in: Defect feature maps representing different scales; and Feature maps representing different scales of student networks and teacher networks, respectively; It is the minimum boundary value to prevent the denominator from being 0; This represents the function that takes the maximum value.

6. The method for detecting defects in cigarette packaging printing based on a student-teacher network according to claim 4, characterized in that, The upsampling and fusion of defect feature maps at different scales yields the final defect feature map, and the corresponding calculation formula is as follows: in: This represents the final defect feature map; This represents the number of defect feature maps at different scales. Indicates upsampling, Indicates the first Defect feature maps at various scales.

7. The method for detecting defects in cigarette packaging printing based on a student-teacher network according to claim 4, characterized in that, The method further includes determining the optimal threshold to be used for threshold segmentation of the final defect feature map.

8. The method for detecting defects in cigarette packaging printing based on a student-teacher network according to claim 7, characterized in that, The steps for determining the optimal threshold include: The dataset containing normal cigarette packaging printing images and defective cigarette packaging printing images was used as test images. The test image is simultaneously input into the student network and teacher network of the trained student-teacher network to obtain the final defect feature map corresponding to the test image; The optimal threshold is determined based on the final defect feature map corresponding to the test image.

9. A method for detecting defects in cigarette packaging printing based on a student-teacher network according to claim 8, characterized in that, The step of determining the optimal threshold based on the final defect feature map corresponding to the test image includes: An initial set of thresholds is determined, which consists of all non-repeating values ​​of the final defect feature map corresponding to the test image; The final defect feature map corresponding to the test image is segmented using different thresholds from the initial set of thresholds to obtain the threshold segmentation result; Based on the detection results determined by the threshold segmentation results and the actual defect situation corresponding to the test image, the F1 score under different thresholds in the initial set of thresholds is determined, and the threshold corresponding to the largest F1 score is taken as the optimal threshold.

10. A cigarette packaging printing defect detection system based on a student-teacher network, characterized in that, The device includes a memory, a processor, and an executable computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to perform a method as described in any one of claims 1 to 9.