Cigarette case defect detection method and system based on mixed double-heterogeneous knowledge distillation network
By using a hybrid dual heterogeneous knowledge distillation network and a teacher-student network architecture and multi-feature fusion strategy, the problem of insufficient generalization ability in cigarette box defect detection is solved, achieving high-precision real-time detection of cigarette box defects, adapting to various defect types in complex scenarios, and improving the intelligence and real-time performance of the detection system.
Patent Information
- Application Number
- CN202511561915.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-29
- Publication Date
- 2026-02-10
AI Technical Summary
In existing technologies, cigarette box defect detection methods suffer from insufficient generalization ability and robustness when the defect types are complex and diverse and defect samples are scarce. It is difficult to achieve comprehensive and accurate identification of cigarette box defects, especially on high-speed production lines where it is difficult to meet the requirements of high precision and real-time performance.
A method based on a hybrid dual heterogeneous knowledge distillation network is adopted. Through a teacher-student network architecture and a multi-feature fusion strategy, standard cigarette box images are used for training. The pixel-level differences between the cigarette box image to be detected and the standard image are calculated to achieve accurate identification of cigarette box defects.
It achieves accurate detection of cigarette box defects without requiring a large number of defect samples, has good generalization ability and robustness, adapts to visual differences between different batches of cigarette boxes, meets the high requirements of high-speed production lines, and improves the accuracy and real-time performance of detection.
Smart Images

