Cigarette loose end detection method and system

The BEGAN-YOLO-DSPP method generates sample data and optimizes the YOLOv4 network to enhance detection accuracy for empty cigarettes, addressing data insufficiency and improving tobacco product quality.

CN119228780AInactive Publication Date: 2024-12-31HEBEI BAISHA TOBACCO

Patent Information

Application Number
CN202411530389.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-30
Publication Date
2024-12-31
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The lack of image data for empty cigarettes and insufficient sample data leads to unsatisfactory training results, affecting the detection accuracy of empty cigarettes in existing detection methods.

Method used

A method utilizing the BEGAN-YOLO-DSPP approach, which includes generating sample data with the BEGAN algorithm, training a YOLOv4 network model with DSPP, and optimizing using the CIoU loss function to enhance feature extraction and detection accuracy.

Benefits of technology

The method effectively addresses the issue of insufficient data by expanding the sample set and improving detection accuracy and speed for empty cigarettes, enhancing the quality and brand effect of tobacco products.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119228780A_ABST
    Figure CN119228780A_ABST
Patent Text Reader

Abstract

The invention discloses a cigarette loose end detection method and system. The method comprises the following steps: acquiring original data of a cigarette, generating sample data based on a BEGAN algorithm, dividing a training set and a test set based on the original data and the sample data, and performing data enhancement on the training set and the test set. Constructing a DSPP-based YOLOv4 network model, and training a backbone network through the training set; image features are extracted and recognized, and a training loss function is obtained; optimizing the model weight based on an SGD optimizer, carrying out multiple iterations on the training process, and selecting an optimal model; and inputting the test set into the optimal model to obtain a prediction result. A BEGAN algorithm is adopted to generate a high-quality image, sample data is expanded, a deep learning target detection algorithm YOLOV4 based on a regression method is adopted to detect a cigarette loose end phenomenon, accuracy and rapidity are met, a deep separable pyramid pooling DSPP algorithm is adopted to replace, multi-scale context features are aggregated, the detection capability of different targets is improved, and the detection efficiency is improved. And the accuracy of short cigarette detection is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of tobacco detection, and more particularly to a method and system for detecting empty cigarettes. Background Art

[0002] With the development and progress of society, manufacturers and merchants have gradually increased their requirements for the quality and efficiency of cigarette production. The quality, popularity and attractiveness of products are the core competitiveness of tobacco brands. The phenomenon of empty cigarettes will seriously affect product quality and even affect people's trust in cigarette brands and manufacturers. Therefore, the detection of empty cigarettes can help improve cigarette quality and enhance brand effect. At present, the production speed of conventional cigarette machines is about 7000-16000 cigarettes / minute, and the probability of cigarette defects is 3%. The fastest cigarette machine can reach 20,000 cigarettes / minute, and the production speed is very fast. It is impossible to rely solely on manual detection of missing cigarettes. For the detection of cigarette defects, traditional methods mainly include infrared photoelectric automatic detection and traditional mechanical contact detection methods. With the development and promotion of technologies such as artificial intelligence, deep learning, and machine learning, the detection technology of missing cigarettes has gradually shifted to intelligence. Using deep learning methods to detect cigarette defects has become a hot topic in current research. Defect detection belongs to the category of target detection, which mainly includes the following categories:

[0003] 1) Two-stage method, represented by the R-CNN series of algorithms, first generates candidate detection boxes, and then calibrates the candidate detection boxes with the help of a neural network algorithm to obtain the final predicted boundary.

[0004] 2) Single-stage method, represented by SSD, YOLO series and other algorithms, directly uses convolutional neural network for prediction without generating candidate regions.

[0005] The publication number is CN112432952A, and its name is A method for detecting empty cigarettes based on machine vision technology. It belongs to the field of empty cigarette detection and includes the following steps: using a linear laser source to irradiate the tobacco end face of the cigarette to be detected; using two symmetrically distributed high-speed area array image sensors to alternately capture equally spaced images of the horizontally moving cigarettes and transmit them to a computer; the computer uses image processing technology to calculate the total number of pixels whose sinking depth exceeds a set threshold, and finally determines whether the cigarette to be detected is an empty cigarette.

