A cigarette carton sheet defect detection method, storage medium and device

CN116958116BActive Publication Date: 2026-09-11WUHAN HONGZHICAI PACKAGING PRINTING
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310964586.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-31
Publication Date
2026-09-11
Estimated Expiration
2043-07-31

AI Technical Summary

Technical Problem

[0003]可见,对于上述的低延时需求和小目标缺陷检测的问题,使用现有的YOLOv5目标检测网络模型是无法解决的

Benefits of technology

[0046] Compared with existing technologies, the advantages of this invention are as follows: By improving the YOLOv5s network model, a cigarette box piece defect detection model is obtained. While achieving model lightweighting, it can effectively improve the recognition accuracy of small targets. At the same time, when both the defect detection accuracy and the defect classification accuracy are greater than preset values, the cigarette box piece images with defects detected by the cigarette box piece defect detection model are added to the dataset, realizing automatic expansion of the dataset, reducing training costs and further improving model accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116958116B_ABST
    Figure CN116958116B_ABST
Patent Text Reader

Abstract

The application discloses a cigarette box piece defect detection method, a storage medium and a device, relates to the technical field of deep learning target detection, and comprises the following steps: acquiring a cigarette box piece picture, performing defect labeling on the cigarette box piece picture based on an active labeling mode, and forming a data set; based on improvement of a YOLOv5s network model, a cigarette box piece defect detection model is built, and the data set is used to train the cigarette box piece defect detection model; the performance of the trained cigarette box piece defect detection model is tested, and classification performance testing is performed, so that the defect detection precision and the defect classification precision of the cigarette box piece defect detection model are obtained; based on the test results, when the defect detection precision and the defect classification precision are greater than preset values, the cigarette box piece picture with defects detected by the cigarette box piece defect detection model is incorporated into the data set. The application can realize automatic expansion of the data set, reduce the training cost and further improve the model precision.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of deep learning target detection technology, specifically to a method, storage medium, and device for detecting defects in cigarette box sheets. Background Technology

[0002] While the existing YOLO (an object detection algorithm) network model offers a superior balance between accuracy and speed, leading to its widespread application in industry, it still has limitations in high-speed cigarette box defect detection. High-speed machines are required to detect defects in cigarette boxes at a rate of 100,000 per hour. When using high-definition cameras to capture images, the image resolution is 4096*1600 pixels (4096 pixels wide, 1600 pixels high). However, some defects have dimensions less than 10 pixels wide and high, while others have very large aspect ratios. For example, defects like knife-like lines may have a width of 25 pixels but a height of 1200 pixels.

[0003] It is evident that the existing YOLOv5 object detection network model cannot solve the aforementioned problems of low latency requirements and small target defect detection. Furthermore, when using deep learning object detection methods, due to the lack of open-source and well-annotated datasets in industrial applications, manual annotation is required in specific areas such as cigarette box defect detection. Deep learning methods often require large amounts of labeled data for training, resulting in significant labor costs in this stage. Summary of the Invention

[0004] In view of the shortcomings of the existing technology, the purpose of this invention is to provide a method, storage medium and device for detecting defects in cigarette box pieces, which can realize the automatic expansion of the dataset, reduce training costs and further improve model accuracy.

[0005] To achieve the above objectives, the present invention provides a method for detecting defects in cigarette box sheets, specifically including the following steps:

[0006] Obtain images of cigarette boxes and label them with defects using an active annotation method to form a dataset;

[0007] Based on the improvement of the YOLOv5s network model, a defect detection model for cigarette box sheets was built, and the model was trained using a dataset.

[0008] The trained cigarette box sheet defect detection model was subjected to performance and classification performance tests to obtain the defect detection accuracy and defect classification accuracy of the cigarette box sheet defect detection model.

[0009] Based on the test results, when both the defect detection accuracy and the defect classification accuracy are greater than the preset values, the cigarette box images with defects detected by the cigarette box defect detection model are incorporated into the dataset.

