Tobacco shred defect detection method, device and equipment and storage medium

By improving the multi-branch large kernel fusion deep convolution module, the multi-scale hole attention mechanism, and the lightweight detection head, the problems of low accuracy and poor robustness in tobacco defect detection are solved, and high-precision and lightweight tobacco defect detection is achieved.

CN121982418APending Publication Date: 2026-05-05INST OF INTELLIGENT MFG GUANGDONG ACAD OF SCI
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
INST OF INTELLIGENT MFG GUANGDONG ACAD OF SCI
Filing Date
2026-02-05
Publication Date
2026-05-05

AI Technical Summary

Technical Problem

Existing methods for detecting defects in tobacco shreds suffer from low detection accuracy when faced with extremely small targets and complex backgrounds. It is difficult to balance lightweight design with accuracy, and the feature misalignment problem in localization and classification tasks has not been effectively solved.

Method used

By employing a multi-branch, large-kernel fusion deep convolutional module, a multi-scale dilated attention mechanism, and a lightweight detection head, the robustness and anti-interference ability of the detection model are improved through multi-scale feature extraction, feature fusion, and classification localization.

Benefits of technology

It significantly improves the accuracy and robustness of tobacco defect detection, meeting the high-precision and low-latency real-time detection requirements of industrial production.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121982418A_ABST
    Figure CN121982418A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a cut tobacco defect detection method, device and equipment and a storage medium, and relates to the technical field of computer vision, and the method comprises the following steps: obtaining a to-be-detected cut tobacco image, and inputting the to-be-detected cut tobacco image into a defect detection model which comprises a backbone network, a feature fusion network and a lightweight detection head; performing multi-scale feature extraction on the cut tobacco image to be detected by using a multi-branch large-kernel fusion deep convolution module of the backbone network to obtain initial image features, and performing feature fusion on the initial image features to obtain target features; performing parallel processing on the target features by using a multi-scale cavity attention mechanism of a feature fusion network to obtain fusion features; and classifying and positioning the fusion features by using a lightweight detection head to obtain a defect detection result of the to-be-detected tobacco shred image. According to the invention, the detection model can meet high precision and light weight at the same time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer vision technology, and more specifically, to a method, apparatus, device, and storage medium for detecting defects in tobacco shreds. Background Technology

[0002] In the tobacco industry, the quality of tobacco shreds is a decisive factor in the quality of cigarette products and production efficiency. On high-speed automated production lines, real-time and accurate online detection and removal of various defects mixed in with the tobacco shreds (such as stems, foreign objects, clumps, and abnormal color) is a crucial step in ensuring product quality. Traditional machine vision methods typically rely on preset color or shape thresholds, which are ill-suited to the complex and varied backgrounds of the tobacco shreds, subtle changes in lighting, and the diversity of defective targets. This results in high false positive and false negative rates, failing to meet the quality requirements of modern industrial production.

[0003] In recent years, with breakthroughs in deep learning technology in the field of computer vision, methods based on single-stage object detection networks (such as the YOLO series) have been introduced into industrial inspection. These methods, through end-to-end learning, can achieve accurate object recognition in complex backgrounds while maintaining high inference speed. However, directly applying the general YOLO model to the high-throughput, high-real-time-requirement field of tobacco defect detection still faces the following three major technical challenges: The problem of obfuscation between extremely small targets and complex backgrounds: In tobacco defects, such as tiny foreign objects and local clumps, they typically occupy only a very small pixel area in images captured by industrial cameras. Standard target detection networks tend to dilute or ignore the detailed features of small targets during deep feature extraction, making it difficult to improve detection accuracy and recall.

[0004] Balancing lightweight design and accuracy is challenging: Industrial deployments often require detection models with extremely low computational cost (FLOPs) and parameter count to achieve millisecond-level real-time inference speeds. Standard lightweight network structures, while compressing model size, inevitably sacrifice some feature extraction capabilities, resulting in detection accuracy that fails to meet industrial application standards.

[0005] Feature mismatch in localization and classification tasks: In defect detection, accurate bounding box localization and accurate defect category classification are two related yet competitive tasks. Standard networks, when sharing feature representations, often fail to specifically enhance features used for localization (boundaries) and classification (semantics), leading to inaccurate bounding boxes or incorrect category predictions at the output. Summary of the Invention