[0006] The publication number is CN117233165A, and the name is a visual hollow detection method based on stripe structured light, which belongs to the field of detection technology. The present invention uses special structured light to assist in illuminating the end of the tobacco shreds of a cigarette, and uses an industrial camera with a certain tilt angle to collect images. Finally, through methods such as horizontal line detection, connected domain area feature filtering, and regional position filtering, the degree of light breakage is calculated to indirectly characterize the size of the tobacco shred depression, thereby achieving accurate visual hollow detection.

[0007] However, there is a lack of image data of empty cigarettes, and the use of target defect detection methods for training has problems such as insufficient sample data and unsatisfactory training results, which may affect the detection accuracy of empty cigarettes.

[0008] Therefore, how to provide a method based on BEGAN-YOLO-DSPP to detect the hollowing phenomenon caused by the end of a cigarette not being filled with tobacco is an urgent problem to be solved by those skilled in the art. Summary of the invention

[0009] In view of this, the present invention provides a method and system for detecting empty cigarettes, aiming to solve the technical problems of lack of image data of empty cigarettes, insufficient sample data and unsatisfactory training effect when using target defect detection method for training, which affect the detection accuracy of empty cigarettes.

[0010] In order to achieve the above object, the present invention adopts the following technical solution:

[0011] A method for detecting empty cigarettes, comprising the following steps:

[0012] S1. Obtain the original data of cigarettes, generate sample data based on the BEGAN algorithm, divide the training set and test set based on the original data and sample data, and perform data enhancement on the training set and test set;

[0013] S2. Build a YOLOv4 network model based on DSPP, train the backbone network through the training set; extract and identify image features, and obtain the training loss function; optimize the model weights based on the SGD optimizer, iterate the above training process multiple times, and select the best YOLOv4-DSPP model;

[0014] S3. Input the test set into the best YOLOv4-DSPP model to obtain the prediction results.

[0015] Furthermore, the sample data generated based on the BEGAN algorithm in S1 is specifically:

[0016] Determine whether the original data is a one-dimensional image or a two-dimensional image. If it is a one-dimensional image, the one-dimensional Gaussian noise input is mapped to a two-dimensional image through the generator. If it is a two-dimensional image, the two-dimensional image is encoded and mapped to a low-dimensional space, and then the image in the low-dimensional space is mapped to a two-dimensional image through the generator.

[0017] Furthermore, the BEGAN algorithm uses Wasserstein distance as the loss function:

[0018] L(x;θ)=E[||xG(z;θ)||1]

[0019] Where x is the real image, G(z;θ) is the image generated by the generator, z is random Gaussian noise, and θ is the generator parameter.

[0020] Furthermore, the BEGAN algorithm introduces the balance factor k t Control the discriminator's attention to the generated image and the real image, and the update formula is:

[0021] k t+1 =k t +λ(γL(x)-L(G(z)))

[0022] Where λ is the learning rate, γ is the target allocation ratio, L(x) is the loss value of the real image x, and L(G(z)) is the loss value of the generated image G(z).

[0023] Furthermore, the step S2 is specifically as follows:

[0024] YOLOv4 uses CSPDarknet53 as the backbone network, and fuses features of different scales through FPN to improve the detection ability of small targets. It introduces the path aggregation network PANet into FPN to further enhance the fusion and transmission of features. The SPP module extracts multi-scale features by pooling pooling windows of different sizes, enhances the receptive field of the model, and applies SPP modules at multiple levels of the network to capture features of different scales.

[0025] Furthermore, Yolov4 uses Mish as the activation function.

[0026] Furthermore, the loss function of the YOLOv4 is:

[0027] Given a random value vector, that is, potential input, any vector that satisfies a certain feature distribution, that is, Noise in the GAN structure diagram, the generator generates data with the same data features as the training set, and constructs the loss function L CIoU :

[0028]

[0029] Among them, B gt represents the real box, that is, the target box, B represents the predicted box, b is the center point of the predicted box, and b gt is the center point of the true box, ρ is the Euclidean distance between the two center points, c is the diagonal distance of the minimum closure area that contains both the predicted box and the true box, β is the weight function, v is the similarity measure of the aspect ratio, and IoU is the intersection-over-union ratio metric.