[0010] Based on the above technical solution, the steps of acquiring cigarette box images and annotating them with defects using an active annotation method to form a dataset include:

[0011] Images of cigarette boxes were obtained by taking pictures with a camera, and images of cigarette boxes with defects were actively screened to identify those with defects, and the types of defects were varied.

[0012] The selected cigarette box images were labeled using an active annotation method to form a dataset.

[0013] Based on the above technical solutions,

[0014] The cigarette box defect detection model includes a backbone feature extraction network, an enhanced feature extraction network, and a detection head;

[0015] Based on the improvement of the YOLOv5s network model, a defect detection model for cigarette box sheets was built, specifically:

[0016] The number of channels in the YOLOv5s network model is halved. A residual structure is added to the backbone feature extraction network of the YOLOv5s network model. Structures for stabilizing accuracy are added to the enhanced feature extraction network and the detection head. The ordinary convolutional layers in the enhanced feature extraction network and the convolutional layers in the residual structure are replaced with full-dimensional dynamic convolutions to obtain the cigarette box sheet defect detection model.

[0017] Based on the above technical solutions,

[0018] The ordinary convolutional layer contains only a single static convolutional kernel, applied to all input samples. The expression for the ordinary convolutional layer is:

[0019] y = W*x

[0020] Where y represents the output feature map, x represents the input feature map, W represents the convolution kernel, and * represents the convolution operation;

[0021] The dynamic convolutional layer in the enhanced feature extraction network uses a linear combination of n convolutional kernels, dynamically weighted through an attention mechanism, as expressed in the following expression:

[0022] y=(α w1 W1+...+α wn W n )*x

[0023] Where, α wn Represents the convolution kernel Wn Attention weighting factor;

[0024] The expression for the full-dimensional dynamic convolution is:

[0025] y=(α w1 ⊙α f1 ⊙α c1 ⊙α s1 ⊙W1+...+α wn ⊙α fn ⊙α cn ⊙α sn ⊙W n )*x

[0026] Where, α fn Represents the convolution kernel W n Attention factor α in the output channel dimension cn Represents the convolution kernel W n Attention factor α in the input channel dimension sn Represents the convolution kernel W n In spatial dimensions, the attention factor ⊙ represents the dot product operation along different dimensions of the kernel space.

[0027] Based on the above technical solutions,

[0028] The specific steps for training the cigarette box defect detection model using the dataset include: dividing the dataset into a training set and a validation set according to a set ratio, preprocessing the cigarette box images in the training set and validation set, and using the preprocessed training set and validation set to train the cigarette box defect detection model.

[0029] The preprocessing operation is as follows: crop the image by cropping a preset percentage of the top, bottom, left, and right sides of the image; divide the remaining image into three equal parts along the width direction; resize the divided image into a square image; and normalize each pixel of the square image.

[0030] Based on the above technical solution, the trained cigarette box sheet defect detection model undergoes performance testing and classification performance testing to obtain the defect detection accuracy and defect classification accuracy of the cigarette box sheet defect detection model. Specifically, the performance testing of the cigarette box sheet defect detection model includes:

[0031] The performance of the cigarette box sheet defect detection model was tested, and the defect detection accuracy of the cigarette box sheet defect detection model was obtained:

[0032] If the defect detection accuracy of the cigarette box piece defect detection model is not greater than the first preset value, then the semi-automatic annotation tool built based on SAM and the cigarette box piece defect detection model will annotate the cigarette box piece images with defects that were missed, and actively review the annotation results. The reviewed cigarette box piece images with defects will be incorporated into the dataset, and the dataset will continue to be used to train the cigarette box piece defect detection model.

[0033] If the defect detection accuracy of the cigarette box sheet defect detection model is greater than the first preset value, then a classification performance test will be performed on the cigarette box sheet defect detection model.