[0006] In view of this, the purpose of the present invention is to provide a method, apparatus, device and storage medium for detecting defects in tobacco shreds, so as to solve the problem of low detection accuracy of existing methods for detecting defects in tobacco shreds.

[0007] To achieve the above objectives, the technical solution adopted by the present invention is as follows: In a first aspect, the present invention provides a method for detecting defects in tobacco shreds, comprising: An image of the tobacco shreds to be tested is acquired, and the image is input into a defect detection model, which includes a backbone network, a feature fusion network, and a lightweight detection head. The multi-branch large kernel fusion deep convolution module of the backbone network is used to extract multi-scale features from the tobacco image to be tested to obtain initial image features, and the initial image features are fused to obtain target features; The target features are processed in parallel using the multi-scale dilated attention mechanism of the feature fusion network to obtain fused features. The lightweight detection head is used to classify and locate the fused features to obtain the defect detection results of the tobacco image to be tested.

[0008] In an optional implementation, the initial image features include initial features and contextual features. The step of using the multi-branch large kernel fusion deep convolution module of the backbone network to extract multi-scale features from the tobacco image to be tested to obtain initial image features, and then fusing the initial image features to obtain target features, includes: The initial features are obtained by extracting features from the tobacco image under test through the depth-separable convolutional layer of the multi-branch large kernel fusion deep convolutional module, and the contextual features are obtained by capturing contextual information from the initial features through the large-size convolutional kernel of the multi-branch large kernel fusion deep convolutional module. The target feature is obtained by fusing the initial feature and the context feature.

[0009] In an optional implementation, the step of fusing the initial features and the context features to obtain the target features includes: The structure and parameters of the depth-separable convolutional layer and the large-size convolutional kernel are optimized by structural reparameterization to obtain multiple identical single convolutional layers corresponding to the depth-separable convolutional layer and the large-size convolutional kernel; The output of each individual convolutional layer is obtained, and the outputs of each layer are fused to obtain the target feature.

[0010] In an optional implementation, the step of using the multi-scale dilated attention mechanism of the feature fusion network to process the target features in parallel to obtain fused features includes: The target features are respectively input into a multi-scale dilated convolutional layer and a channel attention mechanism layer; Multi-scale features are obtained by performing convolution with different dilation rates on the target features using the multi-scale dilated convolutional layer. The target feature is processed using the channel attention mechanism layer to obtain weight coefficients corresponding to the channel dimension. The spatial location and feature channel corresponding to the target feature are weighted and calculated using the weight coefficients to obtain the attention feature. The multi-scale features and the attention features are fused to obtain the fused features.

[0011] In an optional implementation, the step of processing the target features using the channel attention mechanism layer to obtain weight coefficients corresponding to the channel dimension includes: The target features are processed by global average pooling using the channel attention mechanism to obtain global average pooling information. The target features are subjected to global max pooling using the channel attention mechanism to obtain global max pooling information; The weight coefficients are obtained by weighting the global average pooling information and the global max pooling information.

[0012] In an optional implementation, the step of classifying and locating the fused features using the lightweight detection head to obtain the defect detection result of the tobacco image to be tested includes: The lightweight detection head is used to classify, locate, and calculate the target confidence of the fused features using multiple detection branches. The classification results, localization results, and target confidence scores corresponding to the fusion features are labeled on the tobacco image to be tested, thereby obtaining the defect detection results of the tobacco image to be tested.

[0013] In an optional implementation, the step of classifying and locating the fused features using the lightweight detection head further includes: Construct classification loss function, localization loss function, and target confidence loss function respectively; A weighted combined loss function is constructed using the classification loss function, the localization loss function, and the target confidence loss function. The output of the loss-lightweight detection head is then monitored and optimized using the weighted combined loss function.