Figure CN121504828A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of cigarette box defect detection technology, and in particular to a method and system for detecting cigarette box defects based on a hybrid dual heterogeneous knowledge distillation network. Background Technology
[0002] The statements in this section are merely background information related to the present invention and do not necessarily constitute prior art.
[0003] In the cigarette production process, the appearance quality of cigarette packaging directly affects the product image and subsequent distribution efficiency. Even the slightest flaw can impact consumer perception and market acceptance. Therefore, building an efficient and stable cigarette packaging defect detection system has become a crucial step in ensuring product consistency and brand value.
[0004] In related technologies, there are methods that use machine vision to identify whether cigarette boxes are defective. This involves training a defect recognition model using images of defective cigarette boxes, and then using the trained defect recognition model to identify images of cigarette boxes in production to determine whether the cigarette boxes are defective.
[0005] Cigarette box defects are complex and diverse, including printing errors, scratches, color deviations, as well as packaging issues such as wrinkled packaging film and abnormal sealing. Defects vary significantly in shape and scale, ranging from minor local details to macroscopic anomalies such as overall pattern misalignment. However, the defect samples used by rule-based or traditional supervised learning machine vision methods are scarce and unevenly distributed, resulting in insufficient generalization ability and robustness of defect recognition models, making it difficult to achieve comprehensive and accurate identification of cigarette box defects. Summary of the Invention
[0006] To address the aforementioned problems, this invention proposes a method and system for detecting cigarette box defects based on a hybrid dual heterogeneous knowledge distillation network. By calculating the pixel-level differences between the features of the cigarette box image to be detected and the standard cigarette box image, accurate identification of cigarette box defects can be achieved, thus improving the accuracy of cigarette box defect detection.
[0007] To achieve the above objectives, the present invention adopts the following technical solution: Firstly, a defect detection method for cigarette boxes based on a hybrid dual heterogeneous knowledge distillation network is proposed, including: Acquire an image of the cigarette box to be inspected; Extract image features from the image of the cigarette box to be detected; Calculate the pixel-level differences between the image features of the cigarette box to be detected and the features of the standard cigarette box image to obtain the anomaly score map of the cigarette box to be detected; The anomaly score map is compared with a set threshold to determine whether the image of the cigarette box to be inspected has defects.
[0008] Furthermore, the trained student network is used to extract image features from the cigarette box image to be detected. The process includes: The image of the cigarette box to be detected is encoded to obtain the encoded features; Local and global features of the image are extracted from the encoded features, respectively. Image features are obtained by fusing local and global image features.
[0009] Furthermore, the process of extracting global image features from the encoded features includes: The first feature is obtained by performing convolution, pooling, and feature rearrangement on the encoded features; Perform a linear transformation on the first feature to obtain the linearly transformed feature; After linear transformation, the channel dimension of the features is transposed and then scanned in four directions to obtain four-way scanning features. After linear mapping and activation of the four scanning features, bias processing is performed to obtain the four activated features. The four activation features are fused to obtain the fused features; The first feature is convolved to obtain the convolved feature. The fused features are standardized, and the convolutional features are activated and then multiplied element by element to obtain the second feature. The first and second features are fused to obtain the global features of the image.
[0010] Furthermore, a teacher network is used to extract features from standard cigarette box images. The student network is then trained using these standard cigarette box images. During the training process, both the teacher network and the student network extract features from the standard cigarette box images. Knowledge distillation is then used to use the image features extracted by the teacher network from the training data as a supervised target to guide the training of the student network.
[0011] Furthermore, knowledge distillation is performed using the mean squared error loss function.
[0012] Furthermore, when there are pixels in the abnormal scoring image with a difference greater than a set threshold, the image of the cigarette box to be detected is determined to have a defect; Identify pixels in the abnormal scoring image whose differences exceed a set threshold, and determine the connected components of that pixel in the image of the cigarette box to be detected; This connected component is considered as the defect region in the image of the cigarette box to be inspected.
[0013] Secondly, a cigarette box defect detection system based on a hybrid dual heterogeneous knowledge distillation network is proposed, including: The image acquisition unit is used to acquire an image of the cigarette box to be detected. The feature extraction unit is used to extract image features from the cigarette box image to be detected; The difference calculation unit is used to calculate the pixel-level difference between the image features of the cigarette box image to be detected and the features of the standard cigarette box image, and obtain the anomaly score map of the cigarette box to be detected. The defect area determination unit is used to compare the anomaly score map with a set threshold to determine whether there is a defect in the cigarette box image to be inspected.
[0014] Thirdly, a computer device is proposed, the device comprising: A processor, adapted to execute computer programs; A computer-readable storage medium storing a computer program, which, when executed by the processor, implements the cigarette box defect detection method based on a hybrid dual heterogeneous knowledge distillation network proposed in the first aspect.
[0015] Fourthly, a computer-readable storage medium is proposed, which stores a computer program adapted for loading and execution by a processor of the cigarette box defect detection method based on a hybrid dual heterogeneous knowledge distillation network proposed in the first aspect.
[0016] Fifthly, a computer program product is proposed, which includes a computer program that, when executed by a processor, implements the cigarette box defect detection method based on a hybrid dual heterogeneous knowledge distillation network proposed in the first aspect.
[0017] Compared with the prior art, the beneficial effects of the present invention are as follows: This invention proposes a method and system for detecting cigarette box defects based on a hybrid dual heterogeneous knowledge distillation network. After acquiring an image of the cigarette box to be detected, the method directly compares the image with a standard cigarette box image to determine the pixel-level differences between the two images. Then, based on these pixel-level differences, it determines whether the image of the cigarette box to be detected has defects. This method achieves accurate detection of unknown anomalies without requiring a large number of defective cigarette box samples, has good generalization ability, can effectively adapt to visual differences between different batches of cigarette boxes, and also has strong robustness and real-time performance, meeting the high requirements of high-speed production lines for detection systems and making up for the shortcomings of existing technologies in recognizing in complex scenarios.
[0018] Advantages of additional aspects of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description
[0019] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments of this application and their descriptions are used to explain this application and do not constitute an undue limitation of this application.
[0020] Figure 1 This is a flowchart of the cigarette box defect detection method based on a hybrid dual heterogeneous knowledge distillation network proposed in this invention. Detailed Implementation
[0021] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0022] It should be noted that the following detailed descriptions are illustrative and intended to provide further explanation of this application. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains.
[0023] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the exemplary embodiments according to this application. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.
[0024] In the cigarette production process, the appearance quality of cigarette packaging directly affects product image and subsequent distribution efficiency. Even minor flaws can impact consumer perception and market acceptance. Therefore, building an efficient and stable cigarette packaging defect detection system has become a crucial step in ensuring product consistency and brand value. However, the industry currently relies heavily on manual quality inspection or traditional visual algorithms, which are insufficient to meet the actual needs of high-speed, high-precision production lines. A more intelligent and adaptive solution is urgently needed.
[0025] Defect detection in cigarette boxes faces numerous challenges. First, the types of defects are complex and diverse, including printing errors, scratches, color deviations, and packaging issues such as wrinkled film and abnormal sealing. Defects vary significantly in shape and scale, ranging from minor local details to macroscopic anomalies like overall pattern misalignment, posing a significant challenge to general-purpose detection algorithms. Second, traditional manual inspection methods are not only costly and inefficient, but also susceptible to subjective biases, making consistency difficult to guarantee. Rule-based or traditional supervised learning-based machine vision methods struggle to achieve comprehensive and accurate identification in the context of scarce and unevenly distributed defect samples, exhibiting insufficient generalization ability and robustness. Furthermore, the complex patterns on cigarette boxes and the presence of photographic interference factors such as high light reflection necessitate that the detection system simultaneously assess both subtle defects and global anomalies, maintaining a high detection rate while controlling the false alarm rate to meet the high demands of multi-scale, multi-level feature perception and real-time performance in actual production environments.
[0026] To achieve timely and accurate identification of defective cigarette boxes, this invention proposes a cigarette box defect detection method based on a hybrid dual heterogeneous knowledge distillation network. This method utilizes data containing only standard cigarette box images for modeling, enabling automatic learning and construction of normal appearance patterns. This allows for accurate detection of unknown anomalies without requiring a large number of defect samples. The designed model exhibits good generalization ability, effectively adapting to visual differences between different batches of cigarette boxes. It also possesses strong robustness and real-time performance, meeting the high requirements of high-speed production lines for detection systems and overcoming the shortcomings of existing technologies in complex scenarios.
[0027] The standard cigarette box image refers to a normal cigarette box image without defects.
[0028] like Figure 1 As shown, the cigarette box defect detection method based on a hybrid dual heterogeneous knowledge distillation network proposed in this embodiment of the invention includes: Acquire an image of the cigarette box to be inspected; Extract image features from the image of the cigarette box to be detected; Calculate the pixel-level differences between the image features of the cigarette box to be detected and the features of the standard cigarette box image to obtain the anomaly score map of the cigarette box to be detected; The anomaly score map is compared with a set threshold to determine whether the image of the cigarette box to be inspected has defects.
[0029] The cigarette box defect detection method proposed in this invention, based on a hybrid dual heterogeneous knowledge distillation network, utilizes a teacher-student network architecture, a dual decoder design, and a multi-feature fusion strategy to accurately extract features from cigarette box images. Then, by identifying the pixel-level differences between the two types of image features, the defect area of the cigarette box to be detected is determined. This effectively solves the bottlenecks of sensitivity and generalization in traditional unsupervised cigarette box defect detection, and achieves high-precision real-time detection of various types of cigarette box defects.
[0030] This invention utilizes a cigarette box defect detection model to identify cigarette box images and determine whether defects exist. The cigarette box defect detection model includes a student network and a teacher network. Combining the heterogeneous characteristics of the teacher and student networks significantly improves the detection capability for structural defects and global anomalies on the cigarette box surface. The teacher network employs a pure encoder-only architecture to extract high-dimensional feature representations from the input standard cigarette box image, obtaining standard cigarette box image features. The student network includes a ResNet-based encoder, two functionally heterogeneous decoders (a convolutional upsampling decoder (Conv Upsample) and a long-range modeling decoder (Mamba UpNet), and a multi-feature model module. During training, it extracts image features from the standard cigarette box image, and after training, it extracts image features from the cigarette box image to be detected.
[0031] The teacher network and student network proposed in this embodiment of the invention adopt a dual heterogeneous design with different structures, which effectively alleviates the "identity mapping" problem commonly found in traditional knowledge distillation, thereby enhancing the model's ability to distinguish and detect complex defect types, such as minor scratches, indentations, and printing offsets, and thus improving the accuracy of defect recognition in cigarette box images.
[0032] During model training, the input standard cigarette box image First, the system enters the teacher network, which extracts high-level semantic features from the standard cigarette box image using an encoder. This feature can be used to directly determine whether there are defects in the image of the cigarette box to be detected, and it can also be used as a distillation supervision signal to guide the training of the student network.
[0033] The student network first uses a ResNet encoder to extract multi-scale features. The samples are then convolved and fused before being fed into two complementary decoders. The Conv Upsample decoder is mainly used to reconstruct local structural information, and is particularly suitable for detecting fine-grained defects such as printing flaws and edge damage; the Mamba UpNet decoder has the ability to model long-range dependencies and can effectively identify global defects such as inconsistencies in printing patterns and structural deformations.
[0034] Finally, the outputs of the two decoders are integrated through a multi-feature fusion module to improve the system's adaptability to various defect types. The difference between the outputs of the teacher network and the student network is used as an anomaly metric, thereby achieving high-precision and robust cigarette box defect detection.
[0035] The cigarette box defect detection method based on a hybrid dual heterogeneous knowledge distillation network proposed in this invention is deployed on an industrial camera and a GPU-accelerated computing device for real-time defect detection of cigarette boxes on an assembly line. The industrial camera is used to acquire images of the cigarette boxes; the computing device is used to identify the images acquired by the industrial camera to determine whether the cigarette boxes have defects.
[0036] In the actual production process of cigarette boxes, a trained student network is used to extract image features from the images of the cigarette boxes to be inspected. The process includes: The image of the cigarette box to be detected is encoded to obtain the encoded features; Local and global features of the image are extracted from the encoded features, respectively. Image features are obtained by fusing local and global image features.
[0037] In the process of extracting image features from the cigarette box image to be detected, the image is first normalized and standardized; then, image features are extracted from the normalized and standardized image as the image features of the cigarette box image to be detected.
[0038] The process of extracting global features from encoded features includes: The first feature is obtained by performing convolution, pooling, and feature rearrangement on the encoded features; Perform a linear transformation on the first feature to obtain the linearly transformed feature; After linear transformation, the channel dimension of the features is transposed and then scanned in four directions to obtain four-way scanning features. After linear mapping and activation of the four scanning features, bias processing is performed to obtain the four activated features. The four activation features are fused to obtain the fused features; The first feature is convolved to obtain the convolved feature. The fused features are standardized, and the convolutional features are activated and then multiplied element by element to obtain the second feature. The first and second features are fused to obtain the global features of the image.
[0039] The teacher network extracts features from standard cigarette box images; the student network is trained using the standard cigarette box images. During the training process, both the teacher network and the student network extract features from the standard cigarette box images. Knowledge distillation is used to use the image features extracted by the teacher network as the supervised target to guide the training of the student network.
[0040] The process of training a student network using standard cigarette box images includes: S1: Perform data preprocessing on standard cigarette box images, including normalization and standardization.
[0041] The standard cigarette box image is a high-resolution industrial image captured from the surface of a defect-free cigarette box. The size is uniformly adjusted to a fixed size (e.g., 256 × 256 pixels) and normalized and standardized.
[0042] S1.1: Define the standard cigarette box image as ,in, Represents the dimension of the cigarette box image. Indicates the height of the original image, This represents the width of the original image. The formula for scaling a standard cigarette box image is as follows: ; ; in, This represents the corresponding pixel in the scaled image. These are the pixel coordinates. Image of a cigarette box. and This represents the width and height of the cigarette box image. and This indicates the width and height of the scaled image. and This represents the scaling factor.
[0043] S1.2: Normalize the scaled image data using the following formula: ; in, and Let represent the maximum and minimum values of all pixels in the image, respectively; let h represent the height of the image after scaling, and w represent the width of the image after scaling. This is the normalized image.
[0044] S1.3: Standardize the image data using the following formula: ; in, This represents the average value of each channel. Represents the standard deviation of each channel. This is the image after standardization processing.
[0045] S2: Input the standard cigarette box image into the teacher network and the student network, and extract the features of the standard cigarette box image through the teacher network and the student network respectively.
[0046] Teacher Network The architecture comprises a six-layer convolutional neural network with two interspersed average pooling layers. The teacher network is initialized using a pre-trained WideResNet-101 model, trained on the ImageNet dataset, and then transferred to this task for extracting features from standard cigarette box images. During training, the mean squared error (MSE) loss function is used for knowledge distillation. The feature extraction process of the standard cigarette box image, input as training images into the teacher network, is as follows:
[0047] In the formula, The standard cigarette box image features extracted from the teacher's network. Let h1 represent the height of the image feature, w1 represent the width of the image feature, and c1 represent the channel dimension of the image feature. The teacher network will serve as a supervisory signal to guide the training of the student network and to subsequently determine whether the image of the cigarette box to be tested has defects.
[0048] To overcome the "identity mapping" problem in traditional distillation, this invention proposes a heterogeneous student network, which includes an encoder and dual decoders. The encoder encodes the cigarette box image to obtain encoded features. The dual decoders extract local and global features from the encoded features.
[0049] The encoder in the student network is constructed using a ResNet backbone network, comprising four residual modules (Block 1 to Block 4). The intermediate features extracted from the first three residual modules are convolved and then concatenated before being input into Block 4 to generate the final encoded features. This is expressed as follows:
[0050] in, This represents the convolution operation. This indicates the concatenation of channel dimensions. This represents the i-th convolutional module in the ResNet backbone network. This represents the extracted aggregated features. This represents the concatenated convolutional features.
[0051] The decoder of the student network consists of two branches: a local decoding branch (Conv Upsample) and a global decoding branch (Mamba UpNet). The local decoding branch extracts local features of the encoded features, while the global decoding branch extracts global features of the encoded features. Finally, the decoder integrates the outputs of the two branches through a multi-feature fusion module to generate image features. .
[0052] The local decoding branch (Conv Upsample) focuses on preserving and amplifying local structural information, making it suitable for detecting local printing defects, scratches, and other details. This branch achieves spatial feature recovery by alternately stacking upsampling and convolution operations.
[0053] in, Indicates an upsampling operation. This represents the extracted local features at each stage. This represents the extracted local features. To enhance the perception of large-scale structural anomalies, such as cigarette box structural deformation or overall pattern shift, a Mamba UpNet structure is introduced into the global decoding branch (Mamba UpNet). This structure utilizes dilated convolution, multi-scale pooling, and feature rearrangement modules to extract global features. The feature calculation is as follows:
[0054]
[0055] in, This indicates a fully connected operation. Representing neural networks layer, This indicates the addition of characteristic elements. This represents the extracted global features. This module is a deep neural network module that integrates selective scanning mechanisms and spatial convolutional structures, designed to handle long-range dependencies and local spatial features in two-dimensional images. As the first feature, , These are the height and width of the image, respectively. It is the input channel dimension; As the second feature, , Indicates the output dimension of the model. This indicates the training batch of the model. The module's input tensor is , The module first... Perform linear transformation To obtain the features after linear transformation , , Define dimensions for the model, where, Transposed through channel dimension It inputs depthwise separable convolutions to capture local spatial structure. The core part constructs four scanning directions (row, row flip, column, column flip) to form four-way scanning features. ,in The four scanning features are as follows: The row sequence, row-reversed sequence, column sequence, and column-reversed sequence. Then, Through two layers of linear transformation, combined with the intermediate dimension Generate dynamic time steps , The dimension representing the intermediate states of the model. The four-way scanning features of the input Dynamically generated through two layers of linear mapping, and then activated by Softplus with an added bias. Four-way activation features were obtained. ,right The result is obtained by summing. At the same time After performing convolution, we obtain the convolutional features. ,Will After standardization by LayerNorm and features Element-wise multiplication is performed on the result after SiLU activation, i.e. Finally, it is output through the projection layer. Restore the dimensions to obtain the output tensor. , Indicates the output dimension of the model. This represents the training batch of the model. This module integrates spatial convolution, dynamic state propagation, and multi-path modeling mechanisms, improving the model's ability to model complex contexts and understand spatiotemporal structures.
[0056] The Multi-Feature Model fuses features from both the local and global decoding branches to capture both detailed and overall structural information, thus obtaining image features. The fusion operations include concatenation, max pooling, depthwise separable convolution, and upsampling. Finally, element-wise multiplication enhances feature interaction capabilities, ultimately generating image features that serve as the output features of the student network. As shown below:
[0057] in This represents depthwise separable convolution. The feature elements are multiplied. During student network training, the mean squared error loss function is used for knowledge distillation, based on the features of the standard cigarette box image output by the teacher network. As a monitoring target, its correlation with the student network output is calculated using the L2 loss function. The difference between them, loss function The definition is as follows:
[0058] After the student network training is completed, the image of the cigarette box to be detected is input into the trained student network to obtain the image features of the cigarette box image; the image features of the cigarette box image to be detected are then compared with the standard cigarette box image features extracted by the teacher network. By comparing the two features and calculating the pixel-level differences between them, an anomaly score map of the cigarette box to be detected is obtained.
[0059] When there are pixels in the abnormal scoring image that have a difference greater than a set threshold, the image of the cigarette box to be detected is determined to have a defect; Identify pixels in the abnormal scoring image whose differences exceed a set threshold, and determine the connected components of that pixel in the image of the cigarette box to be detected; This connected component is considered as the defect region in the image of the cigarette box to be inspected.
[0060] By setting thresholds and performing connected component analysis on the anomaly scoring map, defective areas in the cigarette box images to be inspected can be accurately marked. Visualization of the inspection results is used for automated quality inspection judgment, rework labeling, and product traceability management.
[0061] In summary, this invention achieves high-precision, comprehensive detection of appearance defects in industrial cigarette boxes through an innovative hybrid dual heterogeneous knowledge distillation network. This method requires no defect sample training, exhibits excellent detection performance for various defect types, and can operate stably on high-speed production lines, significantly improving the automation and intelligence level of cigarette box quality inspection.
[0062] This invention also provides a cigarette box defect detection system based on a hybrid dual heterogeneous knowledge distillation network, comprising: The image acquisition unit is used to acquire an image of the cigarette box to be detected. The feature extraction unit is used to extract image features from the cigarette box image to be detected; The difference calculation unit is used to calculate the pixel-level difference between the image features of the cigarette box image to be detected and the features of the standard cigarette box image, and obtain the anomaly score map of the cigarette box to be detected. The defect area determination unit is used to compare the anomaly score map with a set threshold to determine whether there is a defect in the cigarette box image to be inspected.
[0063] It should be noted that the cigarette box defect detection system based on a hybrid dual heterogeneous knowledge distillation network provided in the above embodiments is only an example of the division of the above functional units. In practical applications, the above functions can be assigned to different functional units as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the cigarette box defect detection system based on a hybrid dual heterogeneous knowledge distillation network provided in the above embodiments and the cigarette box defect detection method embodiment based on a hybrid dual heterogeneous knowledge distillation network belong to the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.
[0064] The present invention also discloses a computer device, the device comprising: A processor, adapted to execute computer programs; A computer-readable storage medium storing a computer program, which, when executed by the processor, implements the cigarette box defect detection method based on a hybrid dual heterogeneous knowledge distillation network disclosed in the embodiments of the present invention.
[0065] The present invention also discloses a computer-readable storage medium storing a computer program adapted for loading and execution by a processor of the cigarette box defect detection method based on a hybrid dual heterogeneous knowledge distillation network disclosed in the embodiments of the present invention.
[0066] The present invention also discloses a computer program product, which includes a computer program. When the computer program is executed by a processor, it implements the cigarette box defect detection method based on a hybrid dual heterogeneous knowledge distillation network disclosed in the embodiments of the present invention.
[0067] The method disclosed in this invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor. The software modules can reside in readily available storage media in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory, and the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method. To avoid repetition, detailed descriptions are omitted here.
[0068] Those skilled in the art will recognize that the units and algorithm steps described in conjunction with the embodiments herein can be implemented in electronic hardware or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0069] While the specific embodiments of the present invention have been described above in conjunction with the accompanying drawings, this is not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art without creative effort based on the technical solutions of the present invention are still within the scope of protection of the present invention.
Claims
1. A method for detecting defects in cigarette boxes based on a hybrid dual heterogeneous knowledge distillation network, characterized in that, include: Acquire an image of the cigarette box to be inspected; Extract image features from the image of the cigarette box to be detected; Calculate the pixel-level differences between the image features of the cigarette box to be detected and the features of the standard cigarette box image to obtain the anomaly score map of the cigarette box to be detected; The anomaly score map is compared with a set threshold to determine whether the image of the cigarette box to be inspected has defects.
2. The cigarette box defect detection method based on a hybrid dual heterogeneous knowledge distillation network as described in claim 1, characterized in that, The process of extracting image features from the cigarette box image to be detected using a trained student network includes: The image of the cigarette box to be detected is encoded to obtain the encoded features; Local and global features of the image are extracted from the encoded features, respectively. Image features are obtained by fusing local and global image features.
3. The cigarette box defect detection method based on a hybrid dual heterogeneous knowledge distillation network as described in claim 2, characterized in that, The process of extracting global features from encoded features includes: The first feature is obtained by performing convolution, pooling, and feature rearrangement on the encoded features; Perform a linear transformation on the first feature to obtain the linearly transformed feature; After linear transformation, the channel dimension of the features is transposed and then scanned in four directions to obtain four-way scanning features. After linear mapping and activation of the four scanning features, bias processing is performed to obtain the four activated features. The four activation features are fused to obtain the fused features; The first feature is convolved to obtain the convolved feature. The fused features are standardized, and the convolutional features are activated and then multiplied element by element to obtain the second feature. The first and second features are fused to obtain the global features of the image.
4. The cigarette box defect detection method based on a hybrid dual heterogeneous knowledge distillation network as described in claim 2, characterized in that, The teacher network extracts features from standard cigarette box images; the student network is trained using the standard cigarette box images. During the training process, both the teacher network and the student network extract features from the standard cigarette box images. Knowledge distillation is used to use the image features extracted by the teacher network as the supervised target to guide the training of the student network.
5. The cigarette box defect detection method based on a hybrid dual heterogeneous knowledge distillation network as described in claim 4, characterized in that, Knowledge distillation is performed using the mean squared error loss function.
6. The cigarette box defect detection method based on a hybrid dual heterogeneous knowledge distillation network as described in claim 1, characterized in that, When there are pixels in the abnormal scoring image that have a difference greater than a set threshold, the image of the cigarette box to be detected is determined to have a defect; Identify pixels in the abnormal scoring image whose differences exceed a set threshold, and determine the connected components of that pixel in the image of the cigarette box to be detected; This connected component is considered as the defect region in the image of the cigarette box to be inspected.
7. A cigarette box defect detection system based on a hybrid dual heterogeneous knowledge distillation network, characterized in that, include: The image acquisition unit is used to acquire an image of the cigarette box to be detected. The feature extraction unit is used to extract image features from the cigarette box image to be detected; The difference calculation unit is used to calculate the pixel-level difference between the image features of the cigarette box image to be detected and the features of the standard cigarette box image, and obtain the anomaly score map of the cigarette box to be detected. The defect area determination unit is used to compare the anomaly score map with a set threshold to determine whether there is a defect in the cigarette box image to be inspected.
8. An electronic device, characterized in that, The device includes: A processor, adapted to execute computer programs; A computer-readable storage medium storing a computer program, which, when executed by the processor, implements the cigarette box defect detection method based on a hybrid dual heterogeneous knowledge distillation network as described in any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program adapted to be loaded by a processor and executed by the method for detecting cigarette box defects based on a hybrid dual heterogeneous knowledge distillation network as described in any one of claims 1-6.
10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the cigarette box defect detection method based on a hybrid dual heterogeneous knowledge distillation network as described in any one of claims 1-6.