[0034] Based on the above technical solution, the trained cigarette box sheet defect detection model undergoes performance testing and classification performance testing to obtain the defect detection accuracy and defect classification accuracy of the cigarette box sheet defect detection model. Specifically, the classification performance testing of the cigarette box sheet defect detection model involves:

[0035] The classification performance of the cigarette box defect detection model was tested, and the defect classification accuracy for defect type classification was obtained:

[0036] If the defect classification accuracy of the cigarette box defect detection model is not greater than the second preset value, then the semi-automatic annotation tool built based on SAM and the cigarette box defect detection model will annotate the cigarette box images with incorrect defect type classification, and actively verify the annotation results. The verified cigarette box images will be incorporated into the dataset, and the dataset will continue to be used to train the cigarette box defect detection model.

[0037] If the defect classification accuracy of the cigarette box defect detection model is greater than the second preset value, then the detected cigarette box images with defects will be incorporated into the dataset.

[0038] Based on the above technical solution, the step of incorporating the detected images of defective cigarette boxes into the dataset specifically involves:

[0039] The defective cigarette box images were annotated with bounding boxes and a txt file was generated and incorporated into the dataset.

[0040] The present invention provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the above-described method for detecting defects in cigarette box sheets.

[0041] The present invention provides a defect detection device for cigarette box sheets, comprising:

[0042] The annotation module is used to acquire cigarette box images and perform defect annotation on the cigarette box images based on an active annotation method to form a dataset;

[0043] The training module is used to build a cigarette box defect detection model based on the improvement of the YOLOv5s network model, and to train the cigarette box defect detection model using the dataset.

[0044] The testing module is used to perform performance testing and classification performance testing on the trained cigarette box sheet defect detection model, and to obtain the defect detection accuracy and defect classification accuracy of the cigarette box sheet defect detection model.

[0045] The execution module is used to incorporate the defective cigarette box images detected by the cigarette box defect detection model into the dataset based on the test results, when both the defect detection accuracy and the defect classification accuracy are greater than preset values.

[0046] Compared with existing technologies, the advantages of this invention are as follows: By improving the YOLOv5s network model, a cigarette box piece defect detection model is obtained. While achieving model lightweighting, it can effectively improve the recognition accuracy of small targets. At the same time, when both the defect detection accuracy and the defect classification accuracy are greater than preset values, the cigarette box piece images with defects detected by the cigarette box piece defect detection model are added to the dataset, realizing automatic expansion of the dataset, reducing training costs and further improving model accuracy. Attached Figure Description

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

[0048] Figure 1 This is a flowchart of a method for detecting defects in cigarette box panels according to an embodiment of the present invention;

[0049] Figure 2 This is a structural diagram of a typical convolutional layer;

[0050] Figure 3 This is a residual structure diagram;

[0051] Figure 4 This is a schematic diagram of the YOLOv5s network model.

[0052] Figure 5 A schematic diagram of the structure of the cigarette box defect detection model obtained by improving the YOLOv5s network model. Detailed Implementation

[0053] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are some embodiments of this application, but not all embodiments.

[0054] See Figure 1 As shown in the figure, the present invention provides a method for detecting defects in cigarette box sheets, the specific steps of which include:

[0055] S1: Obtain images of cigarette boxes and label them with defects using an active annotation method to form a dataset;

[0056] In this invention, images of cigarette boxes are acquired, and defects are labeled on these images using an active annotation method to form a dataset. Specific steps include:

[0057] S101: Based on the images of cigarette box pieces captured by the camera, images of cigarette box pieces with defects are obtained through active screening, and the types of defects are multiple.

[0058] S102: The selected cigarette box images are labeled using an active annotation method to form a dataset.

[0059] Even if we use a camera to capture 8K high-definition images of cigarette boxes, and then manually annotate various defects that may appear on the cigarette box images, we can annotate 1500 to 2000 images in the initial stage of building the dataset.