[0030] Furthermore, the weight function β is:

[0031]

[0032] The similarity measure v of aspect ratio is:

[0033]

[0034] In the formula, ω gt is the width of the real box, h gt is the height of the real box, ω is the width of the predicted box, and h is the height of the predicted box.

[0035] Furthermore, the implementation process of the DSPP algorithm is:

[0036] The image is input into the network, and the features of the image are extracted through multiple convolutional layers. The SPP module is applied at different levels, and each SPP module is pooled on pooling windows of different sizes. The features output by different SPP modules are spliced ​​together to form a multi-scale feature representation. The spliced ​​features are further processed through the fully connected layer or convolutional layer to generate the final output.

[0037] A cigarette empty detection system, comprising:

[0038] A sample data generation module is used to generate empty cigarette sample data; a data set construction module is used to merge the generated sample data with real images to form training sets and test sets; a detection model training module is used to train the YOLOv4 algorithm to detect empty cigarettes; and a feature extraction enhancement module is used to apply the DSPP algorithm in the YOLOv4 algorithm to improve the detection accuracy;

[0039] The sample data generation module uses the BEGAN algorithm, and the algorithm uses the Wasserstein distance as the loss function to achieve a dynamic balance between the generator and the discriminator;

[0040] The detection model training module uses the YOLOv4 algorithm, and the algorithm uses CSPDarknet53 as the backbone network, Mish activation function and CIoU loss function for training;

[0041] The feature extraction enhancement module uses the DSPP algorithm, and the algorithm applies SPP modules at multiple levels of the network to capture features of different scales and form a multi-scale feature representation by splicing these features.

[0042] The above technical solution includes at least the following technical effects:

[0043] It can be seen from the above technical solutions that the present invention discloses a method and system for detecting empty cigarettes. Compared with the prior art, the present invention can address the problem of less cigarette sample data, use the BEGAN algorithm to generate high-quality images, expand sample data, and improve the generalization ability of the model. Secondly, the deep learning target detection algorithm YOLOV4 based on the regression method is selected to detect the empty cigarette phenomenon, which meets the requirements of accuracy and speed. Finally, the deep separable pyramid pooling DSPP algorithm is selected to replace it, aggregate multi-scale context features, improve the detection ability of different targets, and improve the accuracy of short cigarette detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0045] Figure 1 The present invention is a flowchart of a method for detecting empty cigarettes.

[0046] Figure 2 This is a schematic diagram of the network structure of a BEGAN of the present invention.

[0047] Figure 3 This is a schematic diagram of the structure of YOLOv4 after the DSPP algorithm is replaced in the present invention. DETAILED DESCRIPTION

[0048] The technical solutions in the embodiments of the present invention are described clearly and completely below. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0049] See attached Figure 1 The embodiment of the present invention discloses a method for detecting empty cigarettes, including the following method:

[0050] S1. Obtain the original data of cigarettes, generate sample data based on the BEGAN algorithm, divide the training set and test set based on the original data and sample data, and perform data enhancement on the training set and test set;

[0051] S2. Build a YOLOv4 network model based on DSPP, train the backbone network through the training set; extract and identify image features, and obtain the training loss function; optimize the model weights based on the SGD optimizer, iterate the above training process multiple times, and select the best YOLOv4-DSPP model;

[0052] S3. Input the test set into the best YOLOv4-DSPP model to obtain the prediction results.

[0053] In order to further optimize the above technical solution, the sample data generated based on the BEGAN algorithm in S1 is specifically as follows:

[0054] Determine whether the original data is a one-dimensional image or a two-dimensional image. If it is a one-dimensional image, the one-dimensional Gaussian noise input is mapped to a two-dimensional image through the generator. If it is a two-dimensional image, the two-dimensional image is encoded and mapped to a low-dimensional space, and then the image in the low-dimensional space is mapped to a two-dimensional image through the generator.

[0055] To further optimize the above technical solution, the BEGAN algorithm uses Wasserstein distance as the loss function:

[0056] L(x;θ)=E[||xG(z;θ)||1]

[0057] Where x is the real image, G(z;θ) is the image generated by the generator, z is random Gaussian noise, and θ is the generator parameter.