[0014] Secondly, the present invention provides a tobacco defect detection device, comprising: The image acquisition module is used to acquire an image of the tobacco shreds to be tested and input the image of the tobacco shreds to be tested into the defect detection model. The defect detection model includes a backbone network, a feature fusion network, and a lightweight detection head. The feature extraction module is used to extract initial image features from the tobacco image under test by using the multi-branch large kernel fusion deep convolution module of the backbone network, and to fuse the initial image features to obtain target features. The feature fusion module is used to perform parallel processing on the target features using the multi-scale dilated attention mechanism of the feature fusion network to obtain fused features; The defect detection module is used to classify and locate the fused features using the lightweight detection head to obtain the defect detection results of the tobacco image to be tested.

[0015] Thirdly, the present invention provides an electronic device including a processor and a memory, the memory storing machine-executable instructions that can be executed by the processor, the processor executing the machine-executable instructions to implement the tobacco defect detection method described in the first aspect.

[0016] Fourthly, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the tobacco defect detection method described in the first aspect.

[0017] The present invention provides a method, apparatus, device and storage medium for detecting defects in tobacco shreds. By using a multi-branch large kernel fusion deep convolution module, a multi-scale hole attention mechanism and a lightweight detection head, the existing detection model is improved, so that the improved defect detection model has the characteristics of high accuracy and lightweight, and the robustness and anti-interference ability of the detection model are significantly improved.

[0018] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0019] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 A block diagram of an electronic device provided by an embodiment of the present invention is shown; Figure 2A flowchart illustrating a method for detecting defects in tobacco shreds provided in an embodiment of the present invention is shown. Figure 3 This diagram illustrates the structure of a defect detection model provided in an embodiment of the present invention. Figure 4 This diagram illustrates the structure of a multi-branch large-kernel fusion deep convolution module according to an embodiment of the present invention. Figure 5 This diagram illustrates the structure of a multi-scale holed attention mechanism network provided in an embodiment of the present invention. Figure 6 A schematic diagram of a lightweight detection head provided by an embodiment of the present invention is shown.

[0021] icon: 100 - Electronic device; 110 - Memory; 120 - Processor; 130 - Communication module. Detailed Implementation

[0022] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.

[0023] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.

[0024] It should be noted that relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0025] Please refer to Figure 1 , Figure 1This is a block diagram of an electronic device 100 provided in this embodiment. The electronic device 100 includes a memory 110, a processor 120, and a communication module 130. The memory 110, processor 120, and communication module 130 are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines.

[0026] The memory 110 is used to store programs or data. The memory 110 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.

[0027] The processor 120 is used to read / write data or programs stored in the memory 110 and to perform corresponding functions.

[0028] The communication module 130 is used to establish a communication connection between the electronic device 100 and other communication terminals through the network, and to send and receive data through the network.

[0029] It should be understood that, Figure 1 The structure shown is only a schematic diagram of the electronic device 100. The electronic device 100 may also include components that are larger than... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown. Figure 1 The components shown can be implemented using hardware, software, or a combination thereof.

[0030] Please refer to Figure 2 , Figure 2 This is a flowchart illustrating a method for detecting defects in tobacco shreds provided in this embodiment. The method includes: S210. Obtain an image of the tobacco shreds to be tested, and input the image of the tobacco shreds to be tested into a defect detection model. The defect detection model includes a backbone network, a feature fusion network, and a lightweight detection head.

[0031] Please refer to Figure 3 , Figure 3 This is a schematic diagram of the structure of a defect detection model provided in this embodiment.

[0032] This embodiment is based on the YOLOv11n network and has been adapted and improved. The improved defect detection model mainly includes three parts: backbone network, feature fusion network, and lightweight detection head.

[0033] S220. The multi-branch large kernel fusion deep convolution module of the backbone network is used to extract multi-scale features from the tobacco image to be tested to obtain initial image features, and the initial image features are fused to obtain target features.

[0034] Traditional YOLOv11n networks lack a targeted high-frequency information extraction mechanism during rapid downsampling. High-frequency details such as edges and textures in tobacco defect images are crucial for distinguishing foreign objects, tobacco stems, and normal tobacco background. This high-frequency information is easily lost in deeper layers of the network, leading to a significant decrease in recall and localization accuracy for small target defects.