[0060] S2: Based on the improvement of the YOLOv5s network model, a cigarette box sheet defect detection model was built, and the model was trained using a dataset.

[0061] Based on the improvement of the YOLOv5s network model, a cigarette box defect detection model was built. The cigarette box defect detection model is a nanoscale YOLOv5 target detection network based on the improved full-enclosure dynamic convolution kernel.

[0062] In this invention, the cigarette box sheet defect detection model includes a backbone feature extraction network, an enhanced feature extraction network, and a detection head.

[0063] In this invention, based on an improvement to the YOLOv5s network model, a defect detection model for cigarette box sheets is constructed. Specifically:

[0064] The number of channels in the YOLOv5s network model is halved. A residual structure is added to the backbone feature extraction network. Structures for stabilizing accuracy are added to the enhanced feature extraction network and the detection head. The ordinary convolutional layers in the enhanced feature extraction network and the convolutional layers in the residual structure are replaced with full-dimensional dynamic convolutions, resulting in a cigarette box defect detection model. The structure of the YOLOv5s network model is as follows: Figure 4 As shown, the structure of the cigarette box defect detection model is as follows: Figure 5 As shown.

[0065] The number of channels in the original YOLOv5s network model is halved to achieve model lightweighting. Then, a residual structure is added to the backbone feature extraction network of the YOLOv5s network model, and corresponding structures are added to the enhanced feature extraction network and the detection head to stabilize accuracy. To improve the accuracy of the cigarette box defect detection model in recognizing small targets, the ordinary convolutional layers in the enhanced feature extraction network and the convolutional layers in the residual structure are replaced with full-dimensional dynamic convolutions. The structure of the ordinary convolutional layer (Conv) is as follows: Figure 2 As shown, it consists of three parts: a regular convolutional layer, a batch normalization layer, and an activation layer. The residual structure (C3) is as follows: Figure 3 As shown, 3 indicates that the residual structure is repeated 3 times, and 3*3 / 2 indicates that the convolution kernel size is 3*3 and the stride is 2.

[0066] A novel object detection network model, NODC-YOLOv5 (a nanoscale YOLOv5 object detection network based on improved full-enclosure dynamic convolution kernels), was obtained by improving the YOLOv5 network model.

[0067] In this invention, a regular convolutional layer contains only a single static convolutional kernel, applied to all input samples. The expression for a regular convolutional layer is:

[0068] y = W*x

[0069] Where y represents the output feature map, x represents the input feature map, W represents the convolution kernel, and * represents the convolution operation;

[0070] In this invention, the dynamic convolutional layer in the enhanced feature extraction network uses a linear combination of n convolutional kernels, dynamically weighted through an attention mechanism, making the convolution operation dependent on the input. The expression is:

[0071] y=(α w1 W1+...+α wn W n )*x

[0072] Where, α wn Represents the convolution kernel W n Attention weighting factor;

[0073] This invention utilizes a fully dynamic convolutional layer that incorporates a parallel strategy of multi-dimensional attention mechanisms. This strategy learns different attention levels in the four dimensions of the convolutional kernel and spatial space to achieve more accurate feature extraction. The expression for the fully dynamic convolution is:

[0074] y=(α w1 ⊙α f1 ⊙α c1 ⊙α s1 ⊙W1+…+α wn ⊙α fn ⊙α cn ⊙α sn ⊙W n )*x

[0075] Where, α fn Represents the convolution kernel W n Attention factor α in the output channel dimension cn Represents the convolution kernel W n Attention factor α in the input channel dimension sn Represents the convolution kernel W n In spatial dimensions, the attention factor ⊙ represents the dot product operation along different dimensions of the kernel space.

[0076] α wn α fn α cn α sn These four attention factors are all calculated using the Sigmoid function, whose mathematical expression is:

[0077]