[0058] To further optimize the above technical solution, the BEGAN algorithm introduces the balance factor k t Control the discriminator's attention to the generated image and the real image, and the update formula is:

[0059] k t+1 =k t +λ(γL(x)-L(G(z)))

[0060] Where λ is the learning rate, γ is the target allocation ratio, L(x) is the loss value of the real image x, and L(G(z)) is the loss value of the generated image G(z).

[0061] To further optimize the above technical solution, step S2 is specifically as follows:

[0062] YOLOv4 uses CSPDarknet53 as the backbone network, and fuses features of different scales through FPN to improve the detection ability of small targets. It introduces the path aggregation network PANet into FPN to further enhance the fusion and transmission of features. The SPP module extracts multi-scale features by pooling pooling windows of different sizes, enhances the receptive field of the model, and applies SPP modules at multiple levels of the network to capture features of different scales.

[0063] To further optimize the above technical solution, Yolov4 uses Mish as the activation function.

[0064] To further optimize the above technical solution, the loss function of YOLOv4 is:

[0065] Given a random value vector, that is, potential input, any vector that satisfies a certain feature distribution, that is, Noise in the GAN structure diagram, the generator generates data with the same data features as the training set, and constructs the loss function L CIoU :

[0066]

[0067] Among them, B gt represents the real box, that is, the target box, B represents the predicted box, b is the center point of the predicted box, and b gt is the center point of the real box, ρ is the Euclidean distance between the two center points, c is the diagonal distance of the minimum closure area that contains both the predicted box and the real box, β is the weight function, v is the similarity measure of the aspect ratio, and IoU is the intersection over union ratio metric.

[0068] IoU: Intersection over Union, is the ratio of the intersection and union of the prediction box and the target box. It is an important indicator to measure the degree of overlap between the prediction box and the target box. The value range is between 0 and 1. The larger the IoU value, the closer the prediction box is to the target box.

[0069] CIoU: Based on IoU, we further consider factors such as the center distance and aspect ratio between the prediction box and the target box. With the aspect ratio term βv, CIoU can more comprehensively evaluate the matching degree between the predicted box and the target box. This allows the model to learn more accurate box positioning when using CIoU as the loss function when training the target detection model, especially when dealing with target detection tasks in some complex scenarios, and more accurate results can be obtained.

[0070]

[0071] L CIoU It is a loss function that selects the CIoU intersection-over-union form.

[0072] To further optimize the above technical solution, the weight function β is:

[0073]

[0074] The similarity measure v of aspect ratio is:

[0075]

[0076] In the formula, ω gt is the width of the real box, h gt is the height of the real box, ω is the width of the predicted box, and h is the height of the predicted box.

[0077] To further optimize the above technical solution, the implementation process of the DSPP algorithm is as follows:

[0078] The image is input into the network, and the features of the image are extracted through multiple convolutional layers. The SPP module is applied at different levels, and each SPP module is pooled on pooling windows of different sizes. The features output by different SPP modules are spliced ​​together to form a multi-scale feature representation. The spliced ​​features are further processed through the fully connected layer or convolutional layer to generate the final output.

[0079] A cigarette empty detection system, comprising:

[0080] A sample data generation module is used to generate empty cigarette sample data; a data set construction module is used to merge the generated sample data with real images to form training sets and test sets; a detection model training module is used to train the YOLOv4 algorithm to detect empty cigarettes; and a feature extraction enhancement module is used to apply the DSPP algorithm in the YOLOv4 algorithm to improve the detection accuracy;

[0081] The sample data generation module uses the BEGAN algorithm, and the algorithm uses the Wasserstein distance as the loss function to achieve a dynamic balance between the generator and the discriminator;

[0082] The detection model training module uses the YOLOv4 algorithm, and the algorithm uses CSPDarknet53 as the backbone network, Mish activation function and CIoU loss function for training;

[0083] The feature extraction enhancement module uses the DSPP algorithm, and the algorithm applies SPP modules at multiple levels of the network to capture features of different scales and form a multi-scale feature representation by splicing these features.

[0084] The hollowing phenomenon caused by the lack of tobacco at the end of the cigarette is called a hollow head defect. To detect whether a cigarette has a hollow head, it is necessary to determine the depth and cross-sectional ratio of the hollow. The basis for determining the short cigarette phenomenon is shown in Table 1.