[0035] Therefore, this embodiment introduces a multi-branch large kernel fusion deep convolution module (MLFD Module) to replace the original partial convolution modules of the YOLOv11n network backbone. The MLFD Module is used to extract and fuse multi-scale features in the tobacco images under test, thereby enhancing the ability to extract multi-scale defects in tobacco images while maintaining the lightweight nature of the model.

[0036] S230. The target features are processed in parallel using the multi-scale dilated attention mechanism of the feature fusion network to obtain fused features.

[0037] The original YOLOv11n network suffers from redundant and inefficient feature processing. The network's feature extraction modules, such as the C3 module, fail to adequately suppress redundant features between channels when processing features. As a result, although the number of parameters and computational cost (FLOPs) of the model is lower than that of large networks, it still cannot meet the tobacco industry's requirements for real-time detection with extremely low latency.

[0038] To address this, this embodiment introduces a multi-scale hole attention mechanism (MDTA Module) in the feature fusion layer. MDTA is used to recalibrate and enhance the target features output by the backbone network to suppress background noise caused by tobacco weaving and lighting changes, thereby obtaining the processed fused features.

[0039] S240. The lightweight detection head is used to classify and locate the fused features to obtain the defect detection results of the tobacco image to be tested.

[0040] The original YOLOv11n network's detection head lacks a task interaction mechanism, typically treating classification and localization tasks as independent or weakly related tasks. When faced with complex-shaped tobacco stems or irregularly shaped clumps, classification and localization features cannot be perfectly aligned spatially or semantically, resulting in poor robustness and a high false positive rate in the final prediction results.

[0041] Therefore, this embodiment replaces the original YOLOv11n network's detection head with a lightweight detection head. The lightweight detection head performs multi-branch detection on the fused features to obtain classification and localization results. Then, the defect detection results are generated based on the classification and localization results. This reduces the number of parameters in the detection branches and improves the localization accuracy.

[0042] This embodiment improves the existing detection model by using a multi-branch large kernel fusion deep convolution module, a multi-scale dilated attention mechanism, and a lightweight detection head. The improved defect detection model has the characteristics of high accuracy and lightweight, and significantly improves the robustness and anti-interference ability of the detection model.

[0043] In one embodiment, the initial image features include initial features and contextual features. The step of using the multi-branch large kernel fusion deep convolution module of the backbone network to extract multi-scale features from the tobacco image to be tested to obtain initial image features, and then fusing the initial image features to obtain target features, includes: The initial features are obtained by extracting features from the tobacco image under test through the depth-separable convolutional layer of the multi-branch large kernel fusion deep convolutional module, and the contextual features are obtained by capturing contextual information from the initial features through the large-size convolutional kernel of the multi-branch large kernel fusion deep convolutional module. The target feature is obtained by fusing the initial feature and the context feature.

[0044] Please refer to Figure 4 , Figure 4 This is a schematic diagram of the structure of a multi-branch large kernel fusion deep convolution module provided in this embodiment.

[0045] The multi-branch, large-kernel fusion deep convolution module mainly consists of three parts: a lightweight branch, a large-kernel branch, and a fusion and reparameterization part. These three parts are related to... Figure 4 The structures shown correspond sequentially from top to bottom.

[0046] The lightweight branch uses depthwise separable convolution layers to extract features, and can use a small kernel branch to focus on extracting high-frequency detail features of minute defects.

[0047] The large kernel branch uses a large-size convolutional kernel to increase the receptive field, thereby capturing long-range contextual information of the initial features and effectively perceiving the overall shape of large and irregular defects.

[0048] The fusion and reparameterization section is used to fuse the output features of the lightweight branch and the large kernel branch by splicing or adding them together.

[0049] Furthermore, the depthwise separable convolution used in the MLFD module can reduce computational cost. Significantly reduced, as shown in the formula below:

[0050] Where K is the kernel size, H is the feature map height, W is the feature map width, and C is the feature map width. in For input features, C out As an output feature, this structure is one of the core technical means to achieve the ultra-lightweight design of this invention framework, and its parameter count... Compared to the number of parameters in a standard convolutional layer Significantly reduced, as shown below:

[0051] Compared to standard convolution When the K value is large, the MLFD module significantly reduces its number of parameters and computational cost (FLOPs), thereby improving feature extraction capabilities while ensuring the lightweight nature of the model.