[0078] Because full-dimensional dynamic convolutional layers use a full-dimensional attention module in the convolution kernel compared to ordinary convolutional layers, they can better extract feature information from feature maps and prevent the loss of too much effective information during convolution, thereby improving the accuracy of the model.

[0079] In this invention, a dataset is used to train a cigarette box defect detection model. The specific steps include: dividing the dataset into a training set and a validation set according to a set ratio, preprocessing the cigarette box images in the training set and validation set, and using the preprocessed training set and validation set to train the cigarette box defect detection model.

[0080] The preprocessing operation is as follows: crop the image by cropping a preset percentage of the top, bottom, left, and right sides of the image; divide the remaining image into three equal parts along the width direction; resize the divided image into a square image; and normalize each pixel of the square image.

[0081] In one possible implementation, the dataset is divided in an 8:2 ratio, with the training set accounting for 8% and the validation set accounting for 2%. Since the image size is large, directly inputting it into the network model would consume a significant amount of GPU memory, leading to a smaller batch size during training and prolonging the network's training and fitting time. Therefore, this invention first crops the 8K image with a width and height of 4096*1600 pixels by cropping 20% ​​of the image from the top, bottom, left, and right sides. Then, the remaining image is divided into three equal parts along its width. Since the network model requires a square image as input, the trisectioned image is resized to a width and height of 960*960 pixels. Resizing is based on the longer side; any shorter side less than 960 pixels is padded to 960 pixels. Finally, each pixel in the image is normalized by dividing by 255.

[0082] S3: Perform performance testing and classification performance testing on the trained cigarette box sheet defect detection model to obtain the defect detection accuracy and defect classification accuracy of the cigarette box sheet defect detection model;

[0083] S4: Based on the test results, when both the defect detection accuracy and the defect classification accuracy are greater than the preset values, the cigarette box images with defects detected by the cigarette box defect detection model will be incorporated into the dataset.

[0084] In this invention, the trained cigarette box sheet defect detection model undergoes performance testing and classification performance testing to obtain the defect detection accuracy and defect classification accuracy of the cigarette box sheet defect detection model. Specifically, the performance testing of the cigarette box sheet defect detection model includes:

[0085] The performance of the cigarette box sheet defect detection model was tested, and the defect detection accuracy of the cigarette box sheet defect detection model was obtained:

[0086] If the defect detection accuracy of the cigarette box piece defect detection model is not greater than the first preset value, then the semi-automatic annotation tool built based on SAM and the cigarette box piece defect detection model will annotate the cigarette box piece images with defects that were missed, and actively review the annotation results. The reviewed cigarette box piece images with defects will be incorporated into the dataset, and the dataset will continue to be used to train the cigarette box piece defect detection model.

[0087] If the defect detection accuracy of the cigarette box sheet defect detection model is greater than the first preset value, then a classification performance test will be performed on the cigarette box sheet defect detection model.

[0088] When performing performance testing on the cigarette box defect detection model, if the defect detection accuracy of the cigarette box defect detection model is not greater than 95%, then for the cigarette box images that have missed detection and have defects, a semi-automatic annotation tool based on SAM and the cigarette box defect detection model is used to annotate them. Then, the annotation results are manually reviewed. Since it is not necessary to review every missed defect image, but rather to review the data annotated by the semi-automatic annotation tool, the labor costs can be greatly reduced.

[0089] SAM (Segment Anything Model) is a large segmentation model proposed by Meta, which can segment image content with minimal prompting intervention. This invention uses the detection results of the cigarette box defect detection model and the results of manual review as a Prompt (a specific term for large language models) to transmit to SAM, allowing SAM to segment and label defective images that were missed by the cigarette box defect detection model.

[0090] In this invention, the trained cigarette box sheet defect detection model undergoes performance testing and classification performance testing to obtain the defect detection accuracy and defect classification accuracy of the cigarette box sheet defect detection model. Specifically, the classification performance test of the cigarette box sheet defect detection model includes:

[0091] The classification performance of the cigarette box defect detection model was tested, and the defect classification accuracy for defect type classification was obtained:

[0092] If the defect classification accuracy of the cigarette box defect detection model is not greater than the second preset value, then the semi-automatic annotation tool built based on SAM and the cigarette box defect detection model will annotate the cigarette box images with incorrect defect type classification, and actively verify the annotation results. The verified cigarette box images will be incorporated into the dataset, and the dataset will be used to continue training the cigarette box defect detection model. The second preset value can be 85%.

[0093] If the defect classification accuracy of the cigarette box defect detection model is greater than the second preset value, then the detected cigarette box images with defects will be incorporated into the dataset.

[0094] When the defect detection accuracy and defect classification accuracy of the cigarette box sheet defect detection model both meet the requirements, it indicates that the cigarette box sheet defect detection model can accurately identify and classify defects. In this case, the cigarette box sheet images with defects detected by the cigarette box sheet defect detection model can be incorporated into the dataset.

[0095] The detected images of cigarette boxes with defects are incorporated into the dataset. Specifically, bounding boxes are drawn on the images of cigarette boxes with defects, and a txt (text format) file is generated and incorporated into the dataset to expand the training dataset and increase the diversity of the training data.

[0096] It should be noted that for performance testing and classification performance testing of the cigarette box defect detection model, the model can be deployed to the production line. During an initial period, the model's detection results can be used to determine the defect detection accuracy and classification accuracy. Furthermore, once the detection and classification accuracy meet the requirements, the detected defect images can be incorporated into the dataset, enabling on-the-fly training of the model and further improving its accuracy during operation.

[0097] Alternatively, additional images of cigarette box pieces can be collected to perform performance and classification tests on the cigarette box piece defect detection model. Based on the test results, the cigarette box piece defect detection model can be continuously trained. When the defect detection accuracy and defect classification accuracy of the cigarette box piece defect detection model meet the requirements, the detected defect images can be incorporated into the dataset, and then the cigarette box piece defect detection model can be trained again to further improve the detection accuracy of the cigarette box piece defect detection model.

[0098] The cigarette box piece defect detection method of this invention improves the YOLOv5s network model to obtain a cigarette box piece defect detection model. While achieving model lightweighting, it can effectively improve the recognition accuracy of small targets. At the same time, when the defect detection accuracy and defect classification accuracy are both greater than preset values, the cigarette box piece images with defects detected by the cigarette box piece defect detection model are added to the dataset, realizing automatic expansion of the dataset, reducing training costs and further improving model accuracy.

[0099] In one possible implementation, the present invention also provides a non-transitory computer-readable storage medium located in a PLC (Programmable Logic Controller) controller. The storage medium stores a computer program that, when executed by a processor, implements the steps of the following method for detecting defects in cigarette box panels:

[0100] Obtain images of cigarette boxes and label them with defects using an active annotation method to form a dataset;

[0101] Based on the improvement of the YOLOv5s network model, a defect detection model for cigarette box sheets was built, and the model was trained using a dataset.

[0102] The trained cigarette box sheet defect detection model was subjected to performance and classification performance tests to obtain the defect detection accuracy and defect classification accuracy of the cigarette box sheet defect detection model.

[0103] Based on the test results, when both the defect detection accuracy and the defect classification accuracy are greater than the preset values, the cigarette box images with defects detected by the cigarette box defect detection model are incorporated into the dataset.

[0104] Storage media may be any combination of one or more computer-readable media. A computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. Computer-readable storage media may be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this document, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0105] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of transmitting, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to: wireless, wireline, optical fiber, RF, etc., or any suitable combination thereof.

[0106] Computer program code for performing the operations of this invention can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages—such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0107] The present invention provides a defect detection device for cigarette box sheets, comprising a labeling module, a training module, a testing module, and an execution module.

