A reconstituted shreds micro impurities rapid detection system and method based on improved YOLOv8
By improving the YOLOv8 detection model and combining a large-core backbone layer, a multi-scale downsampling module, and a coordinated attention module, the accuracy and universality issues of detecting minute impurities in reconstructed filaments were resolved, achieving efficient and reliable impurity detection results.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- JIANGSU SECOND NORMAL UNIVERSITY
- Filing Date
- 2026-02-14
- Publication Date
- 2026-06-02
AI Technical Summary
Existing technologies are insufficient to effectively detect minute non-tobacco impurities in reconstituted tobacco stems, leading to a decline in cigarette quality and health risks to consumers. Furthermore, traditional methods lack universality and detection accuracy in cases involving minute impurities.
An improved YOLOv8 detection model is adopted, which combines a large kernel backbone layer, a multi-scale downsampling module (MSDM), and a coordinated attention module (CA) to enhance feature extraction capabilities. The AdamW optimizer is used for training to improve detection accuracy and robustness.
It significantly improves the detection accuracy and stability of tiny impurities in reconstituted stems. The model exhibits excellent performance at different scales and with varying detection task complexity, making it suitable for deployment in resource-constrained environments and meeting the requirements for high-precision and reliable detection.
Smart Images

Figure CN122134671A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of tobacco processing quality control technology, specifically relating to a rapid detection system and method for minute impurities in reconstituted stems based on an improved YOLOv8. Background Technology
[0002] With the continuous growth in consumer demand for low-tar cigarettes, reconstituted tobacco stems, as a new type of tobacco raw material that can effectively reduce the tar content of cigarettes, have been widely used in the production of various types of cigarettes. However, during the raw material harvesting, storage, and processing stages, reconstituted tobacco stems are easily contaminated with tiny non-tobacco impurities due to improper handling. These impurities are typically only 2-10 mm in size, difficult to detect with the naked eye, and produce toxic and harmful substances such as benzo[a]pyrene and formaldehyde when burned, seriously affecting cigarette quality and consumer health.
[0003] Currently, there have been some studies on tobacco impurity detection both inside and outside the industry. For example, the paper LIANG Jing, WANG Yueying, SHI Yu, et al. Non-destructive discrimination of homochromatic foreign materials in tobacco based on VIS-NIR hyperspectral imaging[J]. Journal of the Science of Food and Agriculture, 2023, 103(9): 4545-4552. developed a metal detector for metallic impurities and an air separator for light impurities. The paper XUE Sheng, LI Zhenye, WURui, et al. Few-Shot Learning for Small Impurities in Tobacco Stems With Improved YOLOv7[J]. IEEE Access, 2023, 11: 48136-48144. proposed an RGB imaging technique to distinguish impurities by typical patterns. The paper Kai C, Qian X, Bo X, et al. A Machine Vision Algorithm for Foreign Bodies Detection in Tobacco Conveyor [C] / / 2019 International Conference on Sensing and Instrumentation in IoT Era (ISSI). IEEE, 2019: 1-6. This paper develops a machine vision algorithm for detecting impurities in tobacco conveyor belts. This algorithm combines RGB imaging with Bayesian detection methods, enabling the detection of impurities beyond the capabilities of color detection. However, these techniques and algorithms are often designed for specific scenarios, resulting in poor universality and scalability. Furthermore, when the impurities mixed with tobacco stems are numerous and fine, the camera will display stripes, significantly affecting the detection results. Therefore, conventional models are insufficient for applications where impurity targets are extremely fine.
[0004] With the widespread application of RGB imaging, scholars have proposed various algorithms for impurity detection, demonstrating the adaptability of the YOLO series through comparisons with numerous target detection methods. For example, the paper LI Fudong, GAODongyang, YANG Yuequan, et al. Small target deep convolution recognition algorithm based on improved YOLOv4 [J]. International Journal of Machine Learning and Cybernetics, 2023, 14: 387-394, proposes a small target detection model based on YOLOv4, which can extract multi-scale features in the feature pyramid through differences in pooling kernel sizes. Although this model is not based on the latest version of the YOLO series, and the detection accuracy is only 7% higher than YOLOv4, it highlights the potential of introducing multi-scale features into the network to improve the accuracy of small target detection. One of the current challenges in small target detection is the lack of extraction of target-related features from the input image by traditional methods. Therefore, extracting more features from the input is crucial.
[0005] Furthermore, image super-resolution is also considered an effective method for solving the small object detection problem because it can obtain higher resolution input images, thereby enriching the information of the entire image and small objects. For example, the paper DINGWenhao,HELiang.MTGAN:Speaker Verification through Multitasking Triplet Generative Adversarial Networks[C] / / Interspeech2018,2018 can generate higher resolution images and perform small object detection on the results. Its disadvantages are that it requires a lot of computing resources and high-requirement datasets, which conflicts with multi-scale features; in addition, the process of multi-scale feature extraction also generates a large number of feature tensors, making it difficult for GAN to converge, resulting in higher computing resource requirements. Summary of the Invention
[0006] The purpose of this invention is to provide a rapid detection system and method for minute impurities in reconstituted stems based on an improved YOLOv8, thereby solving the problems mentioned in the background art.
[0007] To solve the above-mentioned technical problems, the present invention adopts the following solution: A rapid detection system for minute impurities in reconstituted stem fibers includes: An image acquisition unit is used to acquire an RGB image containing regenerated filaments, wherein the resolution of the RGB image is adjusted to 640×640 pixels.
[0008] The model processing unit incorporates an improved YOLOv8 detection model, which includes a backbone network, a neck network, and a head network. The initial layer of the backbone network is a large-kernel backbone layer, employing a ConvModule module with a 31×31 convolutional kernel size. Each ConvModule module sequentially includes Conv2d, BatchNorm2d, and SiLU activation functions. Each stage layer of the backbone network embeds a multi-scale downsampling module (MSDM), and each stage layer integrates a coordinated attention module (CA) at its tail. The CA module encodes horizontal and vertical positional information and enhances features in the feature map, while the MSDM module extracts multi-scale features of small impurities in the reconstructed filaments. The neck network uses a feature pyramid structure (FPN), and the head network outputs the impurity category, bounding box, and confidence score.
[0009] The result output unit is used to receive the detection results from the model processing unit and visualize the location and category information of tiny impurities in the reconstructed filaments.
[0010] In this invention, the MSDM algorithm is used as the backbone to enhance the feature extraction capability for targets with the smallest surface area and the smallest number of pixels. Multiple branches of the MSDM algorithm can capture features at different levels. Secondly, a ConvModule with a specially designed, enlarged kernel size is used as the backbone layer to enhance the acquisition of correlation information from the input image. Finally, a CA module is added to the end of each stage within the backbone, which helps reduce computational requirements and effectively allocate extracted features, further enhancing the detection performance for small targets.
[0011] Further optimization involves the multi-scale downsampling module MSDM extracting multi-scale features of minute impurities in the reconstructed filaments. The implementation process is as follows: Large kernel downsampling convolution: A large kernel convolution operation is performed on the input feature map, and the feature mapping relationship is as follows: ; In the formula, F out ( i , j ) is the convolution output feature map at position ( i , j The eigenvalue at position ) F in The input feature map is used for convolution. K ( m,n ) represents the weight value of the convolution kernel at position (m,n). m、n The coordinate indices within the convolution kernel, 2 m 2n This represents the input feature map index offset caused by the downsampling stride. In the YOLOv8 architecture, using larger convolutional kernels can significantly increase the effective receptive field of view (ERF), meaning it includes more relational information. At the same time, larger convolutional kernels guide the network to be more suitable for learning shape features. Although image classification may only require relational or shape information, object detection heavily relies on shape information, making the model more suited to shape features for these tasks.
[0012] Multi-pooling feature extraction: 3×3 convolution is applied to the input feature map for inter-channel feature interaction, followed by max pooling and average pooling. Max pooling is used to highlight significant impurity features. The feature mapping relationship is as follows: ; Average pooling is used to smooth background noise, and the feature mapping relationship is as follows: ; In the formula, P max ( i , j ) represents the max-pooling output eigenvalue. P avg ( i , j ) represents the average pooling output feature value. W The window for pooling operations has a size of 2×2, where |W| is the total number of pixels within the window. a , b The coordinate indicators within the window.
[0013] Multi-scale feature fusion: outputting feature maps from large-kernel convolution. F conv With pooling output feature map P max , P avg After concatenation, the number of channels is adjusted to the target size using a 1×1 convolution, and the fused features are output. The feature mapping relationship is as follows: ,and ; In the formula, F conv This is the output feature map of the large kernel downsampling convolution. Concat () represents the feature map channel dimension concatenation operation. Conv 1×1 () represents a 1×1 convolution operation. F final for MSDM The final output feature map, MSDM ( F in )express MSDM The module processes the input feature map. F in The comprehensive processing function.
[0014] This function represents a synthesis operation on the MSDM, taking the input feature map... F in Output after processing through various scales and pooling operations F final With richer correlation information and details, MSDM is suitable for detecting small impurities. MSDM effectively extracts semantic correlation information and fuses features. It includes convolutional kernels of various sizes, where smaller kernels capture fine details and larger kernels capture more global features, thus obtaining multi-scale image information. This module also employs max pooling and average pooling, combining their advantages to some extent. Max pooling helps capture the most important features, while average pooling helps smooth features. Compared with the original feature extraction module, this design enhances the expressive power of features while controlling computational load and maintaining the network's real-time detection capabilities. The innovative integration of MSDM into the YOLOv8 architecture fully utilizes the advantages of multi-scale features, effectively improving the detection accuracy of small object impurities.
[0015] Another key aspect is adjusting the receptive field based on the size of the target. The Trident network architecture utilizes expanded convolutions with different dilation rates to create branches with varying receptive fields. This allows the model to adjust its focus based on the size of the object being detected, proving particularly effective for small imperfections requiring finer detail perception. A series of convolutional branches, each with a different dilation rate, are implemented within the improved MSDM model, enabling it to detect and classify objects over a wide range. This approach not only improves the model's sensitivity to small imperfections but also enhances its overall robustness by providing multiple perspectives with the same input features.
[0016] Further optimization involves the backbone network comprising four Stage layers: StageLayer1, StageLayer2, StageLayer3, and StageLayer4.
[0017] The StageLayer1 embeds the first MSDM, with an input feature map size of 320×320×32 and an output feature map size of 160×160×64; The StageLayer2 embeds a second MSDM, and the output feature map size is 80×80×128; The StageLayer3 embeds a third MSDM, and the output feature map size is 40×40×256; The StageLayer4 embeds a fourth MSDM, and the output feature map size is 20×20×512.
[0018] Tiny impurities, often occupying only small areas in an image, are frequently overlooked by traditional detectors due to their isolation from many background features outside these localized regions. However, these background features often contain crucial information relevant to the real-world scene. Supplementing the limited discriminative features of small targets with information from the surrounding environment can significantly improve detection accuracy. This method emphasizes increasing the feature extraction area of small targets by incorporating information from the surrounding environment. To achieve this, further optimization of the model involves modifying the size of each layer to incorporate more neighboring information from each small target. In CNNs, the dry layer acts as a gateway for the input data, performing initial processing and feature extraction. This layer lays the foundation for all subsequent operations, making its efficiency and effectiveness critical to the overall performance of the network. Larger kernels increase the receptive field, allowing the network to capture a wider range of spatial information from the input in a single convolutional stride. This capability is beneficial for detecting features spanning larger regions of the input image and for incorporating more correlated information early in the processing phase. While 3x3 kernels are a standard module in terms of performance and computational efficiency, they can also lead to biased feature maps with limited spatial correlation information. In contrast, 31x31 kernels generate feature maps with a wider coverage, making the initial feature representation more prominent.
[0019] Furthermore, the integration of the Coordination Attention (CA) module enhances the focus on channel information and amplifies the attention to related information. This attention mechanism not only considers spatial and channel relationships but also addresses long-term dependencies, enabling the model to more effectively focus on relevant details of related information. The CA module is lightweight in terms of parameters, making it computationally feasible.
[0020] Further optimizations include the following workflow for the Coordination Attention Module (CA): S11: Perform global average pooling in the horizontal dimension and global average pooling in the vertical dimension on the input feature map F to obtain the horizontal compressed feature map Fh and the vertical compressed feature map Fv, specifically: ; ; S12: Input Fh and Fv into a shared multilayer perceptron (MLP). The MLP contains one hidden layer (with the number of neurons equal to the number of input channels) and one output layer (with the number of neurons equal to the number of input channels). The output is processed by a sigmoid activation function to obtain a horizontal attention map Ah and a vertical attention map Av, specifically: ; ; In the formula, σ represents the sigmoid activation function, which scales the output of the MLP to the range of 0 to 1, representing the importance of each spatial dimension in different channels; S13: Add Ah and Av in their respective spatial dimensions, then perform element-wise multiplication with the original input feature map F to obtain the enhanced feature map. F enhanced Specifically: .
[0021] This operation ensures that attention is modulated horizontally and vertically, enriching the feature representation with perceptual cues of associative information. Enhanced feature mappings are then used in YOLOv8 layers. F enhanced It is used to detect and classify objects. By integrating CA, this detection model is able to focus on smaller, more important features in a larger context, which is crucial for detecting small impurities in images.
[0022] Further optimization involves the neck network employing an FPN+PAN structure, which fuses the 40×40×256, 80×80×128, and 20×20×512 feature maps output from the backbone network across scales, outputting feature maps of three scales for head network detection.
[0023] A rapid detection method for minute impurities in reconstituted stem fibers, based on the aforementioned rapid detection system for minute impurities in reconstituted stem fibers, includes the following steps: Step S1: Prepare a dataset of reconstructed filament impurities: Collect a large number of RGB images containing 6 typical impurities and manually annotate them to generate a dataset containing impurity bounding boxes and category labels; divide the dataset into training set and test set in a ratio of 85%:15%; the 6 impurities are black rubber block, blue plastic sheet, white paper scrap, white plastic sheet, pink rubber and green paint block.
[0024] Step S2: Constructing an improved YOLOv8 detection model: The initial layer of the backbone network of the improved YOLOv8 detection model is a 31-stem module with 31×31 convolutional kernels. Each stage layer of the backbone network embeds a multi-scale downsampling module MSDM, and each stage layer integrates a coordinated attention module CA at its tail.
[0025] Step S3: Using AdamW as the optimizer, train the improved YOLOv8 detection model using the training set, and adopt a linear learning rate adjustment strategy during the training process; after each round of training, calculate the model's average accuracy (AP) and average recall (AR) on the validation set to obtain the optimal algorithm model.
[0026] The AdamW optimizer is an extension of the Adam optimizer. It's not an add-on but rather incorporates weight decay directly into the optimizer. First, unlike SGD which uses a fixed learning rate, the AdamW optimizer adjusts the learning rate for each parameter based on the estimates of the first and second moments of the gradient. This adaptability leads to faster convergence and allows for targeted adjustments for different parameters during deep learning model training, resulting in significant training improvements. Second, AdamW integrates weight decay into the optimization process, effectively managing regularization to prevent overfitting. This is superior to SGD, where weight decay can sometimes cause gradient shifts and affect the model's generalization ability. Finally, AdamW can be used with superconvergence techniques, where the learning rate rapidly increases or decreases during training. This strategy significantly accelerates convergence and improves the accuracy and efficiency of the training process. By using this optimization strategy, the YOLOv8 model can better handle the variability of real-world data and effectively learn from enhanced training sets, thereby improving detection performance and generalization ability under different imaging conditions.
[0027] Step S4: Input the RGB image of the reconstructed filament to be detected into the trained improved YOLOv8 detection model, and output the impurity category, bounding box and confidence score to complete the detection of small impurities.
[0028] In further optimization, in step S1, each label box contains the coordinates of the upper left corner (x1, y1) and the coordinates of the lower right corner (x2, y2), and the category label uses numerical encoding, corresponding to 6 kinds of impurities respectively.
[0029] Further optimization involves calculating the model's average accuracy (AP) on the validation set in step S3, specifically as follows: First, calculate precision and recall: ; ; Wherein, TP is the true positive number, which is the number of positive samples correctly identified by the detection model; FP is the false positive number, which is the number of negative samples that the detection model incorrectly identified as positive samples; and FN is the false negative number, which is the number of positive samples that the detection model failed to identify. Next, plot the precision-recall curve and calculate the mean precision (AP), which is the area under the curve: ; And the interpolation accuracy P interp satisfy: ; in, r n , r n+1 For adjacent values of recall, For recall rate Corresponding precision; Define the matching relationship between the predicted object and the real object as the Intersection over Union (IoU), which satisfies: ; Where Area(Overlap) is the area of the overlapping region between the predicted bounding box and the ground truth bounding box, and Area(Box1∪Box2) is the area of the union region of the two bounding boxes; Calculate the average precision mAP, which is the average of the AP values for each IoU threshold from 0.5 to 0.95, incremented by 0.05, for a total of 10 thresholds. Then: .
[0030] Further optimization is achieved by calculating the average recall rate (AR) in step S3 as follows: ; in, o Let R(o) be the intersection-union ratio (IoU). o The corresponding recall rate.
[0031] Further optimization involves setting the optimizer's base learning rate to 0.001, the weight decay parameter to 0.05, and the optimizer momentum to 0.9 in step S3. The linear learning rate adjustment strategy satisfies the following formula: ; Where e is the current training epoch number, and max is the total number of training epochs. epochs =1000, minimum retention factor of learning rate lr factor =0.01, initial learning rate base lr =0.001.
[0032] Compared with the prior art, the present invention has the following beneficial effects: 1. This invention proposes a series of improvements to the YOLOv8 architecture model to enhance the detection of fine impurities in tobacco stems and stabilize tobacco product quality. These improvements include integrating a large kernel dry layer (31stem), a multi-scale downsampling module (MSDM), and coordinated attention (CA), as well as using the AdamW optimizer and a custom training protocol. Comparative and ablation studies demonstrate that each introduced component significantly contributes to the overall performance enhancement of the model.
[0033] 2. In comparative tests with current leading single-level and two-level models, the improved YOLOv8 architecture demonstrated superior performance, achieving an mAP of 82.4% and performing well on the AP50 and AP75 metrics. This not only proves the effectiveness of the improvement but also highlights the model's robustness across different scales and detection task complexities. Furthermore, the AdamW optimizer's efficient parameter counting and adaptive learning capabilities facilitate faster convergence and better generalization, making the model suitable for deployment in resource-constrained environments. The results demonstrate the practicality and scalability of this improved model, providing a powerful solution for industries seeking high accuracy and reliability in object detection. Attached Figure Description
[0034] Figure 1 This is a schematic diagram of the improved YOLOv8 detection model architecture; Figure 2 This is a schematic diagram of the MSDM model; Figure 3 These are graphs showing the learning speed and loss function for different models; Figure 4 These are the detection results of each model and the state-of-the-art (SOTA) model. Detailed Implementation
[0035] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions 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, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0036] Example 1: A rapid detection system for minute impurities in reconstituted stems, comprising: An image acquisition unit is used to acquire an RGB image containing regenerated filaments, wherein the resolution of the RGB image is adjusted to 640×640 pixels.
[0037] The model processing unit has a built-in improved YOLOv8 detection model, such as... Figure 1As shown, the improved YOLOv8 detection model includes a backbone network, a neck network, and a head network. The initial layer of the backbone network is a large-kernel backbone layer, which uses a ConvModule module with a convolutional kernel size of 31×31. The ConvModule module sequentially includes Conv2d, BatchNorm2d, and SiLU activation functions. Each stage layer of the backbone network embeds a multi-scale downsampling module (MSDM), and each stage layer integrates a coordinated attention module (CA) at its tail. The CA module is used to encode horizontal and vertical positional information and enhance features in the feature map. The MSDM module is used to extract multi-scale features of small impurities in the reconstructed filaments. The neck network uses a feature pyramid structure (FPN), and the head network outputs the impurity category, bounding box, and confidence score.
[0038] The result output unit is used to receive the detection results from the model processing unit and visualize the location and category information of tiny impurities in the reconstructed filaments.
[0039] In this invention, the MSDM algorithm is used as the backbone to enhance the feature extraction capability for targets with the smallest surface area and the smallest number of pixels. Figure 1 The left side depicts the reconstructed backbone and the location of the MSDM, while the right side details the MSDM architecture, showing multiple branches that capture different levels of features. Secondly, a specially designed ConvModule with an increased kernel size is used as the backbone layer to enhance the ability to acquire correlation information from the input image. Finally, CA modules are added at the end of each stage within the backbone, which helps reduce computational requirements and effectively distribute extracted features, further enhancing the detection performance for small targets.
[0040] In this embodiment, as Figure 1 As shown, the backbone network includes four Stage layers, namely StageLayer1, StageLayer2, StageLayer3, and StageLayer4.
[0041] The StageLayer1 takes a 640×640×3 RGB image as input and outputs a feature map of 320×320×32; the StageLayer2 embeds the first MSDM and outputs a feature map of 160×160×64. The StageLayer3 embeds a second MSDM, and the output feature map size is 80×80×128; The StageLayer4 embeds a third MSDM, and the output feature map size is 40×40×256.
[0042] like Figure 2 As shown, the multi-scale downsampling module MSDM includes four parallel branches: a deep kernel convolution branch, a 3×3 channel convolution branch, a max pooling branch, and an average pooling branch.
[0043] The deep large kernel convolution branch adopts the Conv2d operation with a kernel size of 5×5 and a stride of 2; The 3×3 channel convolution branch adopts a Conv2d operation with a kernel size of 3×3 and a stride of 2. The maximum pooling branch adopts a MaxPool2d operation with a pooling kernel size of 2×2 and a step size of 2. The average pooling branch adopts the AvgPool2d operation with a pooling kernel size of 2×2 and a step size of 2. The output feature maps of the four branches are adjusted to the same number of channels by 1×1 convolution, then fused by the Concat operation, and then processed by the ConvModule to obtain the output feature map of MSDM.
[0044] The workflow of the Coordination Attention Module (CA) includes: S11: Perform global average pooling in the horizontal dimension and global average pooling in the vertical dimension on the input feature map F to obtain the horizontal compressed feature map Fh and the vertical compressed feature map Fv.
[0045] S12: Input Fh and Fv into a shared multilayer perceptron (MLP). The MLP contains one hidden layer (the number of neurons is 1 / 4 of the number of input channels) and one output layer (the number of neurons is the same as the number of input channels). The output is processed by the sigmoid activation function to obtain the horizontal attention map Ah and the vertical attention map Av.
[0046] S13: Add Ah and Av in their respective spatial dimensions, then perform element-wise multiplication with the original input feature map F to obtain the enhanced feature map. F enhanced .
[0047] This operation ensures that attention is modulated horizontally and vertically, enriching the feature representation with perceptual cues of associative information. Enhanced feature mappings are then used in YOLOv8 layers. F enhanced It is used to detect and classify objects. By integrating CA, this detection model is able to focus on smaller, more important features in a larger context, which is crucial for detecting small impurities in images.
[0048] The neck network adopts an FPN+PAN structure, which performs cross-scale fusion of the 40×40×256, 80×80×128, and 160×160×64 feature maps output by the backbone network, and outputs feature maps of three scales for head network detection.
[0049] Example 2: A rapid detection method for minute impurities in reconstituted stems, based on the rapid detection system for minute impurities in reconstituted stems described in Example 1, includes the following steps: Step S1: Prepare the reconstructed filament impurity dataset: Collect a large number of RGB images containing 6 typical impurities and manually annotate them to generate a dataset containing impurity bounding boxes and category labels; divide the dataset into training and testing sets in a ratio of 85%:15%; the 6 impurities are black rubber block, blue plastic sheet, white paper scrap, white plastic sheet, pink rubber, and green paint block. Each bounding box contains the upper left corner coordinates (x1, y1) and the lower right corner coordinates (x2, y2), and the category labels use numerical codes, each corresponding to one of the 6 impurities.
[0050] Step S2: Constructing an improved YOLOv8 detection model: The initial layer of the backbone network of the improved YOLOv8 detection model is a 31-stem module with 31×31 convolutional kernels. Each stage layer of the backbone network embeds a multi-scale downsampling module MSDM, and each stage layer integrates a coordinated attention module CA at its tail.
[0051] Step S3: Using AdamW as the optimizer, train the improved YOLOv8 detection model using the training set, and adopt a linear learning rate adjustment strategy during the training process; after each round of training, calculate the model's average accuracy (AP) and average recall (AR) on the validation set to obtain the optimal algorithm model.
[0052] Step S4: Input the RGB image of the reconstructed filament to be detected into the trained improved YOLOv8 detection model, and output the impurity category, bounding box and confidence score to complete the detection of small impurities.
[0053] Experiments and verification: 1. Experimental setup:
[0054] The experiments were conducted on the improved YOLOv8 architecture, utilizing the AdamW optimizer to facilitate fast and efficient convergence. The optimizer's base learning rate was 0.001, the weight decay parameter was 0.05 (excluding bias and norm), and the optimizer momentum was 0.9. A linear learning rate adjustment strategy was employed during training. ; Where e is the current training epoch number, and max is the total number of training epochs. epochs=1000, minimum retention factor of learning rate lr factor =0.01, initial learning rate base lr =0.001.
[0055] Within the planned 1000 epochs, the learning rate steadily decreased. The initial phase comprised the first 1000 iterations, approximately 20 epochs, during which the learning rate gradually scaled up to the full baseline level. For data processing, the input images were resized to 640x640 pixels; for data augmentation, mosaic techniques were employed for the first 950 epochs to introduce complexity and variability, enhancing the model's generalization ability across different scenarios. This was complemented by randomized affine transformations, albumentation enhancements, HSV adjustments, and random flipping to further enhance the diversity of the dataset. After the 950th epoch, as the model had approached the full training duration, mosaic enhancements were discontinued to stabilize the model's learning, and the model weights were smoothed using an exponential moving average (EMA) with a decay factor of 0.9999 to help stabilize the training results.
[0056] 2. Evaluation indicators:
[0057] To evaluate the performance of the improved YOLOv8 detection model in detecting reconstructed stem impurities, mean accuracy (AP) and mean recall (AR) were selected as evaluation metrics. These metrics are crucial for assessing the robustness and accuracy of the model in detecting and segmenting objects in different scenarios.
[0058] 2.1 Calculation of Mean Accuracy (AP)
[0059] First, calculate precision and recall: ; ; Wherein, TP is the true positive number, which is the number of positive samples correctly identified by the detection model; FP is the false positive number, which is the number of negative samples that the detection model incorrectly identified as positive samples; and FN is the false negative number, which is the number of positive samples that the detection model failed to identify. Next, plot the precision-recall curve and calculate the mean precision (AP), which is the area under the curve: ; And the interpolation accuracy P interp satisfy: ; in, r n , r n+1 For adjacent values of recall, For recall rate Corresponding precision; Define the matching relationship between the predicted object and the real object as the Intersection over Union (IoU), which satisfies: ; Where Area(Overlap) is the area of the overlapping region between the predicted bounding box and the ground truth bounding box, and Area(Box1∪Box2) is the area of the union region of the two bounding boxes; Calculate the average precision mAP, which is the average of the AP values for each IoU threshold from 0.5 to 0.95, incremented by 0.05, for a total of 10 thresholds. Then: ; 2.2 Calculation of Average Recall (AR)
[0060] ; in, o for Intersection over Union (IoU) R(o) represents the value of IoU. o The corresponding recall rate.
[0061] 3. Ablation experiment results and analysis: A series of ablation experiments were conducted to further evaluate the performance improvements brought about by key modifications in the YOLOv8 architecture. These modifications included the addition of a large kernel (31 stem) to the dry layer, the multi-scale downsampling module (MSDM), the coordinated attention module (CA), and changes to the optimizer and training time.
[0062] 3.1 Ablation of key components
[0063] Improvements were gradually added to the standard YOLOv8 model to progressively demonstrate the impact of each modification on the model. Results show that performance improved at each step, as shown in Table 1. Starting with the addition of the CA module, model performance improved slightly, with mAP increasing from 70.6% to 71.5%, and AP75 also showing significant improvement. This validates the effectiveness of CA, especially at higher IoU thresholds. Introducing MSDM brought even greater performance improvements, increasing mAP to 72.4%, with improvements in AP50 and AP75, indicating that processing multi-scale information effectively improves detection accuracy. Replacing the stem layer with the 31stem module also improved performance, highlighting the importance of feature extraction capabilities in the initial layer. Combining 31stem with MSDM significantly improved performance to 73.6% mAP, indicating a synergistic effect between these modules. Adding CA further improved the results, reaching mAP of 73.8%. Finally, the AdamW optimizer integrated with 300 epochs achieved maximum performance, with mAP of 74.0% and AP75 of 85.4%, demonstrating that each component contributed to the enhancement of model performance.
[0064] Table 1 Ablation Results of Key Components ; 3.2MSDM Multiscale Branch Ablation The MSDM has four branches for multi-scale information processing: deep large kernel convolution (lk), 3x3 channel convolution (sk), mean pooling, and max pooling (max). Because these branches have synergistic effects, experiments were conducted on the 31stem+MSDM model to determine their individual and joint effects, as shown in Table 2. The results show that adding the deep large kernel convolution (lk) branch results in the lowest accuracy and insufficient channel interaction. Adding mean pooling significantly improves performance, indicating the importance of incorporating local information. Adding max pooling (max) slightly decreases performance compared to using mean alone, but using both simultaneously does not further improve the results. The 3x3 channel convolution (sk) branch alone improves baseline performance, and more effect can be seen by adding max pooling (max) instead of mean pooling (mean). Combining the deep large kernel convolution (lk) and 3x3 channel convolution (sk) branches does not show a significant change. Adding max pooling (max) and mean pooling (mean) to this combination significantly improves performance. When all four branches are used together, mAP reaches a maximum of 73.6%, indicating that these components effectively complement each other. In the dry layer (31 stem + 1kL), only Switching MSDM to large kernel downsampling channel convolution did not improve performance, which confirms that the key to improving performance is not the large kernel itself, but the processing of multi-scale information.
[0065] Table 2 shows the branch ablation results in MSDM.
[0066] 3.3 Optimizer and Training Cycle Ablation AdamW's advantage over SGD lies in its adaptive learning rate and stronger weight decay handling, which generally leads to faster and more stable convergence (see Table 3). To explore the impact of the optimizer and maximum training epochs, experiments were conducted to vary these parameters. The results show that mAP increases with increasing max_epochs, with the baseline model increasing by 2.2% at 500 epochs and by 5.7% at 1000 epochs. The model using SGD improved by 2.7% and 7.2%, respectively, while the model using AdamW improved by 2.5% and 8.4%, respectively, indicating that AdamW performs better over longer training periods. Figure 3 The variations in learning rate and loss function are described for different optimizers and training durations, where, Figure 3 In the example (a), the training process is repeated 300 times. Figure 3 (b) in the example represents training that has been iterated for 500 times. Figure 3 In the diagram, (c) represents training for 1000 iterations. Compared to SGD, AdamW shows lower loss after 1000 iterations.
[0067] Table 3 Ablation results for different optimizers and training cycles. ; The baseline model is YOLOv8-s, and SGD_X and AdamW_X represent the two optimizers used in this model, respectively. Results show that the learning rate curves of the baseline model and the SGD model are the same, while AdamW has a lower loss when maxepochs=1000. These ablation studies validate the rationality of the selected experimental settings and optimization strategies, and demonstrate the good detection performance of the new algorithm.
[0068] 3.4 Comparative Experiment To further verify the superior performance of this improved model method, comparative experiments were conducted with state-of-the-art (SOTA) object detection algorithms, involving both one-stage and two-stage detection models. These included two-stage methods such as Faster R-CNN, Sparse R-CNN, and Cascade R-CNN, as well as one-stage models such as SSD, EfficientDet, ood, DDOD, YOLOv5, YOLOv6, YOLOv7, and YOLOv8. The comparison results are shown below. Figure 4 Tables 4 and 5.
[0069] Table 4 Comparison of Results Between Each Model and the SOTA Model
[0070] Table 5. Comparison of parameters between each model and the SOTA model.
[0071] The results show that the improved model method achieved a mean accuracy (mAP) of 82.4%, significantly outperforming all other models. The higher mAP value indicates that the method can more accurately locate and identify targets in images. In the accuracy analysis at an IoU threshold of 0.5 (AP50), the improved model achieved an accuracy of 99.4%, indicating good applicability at medium IoU thresholds. Accuracy decreased slightly at a higher IoU threshold of 0.75 (AP75), but still reached 89.5%, demonstrating that the improved model maintains high accuracy even under more stringent conditions, meeting detection requirements. Furthermore, in terms of AP for medium-sized objects (APM) and large objects (APL), the improved model achieved accuracies of 74.9% and 86.5%, respectively, demonstrating robustness across different object scales and enhancing its flexibility and applicability in various detection tasks, such as tobacco impurity detection.
[0072] The improved model achieved the lowest recall rate (37.1%) under extreme detection conditions, indicating that it can still capture targets partially effectively even under stringent conditions. With a normal detection count of 100 (AR100), the recall rate reached 86.6%, meaning most targets were accurately identified. This high recall rate ensures that important targets are not missed, providing greater safety and reliability in addressing the challenges of impurity detection.
[0073] Based on the above-described preferred embodiments of the present invention, and through the foregoing description, those skilled in the art can make various changes and modifications without departing from the inventive concept. The technical scope of this invention is not limited to the contents of the specification, but must be determined according to the scope of the claims.
Claims
1. A rapid detection system for minute impurities in reconstituted stem fibers, characterized in that, include: Image acquisition unit, used to acquire RGB images containing reconstructed filaments; The model processing unit incorporates an improved YOLOv8 detection model, which includes a backbone network, a neck network, and a head network. The initial layer of the backbone network is a large-kernel backbone layer, employing ConvModule modules with a 31×31 convolutional kernel size. Each ConvModule module sequentially includes Conv2d, BatchNorm2d, and SiLU activation functions. Each stage layer of the backbone network embeds a multi-scale downsampling module (MSDM), and each stage layer integrates a coordinated attention module (CA) at its tail. The CA module encodes horizontal and vertical positional information and enhances features in the feature map, while the MSDM module extracts multi-scale features of small impurities in the reconstructed filaments. The neck network uses a feature pyramid structure (FPN), and the head network outputs the impurity category, bounding box, and confidence score. The result output unit is used to receive the detection results from the model processing unit and visualize the location and category information of tiny impurities in the reconstructed filaments.
2. The rapid detection system for minute impurities in reconstituted stems according to claim 1, characterized in that, The multi-scale downsampling module MSDM extracts multi-scale features of minute impurities in the reconstructed filaments, and its implementation process is as follows: Large kernel downsampling convolution: A large kernel convolution operation is performed on the input feature map, and the feature mapping relationship is as follows: ; In the formula, F out ( i , j ) is the convolution output feature map at position ( i , j The eigenvalue at position ) F in The input feature map is used for convolution. K ( m,n ) represents the weight value of the convolution kernel at position (m,n). m、n The coordinate indices within the convolution kernel, 2 m 2 n This indicates the input feature map index offset caused by the downsampling step size; Multi-pooling feature extraction: Max pooling and average pooling are performed on the input feature map, where max pooling is used to highlight the significant features of impurities. The feature mapping relationship is as follows: ; Average pooling is used to smooth background noise, and the feature mapping relationship is as follows: ; In the formula, P max ( i , j ) represents the max-pooling output feature value. P avg ( i , j ) represents the average pooling output feature value. W The window for pooling operations has a size of 2×2, where |W| is the total number of pixels within the window. a , b The coordinate indicators within the window; Multi-scale feature fusion: outputting feature maps from large-kernel convolution. F conv With pooling output feature map P max , P avg After concatenation, the number of channels is adjusted to the target size using a 1×1 convolution, and the fused features are output. The feature mapping relationship is as follows: ,and ; In the formula, F conv This is the output feature map of the large kernel downsampling convolution. Concat () represents the feature map channel dimension concatenation operation. Conv 1×1 () represents a 1×1 convolution operation. F final for MSDM The final output feature map, MSDM ( F in )express MSDM The module processes the input feature map. F in The comprehensive processing function.
3. The rapid detection system for minute impurities in reconstituted stems according to claim 2, characterized in that, The workflow of the Coordination Attention Module (CA) includes: S11: Perform global average pooling in the horizontal dimension and global average pooling in the vertical dimension on the input feature map F to obtain the horizontal compressed feature map Fh and the vertical compressed feature map Fv, specifically: ; ; S12: Input Fh and Fv into a shared multilayer perceptron (MLP), which contains one hidden layer and one output layer. The output is processed by a sigmoid activation function to obtain a horizontal attention map Ah and a vertical attention map Av, specifically: ; ; In the formula, σ represents the sigmoid activation function, which scales the output of the MLP to the range of 0 to 1, representing the importance of each spatial dimension in different channels; S13: Add Ah and Av in their respective spatial dimensions, then perform element-wise multiplication with the original input feature map F to obtain the enhanced feature map. F enhanced Specifically: 。 4. The rapid detection system for minute impurities in reconstituted stems according to claim 3, characterized in that, The backbone network consists of four Stage layers, namely StageLayer1, StageLayer2, StageLayer3, and StageLayer4. The StageLayer1 embeds the first MSDM, with an input feature map size of 320×320×32 and an output feature map size of 160×160×64; The StageLayer2 embeds a second MSDM, and the output feature map size is 80×80×128; The StageLayer3 embeds a third MSDM, and the output feature map size is 40×40×256; The StageLayer4 embeds a fourth MSDM, and the output feature map size is 20×20×512.
5. The rapid detection system for minute impurities in reconstituted stems according to claim 4, characterized in that, The neck network adopts an FPN+PAN structure, which performs cross-scale fusion of the 40×40×256, 80×80×128, and 20×20×512 feature maps output by the backbone network, and outputs feature maps of three scales for head network detection.
6. A rapid detection method for minute impurities in reconstituted stem fibers, characterized in that, The rapid detection system for minute impurities in reconstituted stems according to any one of claims 1-5 includes the following steps: Step S1: Prepare the reconstructed stem impurity dataset: Collect a large number of RGB images containing 6 typical impurities and manually annotate them to generate a dataset containing impurity bounding boxes and category labels; divide the dataset into training set and test set in a ratio of 85%:15%; the 6 impurities are black rubber block, blue plastic sheet, white paper scrap, white plastic sheet, pink rubber and green paint block; Step S2: Constructing an improved YOLOv8 detection model: The initial layer of the backbone network of the improved YOLOv8 detection model is a 31-stem module with 31×31 convolutional kernels. Each stage layer of the backbone network embeds a multi-scale downsampling module MSDM, and each stage layer integrates a coordinated attention module CA at its tail. Step S3: Using AdamW as the optimizer, train the improved YOLOv8 detection model using the training set, and adopt a linear learning rate adjustment strategy during the training process; after each round of training, calculate the average accuracy AP and average recall AR of the model on the validation set to obtain the optimal algorithm model. Step S4: Input the RGB image of the reconstructed filament to be detected into the trained improved YOLOv8 detection model, and output the impurity category, bounding box and confidence score to complete the detection of small impurities.
7. The rapid detection method for minute impurities in reconstituted stems according to claim 6, characterized in that, In step S1, each label box contains the coordinates of the upper left corner (x1, y1) and the coordinates of the lower right corner (x2, y2). The category labels are numerically encoded, corresponding to the six types of impurities.
8. The rapid detection method for minute impurities in reconstituted stems according to claim 6, characterized in that, In step S3, the average accuracy AP of the model is calculated on the validation set, specifically as follows: First, calculate precision and recall: ; ; Wherein, TP is the true positive number, which is the number of positive samples correctly identified by the detection model; FP is the false positive number, which is the number of negative samples that the detection model incorrectly identified as positive samples; and FN is the false negative number, which is the number of positive samples that the detection model failed to identify. Next, plot the precision-recall curve and calculate the mean precision (AP), which is the area under the curve: ; And the interpolation accuracy P interp satisfy: ; in, r n , r n+1 For adjacent values of recall, For recall rate Corresponding precision; Define the matching relationship between the predicted object and the real object as the Intersection over Union (IoU), which satisfies: ; Where Area(Overlap) is the area of the overlapping region between the predicted bounding box and the ground truth bounding box, and Area(Box1∪Box2) is the area of the union region of the two bounding boxes; Calculate the average precision mAP, which is the average of the AP values for each IoU threshold from 0.5 to 0.95, incremented by 0.05, for a total of 10 thresholds. Then: 。 9. The rapid detection method for minute impurities in reconstituted stems according to claim 6, characterized in that, In step S3, the average recall rate (AR) is calculated as follows: ; in, o Let R(o) be the intersection-union ratio (IoU). o The corresponding recall rate.
10. The rapid detection method for minute impurities in reconstituted stems according to claim 6, characterized in that, In step S3, the optimizer's basic learning rate is set to 0.001, the weight decay parameter to 0.05, and the optimizer momentum to 0.9; the linear learning rate adjustment strategy satisfies the following formula: ; Where e is the current training epoch number, and max is the total number of training epochs. epochs =1000, minimum retention factor of learning rate lr factor =0.01, initial learning rate base lr =0.001.