[0052] This embodiment extracts features from the tobacco images under test by using a lightweight branch and a large kernel branch, while capturing local minute details and long-range contextual information in the tobacco images. Furthermore, the number of model parameters is reduced by using depthwise separable convolutional layers, thus achieving a lightweight model.

[0053] In one implementation, the step of fusing the initial features and the context features to obtain the target features includes: The structure and parameters of the depth-separable convolutional layer and the large-size convolutional kernel are optimized by structural reparameterization to obtain multiple identical single convolutional layers corresponding to the depth-separable convolutional layer and the large-size convolutional kernel; The output of each individual convolutional layer is obtained, and the outputs of each layer are fused to obtain the target feature.

[0054] Structural reparameterization is a neural network optimization method. Its core is to improve model performance by using complex multi-branch structures during training, and then to merge the complex structures into simpler structures for inference after training by equivalent parameter transformation, thereby balancing model accuracy and inference efficiency.

[0055] Therefore, during the model training phase, a complex multi-branch network structure can be built and then the parameters can be fused. During the inference phase, only the fused simple structure needs to be used for inference.

[0056] Since the lightweight branch and the large kernel branch may use different kernel sizes, the lightweight branch usually uses a 3×3 kernel, while the large kernel branch usually uses a 5×5 or 7×7 kernel. After the model is trained, the kernels of the lightweight branch and the large kernel branch can be reparameterized to optimize them into a single, computationally efficient convolutional layer. Then, the output results can be simply fused together.

[0057] This embodiment optimizes the structure and parameters of the lightweight branch and the large core branch by using structural reparameterization technology, thereby improving the computational efficiency of the model.

[0058] In one embodiment, the step of using the multi-scale dilated attention mechanism of the feature fusion network to perform parallel processing on the target features to obtain fused features includes: The target features are respectively input into a multi-scale dilated convolutional layer and a channel attention mechanism layer; Multi-scale features are obtained by performing convolution with different dilation rates on the target features using the multi-scale dilated convolutional layer. The target feature is processed using the channel attention mechanism layer to obtain weight coefficients corresponding to the channel dimension. The spatial location and feature channel corresponding to the target feature are weighted and calculated using the weight coefficients to obtain the attention feature. The multi-scale features and the attention features are fused to obtain the fused features.

[0059] Please refer to Figure 5 , Figure 5 This is a schematic diagram of the structure of a multi-scale hole attention mechanism network provided in this embodiment.

[0060] The multi-scale dilated attention mechanism is a combination of multi-scale dilated convolution and Transformer self-attention mechanism. It fuses the features output by the backbone network by using multi-scale dilated convolution and Transformer self-attention mechanism in parallel.

[0061] Among them, multi-scale dilated convolution uses dilated convolution with different dilation rates to process target features in parallel, thereby effectively expanding the local receptive field and obtaining multi-scale contextual information, which is particularly helpful in identifying defects in different interleaving states.

[0062] The channel attention mechanism dynamically weights the spatial location and feature channels on the feature map by calculating the relationship between the query, key, and value corresponding to the target feature.

[0063]

[0064] in, The dimension of the Key.

[0065] This embodiment innovatively integrates multi-scale dilated convolution and Transformer self-attention mechanism to enhance the robustness of the model under complex tobacco backgrounds and varying lighting conditions.

[0066] In one implementation, the step of processing the target features using the channel attention mechanism layer to obtain weight coefficients corresponding to the channel dimension includes: The target features are processed by global average pooling using the channel attention mechanism to obtain global average pooling information. The target features are subjected to global max pooling using the channel attention mechanism to obtain global max pooling information; The weight coefficients are obtained by weighting the global average pooling information and the global max pooling information.

[0067] The channel attention weights in the MDTA module integrate dual-path attention, combining global average pooling and global max pooling, ensuring the completeness and robustness of feature description. The calculation formula is as follows:

[0068] in It is the input feature map. and These are global average pooling and global max pooling, respectively.

[0069] In one embodiment, the step of classifying and locating the fused features using the lightweight detection head to obtain the defect detection result of the tobacco image to be tested includes: The lightweight detection head is used to classify, locate, and calculate the target confidence of the fused features using multiple detection branches. The classification results, localization results, and target confidence scores corresponding to the fusion features are labeled on the tobacco image to be tested, thereby obtaining the defect detection results of the tobacco image to be tested.