[0108] The annotation module acquires images of cigarette box pieces and annotates them with defects using an active annotation method, forming a dataset. The training module builds a cigarette box piece defect detection model based on an improvement of the YOLOv5s network model and trains it using the dataset. The testing module performs performance and classification performance tests on the trained cigarette box piece defect detection model to obtain its defect detection accuracy and defect classification accuracy. The execution module, based on the test results, adds defective cigarette box piece images detected by the model to the dataset when both the defect detection accuracy and defect classification accuracy exceed preset values.

[0109] The above description is merely a specific embodiment of this application, enabling those skilled in the art to understand or implement this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.

[0110] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

Claims

1. A method for detecting defects in cigarette box panels, characterized in that, Specifically, the following steps are included: Obtain images of cigarette boxes and label them with defects using an active annotation method to form a dataset; Based on the improvement of the YOLOv5s network model, a defect detection model for cigarette box sheets was built, and the model was trained using a dataset. The trained cigarette box sheet defect detection model was subjected to performance and classification performance tests to obtain the defect detection accuracy and defect classification accuracy of the cigarette box sheet defect detection model. Based on the test results, when both the defect detection accuracy and the defect classification accuracy are greater than the preset values, the cigarette box images with defects detected by the cigarette box defect detection model will be incorporated into the dataset. The cigarette box defect detection model includes a backbone feature extraction network, an enhanced feature extraction network, and a detection head. Based on the improvement of the YOLOv5s network model, a defect detection model for cigarette box sheets was built, specifically: The number of channels in the YOLOv5s network model is halved. A residual structure is added to the backbone feature extraction network of the YOLOv5s network model. A structure for stabilizing accuracy is added to the enhanced feature extraction network and the detection head. The ordinary convolutional layer in the enhanced feature extraction network and the convolutional layer in the residual structure are replaced with full-dimensional dynamic convolutions to obtain the cigarette box sheet defect detection model. The residual structure is located between the output of the 3*C3 module and the input of the Conv module in the backbone feature extraction network part of the YOLOv5s network model. The structures used to stabilize accuracy include the ODConv module and the ODC3 module.

2. The method for detecting defects in cigarette box panels as described in claim 1, characterized in that, The steps involved in acquiring cigarette box images and annotating them with defects using an active annotation method to form a dataset include: Images of cigarette boxes were obtained by taking pictures with a camera, and images of cigarette boxes with defects were actively screened to identify those with defects, and the types of defects were varied. The selected cigarette box images were labeled using an active annotation method to form a dataset.

3. The method for detecting defects in cigarette box panels as described in claim 1, characterized in that: The ordinary convolutional layer contains only a single static convolutional kernel, applied to all input samples. The expression for the ordinary convolutional layer is: in, This represents the output feature map. Indicates the input feature map, Represents the convolution kernel. Indicates the convolution operation; The dynamic convolutional layer in the enhanced feature extraction network uses A linear combination of convolutional kernels, dynamically weighted through an attention mechanism, is expressed as: in, Represents the convolution kernel Attention weighting factor; The expression for the full-dimensional dynamic convolution is: in, Represents the convolution kernel Attention factor in the output channel dimension, Represents the convolution kernel Attention factor in the input channel dimension, Represents the convolution kernel Attention factor in the spatial dimension, This represents the dot product operation along different dimensions of the kernel space.

4. The method for detecting defects in cigarette box panels as described in claim 1, characterized in that: The specific steps for training the cigarette box defect detection model using the dataset include: dividing the dataset into a training set and a validation set according to a set ratio, preprocessing the cigarette box images in the training set and validation set, and using the preprocessed training set and validation set to train the cigarette box defect detection model. The preprocessing operation is as follows: crop the image by cropping a preset percentage of the top, bottom, left, and right sides of the image; divide the remaining image into three equal parts along the width direction; resize the divided image into a square image; and normalize each pixel of the square image.