[0085] Table 1 Standards for empty cigarettes

[0086]

[0087]

[0088] In order to solve the problem of small number of samples of empty cigarette defective images, the BEGAN algorithm was selected to expand the sample data. The BEGAN algorithm can generate high-quality images. By inputting one-dimensional random Gaussian noise and using the generator, the purpose of generating two-dimensional images can be achieved. The BEGAN algorithm uses Wasserstein distance as an indicator to measure loss, which solves the problem of gradient disappearance and weight failure during training caused by cross entropy loss in the GAN algorithm. Compared with GAN, BEGAN has higher stability and faster convergence speed during network training. Therefore, the BEGAN algorithm was selected to generate data for empty cigarettes. The network structure of BEGAN is as follows Figure 2 As shown;

[0089] The generator in BEGAN can map one-dimensional Gaussian noise input to a two-dimensional image, and its network structure is a decoder structure. For situations where the network input is two-dimensional, relying solely on the decoder structure in BEGAN cannot help the generator complete the mapping task from a two-dimensional image to a two-dimensional repaired image. First, encode the two-dimensional image and map the two-dimensional image to a low-dimensional space. Then, with the help of the decoder, the features of the low-dimensional space are mapped to a two-dimensional image to achieve the generation of a hollow cigarette image.

[0090] The generative network can realize the generation of images, while the discriminative network determines whether the input sample is a real sample or generated data. In the GAN algorithm, the discriminative network is a decoder structure, whose output is fused through the connection layer, and can predict the probability that the corresponding image is a real image. However, it is easy to have the discriminative ability enhanced and the generator gradient disappear. Therefore, the BEGAN algorithm modifies the discriminative network and uses an autoencoder structure. The decoder and encoder are used to avoid the gradient disappearance phenomenon and accelerate the convergence speed.

[0091] Wasserstein distance

[0092] BEGAN uses Wasserstein distance as the loss function, the formula is as follows:

[0093] L(x;θ)=E[||xG(z;θ)||1]

[0094] Where x is the real image, G(z;θ) is the image generated by the generator, z is random Gaussian noise, and θ is the generator parameter.

[0095] Boundary balance mechanism

[0096] BEGAN introduces the balance factor k t To control the attention of the discriminator to the generated images and real images. t The update formula is as follows:

[0097] k t+1 =k t +λ(γL(x)-L(G(z)))

[0098] Where λ is the learning rate, γ is the target allocation ratio, L(x) is the loss value of the real image x, and L(G(z)) is the loss value of the generated image G(z).

[0099] The YOLOv4 network structure mainly consists of the following parts. The input layer accepts image data, usually with a resolution of 416x416 or 608x608. YOLOv4 uses CSPDarknet53 as the backbone network, which is an improved version based on Darknet and has better feature extraction capabilities. CSPDarknet53 reduces the amount of calculation by connecting parts across levels while maintaining high accuracy. FPN is used to fuse features of different scales to improve the detection ability of small targets. YOLOv4 introduces PANet (path aggregation network) into FPN to further enhance the fusion and transmission of features. The SPP module extracts multi-scale features by pooling pooling windows of different sizes and enhances the receptive field of the model. The detection head is responsible for generating the final detection results, including the category, location and confidence of the target. The detection head of YOLOv4 contains 3 detection layers of different scales, corresponding to targets of different sizes. The output layer generates the final detection box and category probability.

[0100] Yolov4 uses a new Mish activation function. The Mish activation function is a self-regularized non-monotonic neural activation function. The smooth activation function allows better information to penetrate into the neural network, thereby achieving better accuracy and generalization.

[0101] Given a random value (potential input) vector, usually an arbitrary vector that satisfies a certain feature distribution, namely the Noise in the GAN structure diagram. The generator can generate data with the same data features as the training samples (Generated Images). Zheng Z et al. proposed a loss function - CIoU (Complete Overlap Union) positioning loss function and DIoU (Distance Intersection over Union) positioning loss function. The CIoU loss function is applied to the selection of the YOLOv4 network, which is based on the loss function IoU.