[0070] Please refer to Figure 6 , Figure 6 This is a schematic diagram of a lightweight detection head provided in this embodiment.

[0071] The lightweight detection head employs three distinct branches, with separate outputs for classification, localization, and target confidence corresponding to the fused features, ensuring the model's effectiveness in multi-task learning.

[0072] Then, by combining the loss function, the accuracy of detection and positioning is not degraded under the premise of significantly reducing the number of parameters, especially for the accurate positioning of small and irregular targets such as foreign objects and tobacco stems.

[0073] The step of classifying and locating the fused features using the lightweight detection head further includes: Construct classification loss function, localization loss function, and target confidence loss function respectively; A weighted combined loss function is constructed using the classification loss function, the localization loss function, and the target confidence loss function. The output of the loss-lightweight detection head is then monitored and optimized using the weighted combined loss function.

[0074] This embodiment uses a weighted combination loss function. To optimize the geometric accuracy of the bounding box, the presence of the target, and the classification accuracy, the formula is as follows:

[0075] in, These are the weighting coefficients for the losses of each part.

[0076] Location loss (Locus Loss): We employ DIoU Loss (Distance IoU Loss) or CIoU Loss. DIoU Loss considers not only the overlap area (IoU) between the predicted and ground truth boxes, but also the distance between their center points. This helps accelerate model convergence and improves the accuracy of bounding box fitting for irregularly shaped defects (such as tobacco stems or irregular foreign objects).

[0077]

[0078] in, It is a prediction box and real frame The square of the Euclidean distance from the center point. It is the diagonal length of the smallest rectangle containing two boxes.

[0079] Classification loss (Classification Loss): The binary cross-entropy (BCE) loss is used to predict the defect category probability for each anchor box.

[0080] Target confidence loss (Objectness Loss): Also using BCE loss, it is used to determine whether the anchor frame contains any tobacco defect targets.

[0081] This embodiment improves the accuracy of detection results by constructing a weighted combined loss function to supervise and optimize the lightweight detection head.

[0082] To perform the corresponding steps in the above embodiments and various possible methods, an implementation of a tobacco defect detection device is given below. It should be noted that the basic principle and technical effects of the tobacco defect detection device provided in this embodiment are the same as those in the above embodiments. For the sake of brevity, any parts not mentioned in this embodiment can be referred to the corresponding content in the above embodiments. The tobacco defect detection device includes: The image acquisition module is used to acquire an image of the tobacco shreds to be tested and input the image of the tobacco shreds to be tested into the defect detection model. The defect detection model includes a backbone network, a feature fusion network, and a lightweight detection head. The feature extraction module is used to extract initial image features from the tobacco image under test by using the multi-branch large kernel fusion deep convolution module of the backbone network, and to fuse the initial image features to obtain target features. The feature fusion module is used to perform parallel processing on the target features using the multi-scale dilated attention mechanism of the feature fusion network to obtain fused features; The defect detection module is used to classify and locate the fused features using the lightweight detection head to obtain the defect detection results of the tobacco image to be tested.

[0083] Optionally, the above modules can be stored in the form of software or firmware. Figure 1 The memory shown is either stored in or embedded in the operating system (OS) of the electronic device, and can be used by... Figure 1 The processor executes the commands. Meanwhile, the data and program code required to execute these modules can be stored in memory.

[0084] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative; for example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0085] In addition, the functional modules in the various embodiments of the present invention can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0086] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0087] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A method for detecting defects in tobacco shreds, characterized in that, include: An image of the tobacco shreds to be tested is acquired, and the image is input into a defect detection model, which includes a backbone network, a feature fusion network, and a lightweight detection head. The multi-branch large kernel fusion deep convolution module of the backbone network is used to extract multi-scale features from the tobacco image to be tested to obtain initial image features, and the initial image features are fused to obtain target features; The target features are processed in parallel using the multi-scale dilated attention mechanism of the feature fusion network to obtain fused features. The lightweight detection head is used to classify and locate the fused features to obtain the defect detection results of the tobacco image to be tested.