5. The method for detecting defects in cigarette box panels as described in claim 1, characterized in that, The trained cigarette box sheet defect detection model undergoes performance and classification performance testing to obtain its defect detection accuracy and defect classification accuracy. Specifically, the performance testing of the cigarette box sheet defect detection model includes: The performance of the cigarette box sheet defect detection model was tested, and the defect detection accuracy of the cigarette box sheet defect detection model was obtained: If the defect detection accuracy of the cigarette box piece defect detection model is not greater than the first preset value, then the semi-automatic annotation tool built based on SAM and the cigarette box piece defect detection model will annotate the cigarette box piece images with defects that were missed, and actively review the annotation results. The reviewed cigarette box piece images with defects will be incorporated into the dataset, and the dataset will continue to be used to train the cigarette box piece defect detection model. If the defect detection accuracy of the cigarette box sheet defect detection model is greater than the first preset value, then a classification performance test will be performed on the cigarette box sheet defect detection model.

6. The method for detecting defects in cigarette box panels as described in claim 5, characterized in that, The trained cigarette box defect detection model undergoes performance testing and classification performance testing to obtain its defect detection accuracy and defect classification accuracy. Specifically, the classification performance testing of the cigarette box defect detection model involves: The classification performance of the cigarette box defect detection model was tested, and the defect classification accuracy for defect type classification was obtained: If the defect classification accuracy of the cigarette box defect detection model is not greater than the second preset value, then the semi-automatic annotation tool built based on SAM and the cigarette box defect detection model will annotate the cigarette box images with incorrect defect type classification, and actively verify the annotation results. The verified cigarette box images will be incorporated into the dataset, and the dataset will continue to be used to train the cigarette box defect detection model. If the defect classification accuracy of the cigarette box defect detection model is greater than the second preset value, then the detected cigarette box images with defects will be incorporated into the dataset.

7. The method for detecting defects in cigarette box panels as described in claim 6, characterized in that, The process of incorporating the detected defective cigarette box images into the dataset specifically involves: The defective cigarette box images were annotated with bounding boxes and a txt file was generated and incorporated into the dataset.

8. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the steps of a method for detecting defects in cigarette box sheets as described in any one of claims 1 to 7.

9. A device for detecting defects in cigarette box panels, characterized in that, include: The annotation module is used to acquire cigarette box images and perform defect annotation on the cigarette box images based on an active annotation method to form a dataset; The training module is used to build a cigarette box defect detection model based on the improvement of the YOLOv5s network model, and to train the cigarette box defect detection model using the dataset. The testing module is used to perform performance testing and classification performance testing on the trained cigarette box sheet defect detection model, and to obtain the defect detection accuracy and defect classification accuracy of the cigarette box sheet defect detection model. The execution module is used to incorporate the defective cigarette box images detected by the cigarette box defect detection model into the dataset when both the defect detection accuracy and defect classification accuracy are greater than preset values, based on the test results. The cigarette box defect detection model includes a backbone feature extraction network, an enhanced feature extraction network, and a detection head. Based on the improvement of the YOLOv5s network model, a defect detection model for cigarette box sheets was built, specifically: The number of channels in the YOLOv5s network model is halved. A residual structure is added to the backbone feature extraction network of the YOLOv5s network model. A structure for stabilizing accuracy is added to the enhanced feature extraction network and the detection head. The ordinary convolutional layer in the enhanced feature extraction network and the convolutional layer in the residual structure are replaced with full-dimensional dynamic convolutions to obtain the cigarette box sheet defect detection model. The residual structure is located between the output of the 3*C3 module and the input of the Conv module in the backbone feature extraction network part of the YOLOv5s network model. The structures used to stabilize accuracy include the ODConv module and the ODC3 module.

Citation Information

Patent Citations

  • Cigarette appearance defect detection method and system

    CN114170161A

  • Data annotation method and device, equipment and storage medium

    CN114418553A