[0102] IoU is the intersection over union (IoU) of the predicted frame and the real frame. The formula is as follows:

[0103]

[0104] In the formula, B gt Represents the real box, and B represents the predicted box. Io U calculation area B gt The intersection-over-union ratio of IoU and B is an important indicator for measuring the detection effect of the detection box. However, IoU also has many shortcomings. Later, a variety of loss functions were derived based on Io U. For example, GIoU adds a closed area as a penalty term on the basis of IoU, while DIoU considers the Euclidean distance between the center points of the prediction box and the regression box on the basis of GIoU. The loss function CIoU used in the YOLOv4 algorithm considers the aspect ratio on the basis of DIoU. The calculation formula is as follows:

[0105]

[0106] In the formula, B gt represents the real box, that is, the target box, B represents the predicted box, b is the center point of the predicted box, and b gt is the center point of the true box, ρ is the Euclidean distance between the two center points, c is the diagonal distance of the minimum closure area that contains both the predicted box and the true box, β is the weight function, v is the similarity measure of the aspect ratio, and IoU is the intersection-over-union ratio metric.

[0107] The calculation formulas for β and v are as follows:

[0108]

[0109] In the formula, ω gt is the width of the real box, h gt is the height of the real box, ω is the width of the predicted box, and h is the height of the predicted box.

[0110] The principle of DSPP is to apply SPP at multiple levels of the network to capture features of different scales. Specifically, DSPP sets SPP modules at multiple levels of the network. Each SPP module performs pooling on pooling windows of different sizes, and then splices these pooled features together to form a multi-scale feature representation. This multi-scale feature representation can better capture the details and global information in the image and improve the performance of the model.

[0111] The DSPP algorithm can capture richer spatial information and improve the expressiveness of features. It can better fuse features of different scales and improve the performance of the model. Multi-scale feature representation can better cope with scale changes and deformations in images and improve the robustness of the model. By applying SPP at multiple levels, the accuracy of the model can be improved, especially when dealing with complex scenes and small objects.

[0112] The implementation process of the DSPP algorithm is as follows.

[0113] Step 1: Input Image: Input the image into the network.

[0114] Step 2: Feature extraction: Extract image features through multiple convolutional layers.

[0115] Step 3: Spp application: SPP modules are applied at different levels, and each SPP module is pooled on pooling windows of different sizes.

[0116] Step 4: Feature splicing: The features output by different SPP modules are spliced ​​together to form a multi-scale feature representation.

[0117] Step 5: Subsequent processing: The concatenated features are further processed through a fully connected layer or a convolutional layer to generate the final output.

[0118] A method for detecting empty cigarettes designed according to the present invention generates sample data through the BEGAN algorithm, which effectively solves the problem of insufficient empty cigarette image data, expands the data set, and improves the generalization ability of the model. Secondly, the YOLOv4 algorithm is used for target detection to ensure the accuracy and speed of detection. In addition, the SPP algorithm is replaced by the DSPP algorithm, and the detection ability of the model for different targets is further improved by aggregating multi-scale context features, especially the detection performance for small targets and complex scenes. This method not only improves the accuracy of empty cigarette detection, but also helps to improve the overall quality of cigarettes and enhance the brand effect, and has important practical application value for the tobacco industry.

[0119] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0120] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for detecting empty cigarettes, characterized in that: The following methods are included: S1. Obtain the original data of cigarettes, generate sample data based on the BEGAN algorithm, divide the training set and test set based on the original data and sample data, and perform data enhancement on the training set and test set; S2. Build a YOLOv4 network model based on DSPP, train the backbone network through the training set; extract and identify image features, and obtain the training loss function; optimize the model weights based on the SGD optimizer, iterate the above training process multiple times, and select the best YOLOv4-DSPP model; S3. Input the test set into the best YOLOv4-DSPP model to obtain the prediction results.

2. A method for detecting empty cigarettes according to claim 1, characterized in that: The sample data generated based on the BEGAN algorithm in S1 is specifically: Determine whether the original data is a one-dimensional image or a two-dimensional image. If it is a one-dimensional image, the one-dimensional Gaussian noise input is mapped to a two-dimensional image through the generator. If it is a two-dimensional image, the two-dimensional image is encoded and mapped to a low-dimensional space, and then the image in the low-dimensional space is mapped to a two-dimensional image through the generator.