2. The method for detecting defects in tobacco shreds according to claim 1, characterized in that, The initial image features include initial features and contextual features. The step of using the multi-branch large kernel fusion deep convolution module of the backbone network to extract multi-scale features from the tobacco image to be tested to obtain initial image features, and then fusing the initial image features to obtain target features, includes: The initial features are obtained by extracting features from the tobacco image under test through the depth-separable convolutional layer of the multi-branch large kernel fusion deep convolutional module, and the contextual features are obtained by capturing contextual information from the initial features through the large-size convolutional kernel of the multi-branch large kernel fusion deep convolutional module. The target feature is obtained by fusing the initial feature and the context feature.

3. The method for detecting defects in tobacco shreds according to claim 2, characterized in that, The step of fusing the initial features and the context features to obtain the target features includes: The structure and parameters of the depth-separable convolutional layer and the large-size convolutional kernel are optimized by structural reparameterization to obtain multiple identical single convolutional layers corresponding to the depth-separable convolutional layer and the large-size convolutional kernel; The output of each individual convolutional layer is obtained, and the outputs of each layer are fused to obtain the target feature.

4. The method for detecting defects in tobacco shreds according to claim 1, characterized in that, The step of using the multi-scale dilated attention mechanism of the feature fusion network to process the target features in parallel to obtain fused features includes: The target features are respectively input into a multi-scale dilated convolutional layer and a channel attention mechanism layer; Multi-scale features are obtained by performing convolution with different dilation rates on the target features using the multi-scale dilated convolutional layer. The target feature is processed using the channel attention mechanism layer to obtain weight coefficients corresponding to the channel dimension. The spatial location and feature channel corresponding to the target feature are weighted and calculated using the weight coefficients to obtain the attention feature. The multi-scale features and the attention features are fused to obtain the fused features.

5. The method for detecting defects in tobacco shreds according to claim 4, characterized in that, The step of processing the target features using the channel attention mechanism layer to obtain weight coefficients corresponding to the channel dimension includes: The target features are processed by global average pooling using the channel attention mechanism to obtain global average pooling information. The target features are subjected to global max pooling using the channel attention mechanism to obtain global max pooling information; The weight coefficients are obtained by weighting the global average pooling information and the global max pooling information.

6. The method for detecting defects in tobacco shreds according to claim 1, characterized in that, The step of classifying and locating the fused features using the lightweight detection head to obtain the defect detection result of the tobacco image to be tested includes: The lightweight detection head is used to classify, locate, and calculate the target confidence of the fused features using multiple detection branches. The classification results, localization results, and target confidence scores corresponding to the fusion features are labeled on the tobacco image to be tested, thereby obtaining the defect detection results of the tobacco image to be tested.

7. The method for detecting defects in tobacco shreds according to claim 6, characterized in that, The step of classifying and locating the fused features using the lightweight detection head further includes: Construct classification loss function, localization loss function, and target confidence loss function respectively; A weighted combined loss function is constructed using the classification loss function, the localization loss function, and the target confidence loss function. The output of the loss-lightweight detection head is then monitored and optimized using the weighted combined loss function.

8. A device for detecting defects in tobacco shreds, characterized in that, include: The image acquisition module is used to acquire an image of the tobacco shreds to be tested and input the image of the tobacco shreds to be tested into the defect detection model. The defect detection model includes a backbone network, a feature fusion network, and a lightweight detection head. The feature extraction module is used to extract initial image features from the tobacco image under test by using the multi-branch large kernel fusion deep convolution module of the backbone network, and to fuse the initial image features to obtain target features. The feature fusion module is used to perform parallel processing on the target features using the multi-scale dilated attention mechanism of the feature fusion network to obtain fused features; The defect detection module is used to classify and locate the fused features using the lightweight detection head to obtain the defect detection results of the tobacco image to be tested.

9. An electronic device, characterized in that, It includes a processor and a memory, the memory storing machine-executable instructions that can be executed by the processor, the processor executing the machine-executable instructions to implement the tobacco defect detection method according to any one of claims 1-7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the tobacco defect detection method as described in any one of claims 1-7.