3. A method for detecting empty cigarettes according to claim 2, characterized in that: The BEGAN algorithm is based on the Wasserstein distance as the loss function: L(x;θ)=E[||xG(z;θ)||1] Where x is the real image, G(z;θ) is the image generated by the generator, z is random Gaussian noise, and θ is the generator parameter.

4. A method for detecting empty cigarettes according to claim 3, characterized in that: BEGAN algorithm introduces balance factor k t Control the discriminator's attention to the generated image and the real image, and the update formula is: k t+1 =k t +λ(γL(x)-L(G(z))) Where λ is the learning rate, γ is the target allocation ratio, L(x) is the loss value of the real image x, and L(G(z)) is the loss value of the generated image G(z).

5. The method for detecting empty cigarettes according to claim 1, characterized in that: The step S2 is specifically as follows: YOLOv4 uses CSPDarknet53 as the backbone network, and fuses features of different scales through FPN to improve the detection ability of small targets. It introduces the path aggregation network PANet into FPN to further enhance the fusion and transmission of features. The SPP module extracts multi-scale features by pooling pooling windows of different sizes, enhances the receptive field of the model, and applies SPP modules at multiple levels of the network to capture features of different scales.

6. A method for detecting empty cigarettes according to claim 5, characterized in that: Yolov4 uses Mish as the activation function.

7. A method for detecting empty cigarettes according to claim 5, characterized in that: The loss function of the YOLOv4 is: Given a random value vector, that is, potential input, any vector that satisfies a certain feature distribution, that is, Noise in the GAN structure diagram, the generator generates data with the same data features as the training set, and constructs the loss function L CIoU : In the formula, B gt represents the real box, that is, the target box, B represents the predicted box, b is the center point of the predicted box, and b gt is the center point of the true box, ρ is the Euclidean distance between the two center points, c is the diagonal distance of the minimum closure area that contains both the predicted box and the true box, β is the weight function, v is the similarity measure of the aspect ratio, and IoU is the intersection-over-union ratio metric.

8. A method for detecting empty cigarettes according to claim 7, characterized in that: The weight function β is: The similarity measure v of aspect ratio is: In the formula, ω gt is the width of the real box, h gt is the height of the real box, ω is the width of the predicted box, and h is the height of the predicted box.

9. A method for detecting empty cigarettes according to claim 5, characterized in that: The implementation process of the DSPP algorithm is: The image is input into the network, and the features of the image are extracted through multiple convolutional layers. The SPP module is applied at different levels, and each SPP module is pooled on pooling windows of different sizes. The features output by different SPP modules are spliced ​​together to form a multi-scale feature representation. The spliced ​​features are further processed through the fully connected layer or convolutional layer to generate the final output.

10. A cigarette empty end detection system, used in any one of the cigarette empty end detection methods according to claims 1 to 9, characterized in that: include: A sample data generation module is used to generate empty cigarette sample data; a data set construction module is used to merge the generated sample data with real images to form training sets and test sets; a detection model training module is used to train the YOLOv4 algorithm to detect empty cigarettes; and a feature extraction enhancement module is used to apply the DSPP algorithm in the YOLOv4 algorithm to improve the detection accuracy; The sample data generation module uses the BEGAN algorithm, and the algorithm uses the Wasserstein distance as the loss function to achieve a dynamic balance between the generator and the discriminator; The detection model training module uses the YOLOv4 algorithm, and the algorithm uses CSPDarknet53 as the backbone network, Mish activation function and CIoU loss function for training; The feature extraction enhancement module uses the DSPP algorithm, and the algorithm applies SPP modules at multiple levels of the network to capture features of different scales and form a multi-scale feature representation by splicing these features.

Citation Information

Patent Citations

  • Electric power equipment infrared image real-time detection and identification method based on artificial intelligence

    CN112380952A

  • Unmanned aerial vehicle flame detection method and system based on YOLOv4 network

    CN113935364A

  • High-resolution remote sensing ship detection method based on improved YOLOv4

    CN115205264A

Cited By

  • Defect detection method and device

    CN120031884A