Improved YOLOv11-based cigarette carton specification target detection method and system
By improving the YOLOv11 model, the problems of accuracy and real-time identification of cigarette pack specifications in the automated warehouse of cigarette factories were solved, realizing efficient detection of cigarette pack specifications, which is suitable for intelligent inventory in industrial automated warehouses.
Patent Information
- Application Number
- CN202511107736.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-07
- Publication Date
- 2025-11-25
AI Technical Summary
Existing intelligent inventory technology has difficulty effectively identifying cigarette packs and specifications in automated warehouses of cigarette factories, especially under conditions of changing lighting, occlusion, and large differences in features. The accuracy of identification is low, and traditional methods cannot meet the requirements of real-time operation.
An improved YOLOv11 model is adopted, replacing the standard convolutional downsampling module with the ADown module, introducing the iEMA attention module and the DynamicHead detection head, and combining specific region copy-paste data augmentation technology to optimize the model's feature fusion and detection performance.
It improved the accuracy of identifying cigarette brands, reduced the false negative rate, enhanced the robustness of the model in complex scenarios, met the needs of real-time detection, improved detection accuracy by 0.9%, reduced the number of parameters by 28.78%, and achieved a frame rate of 38.5 frames per second.
Smart Images

Figure CN121010753A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of tobacco inspection systems, and in particular to a method and system for detecting the specifications of cigarette packs based on an improved YOLOv11. Background Technology
[0002] In recent years, with the rapid development of industrial automation, automated storage and retrieval systems (AS / RS), with their high efficiency and intelligence, are gradually becoming an important means for enterprises to improve warehousing efficiency and reduce costs. An AS / RS is a computer-controlled mechatronics system. High-rise racks are its main body, and various loading and unloading equipment are its foundation. It integrates multiple technologies such as mechanics, electronics, computers, communications, networks, sensors, and automatic control, and realizes microcomputer-based, mechanized loading and unloading, and networked information management. Through the integration and optimization of racks, stacker cranes, conveyor lines, control systems, and other equipment, it achieves efficient, accurate, and safe storage and handling of goods, greatly improving warehousing efficiency.
[0003] While automated storage and retrieval systems (AS / RS) in cigarette factories have improved the storage capacity and warehousing efficiency of finished cigarette cartons, effective inventory counting has become a challenge in practical applications. Traditional manual inventory counting methods suffer from low efficiency, high false detection rates, and safety hazards, making them unsuitable for the needs of AS / RS. With the continuous development of computer vision technology, existing machine vision solutions are increasingly widely used in industrial inspection. The AS / RS in cigarette factories utilizes a multi-agent scheduling and positioning operation management approach to address the comprehensive issues of machine positioning and job scheduling. This method enables stacker cranes to operate accurately and efficiently. Furthermore, the high-quality printing on cigarette packaging, with unique patterns and text printed on each type of pack, and the ability to mount cameras and other equipment on the stacker crane's loading platform, all contribute to the image acquisition and identification of cigarette pack specifications. Through machine vision image recognition technology, relying on artificial intelligence visual algorithms, the identification and inventory of cigarette pack specifications can be achieved without any processing of the finished cigarette cartons. This technology features high accuracy in identification and detection, fast inventory speed, and strong environmental adaptability. It reduces manual intervention, improves the automation level of inventory in automated warehouses, realizes automated identification and intelligent inventory of cigarette packs, and promotes the intelligent transformation of tobacco industry warehouse management.
[0004] Using machine vision technology for intelligent inventory management, a common computer vision task is object detection, which aims to accurately identify and locate multiple objects from images or videos. Since 2012, deep learning-based object detection algorithms have made significant breakthroughs, from early two-stage detection algorithms like R-CNN to the current mainstream one-stage detection algorithms like YOLO, all of which have made significant contributions to the development of object detection algorithms. While two-stage object detection algorithms have high detection accuracy, their detection speed is relatively slow and the detection time is long, making it difficult to meet the real-time requirements of industrial scenarios. The YOLO series of algorithms transforms the object detection task into a regression problem, predicting the target location and its related features directly from the input image, achieving real-time object detection. Its detection speed exceeds that of most two-stage algorithms, and it has great potential for optimization in terms of detection speed and model complexity.
[0005] YOLOv11, the latest version of the YOLO series released by Ultralytics in 2024, inherits the advantages of YOLOv8 and makes improvements on that basis. It reduces the number of model parameters and better balances the relationship between detection efficiency and accuracy. The detection accuracy and speed have been significantly improved compared with previous object detection methods, and it performs outstandingly in a variety of visual processing tasks.
[0006] Existing advancements in intelligent inventory management and cigarette box recognition have several limitations and are not suitable for intelligent inventory management of cigarette cartons in automated warehouses of cigarette factories. These limitations stem from factors such as varying lighting conditions, differences in the size of various cigarette box features, partial occlusion between cigarette boxes, and the large number and uneven distribution of data in the collected datasets. Summary of the Invention
[0007] The purpose of this invention is to overcome the shortcomings of the existing technology and provide a method and system for detecting cigarette product specifications based on the improved YOLOv11.
[0008] To achieve the above objectives, the technical solution adopted by the present invention is as follows:
[0009] A method for detecting the quality and specifications of cigarette packs based on an improved YOLOv11 includes the following steps:
[0010] (1) Construct a tobacco product specification dataset: Collect images of tobacco boxes of different specifications in an automated warehouse using industrial cameras, and enhance a few categories of samples using a copy-paste technique based on specific regions;
[0011] (2) The improved YOLOv11n model is used for training, and the model includes:
[0012] In the backbone network and feature fusion network, the ADown module is used to replace the standard convolutional downsampling module. The ADown module realizes feature fusion through a dual-branch structure, including a 3×3 convolutional branch after channel segmentation and a max pooling + 1×1 convolutional branch.
[0013] An iEMA attention module is embedded in the feature fusion network. This module integrates an efficient multi-scale attention mechanism (EMA) through an inverted residual structure.
[0014] The DynamicHead detection head is used, which includes a scale-aware attention module (πL), a spatial awareness attention module (πS), and a task-aware attention module (πC).
[0015] (3) Deploy the trained model to the stacker crane loading platform vision system to detect cigarette box specifications in real time and verify the matching with the system task.
[0016] Furthermore, the region-specific copy-paste technique in step (1) includes:
[0017] a. Use the Segment Anything Model (SAM) to segment the cigarette box features of the category to be enhanced;
[0018] b. Generate the maximum mask region of the background image using a pre-trained YOLOv11-Seg model;
[0019] c. Adapt the segmentation features to the shape of the mask region and paste them onto the background image to generate a non-overlapping composite image.
[0020] Furthermore, the operation of the ADown module includes:
[0021] The input feature map is split into two subsets along the channel dimension;
[0022] Branch 1 performs a 3×3 convolution with a stride of 2;
[0023] Branch 2 executes max pooling with a stride of 2 and 1×1 convolution with a stride of 1 in sequence;
[0024] The output characteristics of the two branches are integrated.
[0025] Furthermore, the iEMA module achieves multi-scale attention enhancement through the following structure:
[0026] An EMA branch is embedded in the inverted residual block (iRMB); the EMA branch performs grouped convolutions and cross-dimensional interactions to generate a spatial attention map.
[0027] Furthermore, the computational process of the DynamicHead detection head satisfies:
[0028] WL (F)=π C {π S [π L (F)·F]·F}·F
[0029] Where πL, πS, and πC correspond to scale, space, and task-aware attention functions, respectively.
[0030] Furthermore, step (1) also includes applying conventional data augmentation operations to the augmented dataset, including at least one of rotation, noise addition, brightness adjustment, occlusion simulation, and contrast transformation.
[0031] Furthermore, the validation method for the improved YOLOv11n model trained by the above method includes the following performance evaluation steps:
[0032] (a) Calculate the mean with average precision (mAP):
[0033]
[0034] Where N is the total number of cigarette product categories, AP i The average precision of the i-th category;
[0035] (b) Calculate the average precision (AP) for each class.
[0036]
[0037] P i R represents the precision value when the threshold is i; i This is the recall value when the threshold is i;
[0038] (c) Measurement of inference speed (FPS): Count the number of frames of test set images processed per second.
[0039] A cigarette pack specification target detection system based on an improved YOLOv11 includes:
[0040] Industrial cameras deployed on the stacker crane's loading platform are used to acquire real-time images of the smoke boxes;
[0041] The processing unit loads the improved YOLOv11n model trained by the method described in any one of claims 1-6;
[0042] The verification module matches and verifies the product specification identification results output by the model with the system's stored tasks, and marks mixed-brand anomalies.
[0043] Furthermore, the number of parameters in the improved YOLOv11n model is ≤1.85×10⁻⁶. 6 Inference speed ≥ 38.5 frames / second.
[0044] Furthermore, the logic for the verification module to perform mixed-card detection includes:
[0045] a. Receive real-time images of the stacker crane's cargo platform and the expected product specification codes from system task instructions;
[0046] b. Identify the product type of all cigarette boxes in the image and perform the following operations:
[0047] -If the identified product specification matches the expected code: save the product specification information, location coordinates and detection time of the cigarette box to the inventory database to complete the real-time inventory count;
[0048] -If the identified product specification does not match the expected code: immediately trigger an audible and visual alarm, and record the product specification information, coordinates and timestamp of the abnormal cigarette box to the abnormal log;
[0049] c. When mixed product specifications are detected continuously at the same coordinate, a stop operation command is sent to the central control system.
[0050] The beneficial effects of this invention are as follows: 1. Breakthrough recognition accuracy: By retaining key details such as edge texture and brand logo of cigarette boxes through the ADown module (especially solving the problem of small-sized cigarette boxes), and combining with the iEMA attention mechanism to enhance the feature capture capability of occluded targets, the model achieves mAP of 97.9% in complex scenes such as uneven lighting and partial occlusion (0.9% improvement over the original YOLOv11n), and the false negative rate is reduced to a new low in the industry.
[0051] 2. Precise multi-scale target localization: The DynamicHead detection head adopts a triple perception mechanism of scale, space, and task to adaptively fuse features of cigarette boxes of different sizes, reducing the localization error rate by 42%.
[0052] 3. The ADown module adopts a grouped convolution + dual-branch fusion architecture to reduce redundant channel calculations; DynamicHead replaces traditional convolution with an attention mechanism, resulting in a final model with only 1.84 million parameters (compared to 2.59 million in the original model), laying the foundation for industrial-side deployment.
[0053] In the backbone and neck network of YOLOv11n, an adaptive downsampling module is used instead of a downsampling convolution module, effectively preserving more feature details and achieving model lightweighting. Secondly, the iEMA efficient multi-scale attention module is introduced to efficiently capture spatial context information at different scales, generating more accurate spatial attention maps and effectively improving the model's prediction accuracy for complex features and occlusion recognition. Finally, we use a DynamicHead dynamic detection head to replace the original model's detection head, performing multi-scale object detection on the feature maps extracted by the backbone and neck networks, achieving accurate localization and classification of predicted targets. To test the performance of the improved algorithm in real-world applications, this application constructs a visual cigarette pack specification dataset, performing data augmentation based on copy-paste of specific regions and traditional augmentation. The resulting dataset includes factors such as complex backgrounds, occlusion and overlap, and small targets. Experimental verification shows that the detection accuracy of the improved algorithm is improved by 0.9% compared to the original algorithm, reaching 97.9%, while reducing the number of parameters by 28.78% and the number of floating-point operations by 1.4G. Simultaneously, the frame rate of this improved algorithm reaches 38.5 frames / s, meeting the requirements for real-time detection. Attached Figure Description
[0054] Figure 1 This is a data graph collected by the data acquisition platform of this invention.
[0055] Figure 2 This forms the overall framework of the present invention based on copy-paste data enhancement technology for specific regions.
[0056] Figure 3 This is a structural diagram of the Adown module of the present invention.
[0057] Figure 4 This is a structural diagram of the iEMA module of the present invention.
[0058] Figure 5 This is a structural diagram of the DynamicHead detection head module of the present invention.
[0059] Figure 6 The diagram shows the improved YOLOv11 network structure for this invention.
[0060] Figure 7 This is a graph showing the detection results of the improved YOLOv11n according to the present invention. Detailed Implementation
[0061] A method for detecting the quality and specifications of cigarette packs based on an improved YOLOv11 includes the following steps:
[0062] 1. Data was collected from the automated warehouse of the Longyan Cigarette Factory to create a dedicated dataset. A data augmentation technique based on copying and pasting specific regions was then used to augment the fewer class samples, effectively alleviating the class imbalance problem. Traditional data augmentation methods were then used to expand the dataset and improve its generalization performance.
[0063] 2. The ADown downsampling module is used to replace the downsampling convolution modules in the backbone and neck networks. This retains more detailed information, reduces the model's weight, and improves the robustness of the downsampling features.
[0064] 3. An iEMA attention module is inserted into the neck network. Its inverted residual structure combined with an efficient multi-scale attention mechanism further optimizes the model's capture of details of small targets and significantly improves the detection accuracy of small target features.
[0065] 4. Using the DynamicHead detection head, multi-scale target detection is performed on the feature maps extracted from the backbone and neck network. This enables accurate localization of predicted targets, classification of targets, and evaluation of the accuracy of predicted bounding boxes.
[0066] In computer vision tasks, constructing dedicated detection datasets is crucial to the detection performance and application effectiveness of models. Object detection tasks not only require identifying and classifying target objects in images but also accurately determining their locations. Dedicated detection datasets can best reproduce real-world detection scenarios. Using dedicated datasets during training can improve the model's detection accuracy under real-world conditions and reduce false positives and false negatives in practical applications. Furthermore, object detection tasks require accurate bounding box annotations. Dedicated object detection datasets are typically created through manual annotation, ensuring the accuracy and consistency of the annotations.
[0067] The dataset used in this paper comes from the automated warehouse of the logistics department of Longyan Cigarette Factory. Based on the process of goods entering and leaving the warehouse, industrial cameras and triggered image capture technology were used to collect 4835 images, such as... Figure 1 As shown, the images contain 38 different types of cigarette boxes, including red-packaged, soft gray, and Gutian varieties. Because the data was collected during the goods' entry and exit from the warehouse, the number of cigarette boxes for each category varies significantly in the collected images; some categories even have only one image. Therefore, data augmentation is necessary.
[0068] Data augmentation is a technique that uses existing training datasets to artificially create new samples, and it is a common method in image processing. Its core idea is to generate new data that is semantically similar to the original data but differs in form by performing a series of reasonable and targeted transformations (or perturbations) on the original data. Current data augmentation techniques used in object detection include basic data augmentation, such as brightness adjustment, contrast adjustment, rotation, scaling, cropping, adding noise, and adding occlusion, as well as advanced augmentation techniques such as MixUp, Mosaic, and RandAug.
[0069] Copy and paste ] It is a data augmentation technique for individual segmentation. It enhances data by pasting objects from a real image onto different background images that have undergone various transformations (cropping, resizing, and rotation). It is random and the objects in the resulting augmented images overlap and occlude severely.
[0070] YOLOv11-Seg is a YOLO series component specifically designed for real-time instance segmentation tasks. While maintaining the high inference speed of the YOLO family, it achieves pixel-level accurate object detection and segmentation through innovative network structure and segmentation head design. Its core design is optimized for efficient segmentation tasks, while also considering detection and mask generation capabilities, making it suitable for scenarios with stringent requirements for accuracy and speed, such as industrial inspection.
[0071] Segment Anything Model (SAM) is a pre-trained image segmentation model that supports precise localization and segmentation of target objects using cues such as points, boxes, or text. It is designed for efficient image segmentation, particularly accurate object segmentation. SAM utilizes large-scale training data, enabling it to excel in image segmentation tasks. It can identify and segment objects in various complex scenes, and even for some unseen objects, it can achieve relatively accurate segmentation through the model's learned experience.
[0072] To ensure a relative balance in the number of various cigarette boxes in the dataset, data augmentation techniques are needed to compensate for its deficiencies. We selected and improved upon a region-specific copy-and-paste data augmentation technique. The overall framework of the data augmentation techniques presented in this paper is as follows: Figure 2 As shown, the goal is to enhance the detection categories in the dataset that are too few in number by leveraging segmentation annotations generated by an instance segmentation model, and then use an algorithm to create synthetic images based on these segmentation annotations.
[0073] The copy-paste data augmentation technique based on a specific region used in this paper follows these steps: First, SAM is used to segment the image of the category to be augmented, obtaining its corresponding category features. Second, a YOLOv11-Seg instance segmentation model pre-trained on a self-made dataset is used to generate a segmentation mask for the background image. Then, the curves at the edges of the segmentation mask are fitted to straight lines, and the shape of the segmented feature image is adjusted to the shape of a specific region of the mask using an algorithm. Finally, the segmented category features are pasted onto a specific region (the maximum mask region) of the target background image to obtain an augmented image without object overlap. Ultimately, this technique yielded 600 augmented images, bridging the gap in the number of images for each category.
[0074] Meanwhile, in order to enhance the generalization performance of the dataset, traditional data augmentation methods, such as rotation, adding noise, adjusting brightness, adding occlusion, and adjusting contrast, were combined with this technique, resulting in a final dataset of 6602 images.
[0075] YOLOv11 is the latest model in the YOLO series launched by Ultralytics in 2024. It supports multiple computer vision tasks such as object detection, semantic segmentation, and pose estimation. Through several architectural innovations, it has achieved breakthroughs in the accuracy, speed, and versatility of object detection.
[0076] Compared to the YOLOv8 model from Ultralytics, the YOLOv11 model offers the following improvements. It introduces the C3k2 module, which dynamically switches the bottleneck structure via the C3k parameter, dynamically switching between multi-branch convolutions (grouped convolutions + multi-scale convolution kernels) and the standard residual structure. Compared to YOLOv8's C2f module, this reduces the number of parameters by 15% while increasing inference speed by 10%. Simultaneously, it integrates the C2PSA module (cross-level pyramid slice attention) in the Neck part, combined with Pointwise Spatial Attention (PSA). Through multi-branch structures (local branches, large receptive field branches, and global branches), it enhances feature selection capabilities, helping the model focus its attention on key parts of the image, thereby improving detection accuracy and efficiency, and further enhancing its performance in complex scenes. Furthermore, YOLOv11 adds two depthwise convolutions (DW-Conv) to the detection head. These DW-Convs process each input channel individually, meaning each channel has its own kernel for convolution, without interaction with other channels. This focuses on spatial convolution operations, significantly reducing the model's parameter count and computational cost. Through these optimizations, it surpasses previous versions in both detection speed and accuracy, making it ideal for object detection tasks that prioritize both accuracy and efficiency.
[0077] Target detection of cigarette cartons is a crucial component of intelligent inventory management in automated warehouses of cigarette factories, and its accuracy and efficiency directly impact the accuracy of stacker crane retrieval. However, in real-world industrial scenarios, target detection of cigarette cartons faces numerous challenges, such as the variety of image types, significant differences in feature sizes across different categories, uneven lighting, and occlusion in some cigarette cartons. These issues make it difficult for traditional detection methods to meet the requirements of high accuracy and robustness. In recent years, optimized algorithms for target detection have been developed...
[33] Significant progress has been made in the field of industrial inspection, with YOLOv11 becoming a research hotspot due to its high detection speed, high accuracy, and multi-task processing capabilities. However, for the specific needs of cigarette pack specification inspection, YOLOv11 still has certain limitations in target localization and detection in complex environments. Therefore, this paper proposes an improved YOLOv11 cigarette pack specification inspection model. This model improves its detection performance by optimizing the backbone network, introducing a small target detection attention mechanism, and replacing the detection head. This enables intelligent inventory tasks to accurately identify image features, achieve accurate verification of information and physical goods during stacker crane retrieval, and promptly detect potential information errors during stacker crane retrieval, preventing large-scale information errors or mixed-label quality accidents in subsequent operations.
[0078] The YOLOv11 model uses the CBS (Conv-BN-SiLU) module for downsampling, which undertakes the core tasks of spatial size compression and feature extraction in the backbone network. It is concise and efficient, balancing efficiency and generalization, but it suffers from potential information loss. To address the balance between feature information preservation and computational efficiency, this paper replaces the CBS convolutional downsampling module with the Adown (Adaptive Downsampling) module. The ADown module employs an innovative feature extraction and spatial dimension compression technique with strong information preservation capabilities. Through a dual-branch structure, it fuses multi-scale features, reducing spatial resolution while retaining richer details. Furthermore, its grouped convolutions reduce redundant computation between channels, achieving model lightweighting and improving the robustness of downsampled features.
[0079] The ADown module employs a dual-branch collaborative processing approach for adaptive downsampling, achieving feature information fusion and extraction. Its structure is as follows: Figure 3As shown. In the channel segmentation part, the input feature map is divided into two subsets along the channel dimension to avoid information overload caused by processing all features in a single path. Branch 1 focuses on spatial detail preservation, using a 3×3 convolutional kernel and a convolution with a stride of 2 to compress the feature map size, capturing local detail features and preserving high-frequency details, making it more sensitive to small object detection. Branch 2 focuses on semantic context extraction, using a max pooling layer with a stride of 2 and a convolutional layer with a stride of 1 to compress the feature map size and extract spatial correlation features. Then, feature concatenation is performed to fuse local details and global context, constructing a multi-scale feature representation and enhancing feature diversity.
[0080] Because the feature sizes of cigarette images vary, recognizing features that are too small is prone to errors, and some features are incomplete due to occlusion, leading to high uncertainty in feature recognition. Therefore, this paper integrates an iEMA attention module into the YOLOv11 model, enabling the model to better focus on small targets and occluded features.
[0081] iEMA (Efficient Inverted Attention Module) is an innovative, lightweight attention mechanism that combines the core design of Inverted Residual Blocks (iRMB) with dynamic multi-scale modeling capabilities. It eliminates the limitations of iRMB's native coupling with specific attention mechanisms, introducing a plug-and-play EMA (Efficient Multi-Scale Attention) branch, forming a dual-path collaborative structure of local perception and global modeling. iRMB is a hybrid network module that combines depthwise separable convolutions (3x3 DW-Conv) and a self-attention mechanism. 1x1 convolutions are used for channel compression and expansion to optimize computational efficiency, DW-Conv captures spatial features, and the attention mechanism captures global dependencies between features. EMA is an efficient multi-scale attention module designed to simultaneously reduce computational overhead and preserve key information in each channel. It leverages cross-dimensional interactions to capture multi-scale spatial contextual information, generating more accurate spatial attention maps. Simultaneously, it controls computational overhead through grouping and parallel design, enhancing feature representation capabilities and significantly improving model performance.
[0082] The essence of the iEMA module is to cleverly embed the EMA attention mechanism as a core component into the inverse residual structure framework of iRMB. It inherits the efficiency and residual connectivity advantages of iRMB, while introducing the powerful multi-scale spatial attention capabilities of EMA. The structure of the fused iEMA module is as follows: Figure 4 As shown.
[0083] The main function of the detection head module is to perform multi-scale target detection on the feature maps extracted from the backbone and neck network. It can achieve accurate localization of predicted targets, classify targets, and evaluate the accuracy of predicted bounding boxes. In the process of classifying cigarette brands, because the scale transformations of various target features in the image are different, and some images contain many bounding boxes, the detection of cigarette brands needs to consider different scales, textures, and other features simultaneously. This application uses the DynamicHead detection head.
[37] Replacing the basic detection head of the YOLOv11 model, it improves detection performance and efficiency by constructing a complete self-attention mechanism that unifies scale perception, spatial perception, and task perception. The framework structure of the DynamicHead detection head is as follows: Figure 5 As shown.
[0084] The key components of the DynamicHead module include a scale-aware attention module (πL), a spatially-aware attention module (πS), and a task-aware attention module (πC). The scale-aware attention module adjusts according to the scale of the features, allowing features of different scales to be fused and processed at an appropriate scale. It optimizes the impact of scale differences by assigning weights to features of different scales. The spatially-aware attention module optimizes for spatial location by weighting important regions in the feature map, enabling the network to focus more on the foreground region of the target object and avoiding the impact of redundant parts of the feature map on model performance. The task-aware attention module adjusts the head output according to the specific task. It can optimize the classification or regression results of the target according to the task requirements, improving the accuracy and robustness of the model. Its mathematical formula can be expressed as follows:
[0085] W L (F)=π C (π S [π L (F)·F]·F}·F (1)
[0086]
[0087] π C (F)·F=max[α 1 (F)·F c +β 1 (F),α 2 (F)·Fc+β 2 (F)] (4)
[0088] In the above formula, W L (F) is the attention function, π L (F), π S (F), π C(F) represents the attention in the scale, space, and task dimensions, respectively. f(·) is a linear function, σ(x) is the hard-sigmoid activation function; K is the number of sparse sampling locations, p k +Δp k It involves a positional offset to focus on the discriminative region, Δm k It is about position p k The self-learnable importance metric factor; α(F) and β(F) are hyperparameter functions used to learn activation threshold control.
[0089] After the improvements to the above modules, the final overall structure diagram of the improved YOLOv11 model is as follows: Figure 6 As shown.
[0090] The experimental results and analysis are as follows:
[0091] The experiments in this paper are based on the PyTorch deep learning framework, and the specific experimental environment is shown in Table 1.
[0092] Table 1Experimental Environment
[0093]
[0094]
[0095] This paper uses a self-made dataset containing 6602 images, randomly divided into training, validation, and test sets in a 7:2:1 ratio. The input image size for each experiment is 640×640 pixels, with an initial learning rate of 0.01 updated using stochastic gradient descent and a momentum of 0.937 to prevent overfitting. During training, Mosaic data augmentation is used, reading four images at a time to enrich the detection background. All models are trained for 100 epochs with a batch size of 4 and a worker count of 0.
[0096] Once an object detection task identifies an object, it makes a prediction. For multi-class classification tasks, the currently relevant sample is considered a positive sample, and the remaining samples are considered negative samples. TP represents the number of samples where the model predicts a positive result and the actual result is also positive; FP represents the number of samples where the model predicts a positive result and the actual result is negative; FN represents the number of samples where the model predicts a negative result and the actual result is positive; TN represents the number of samples where the model predicts a negative result and the actual result is negative. Based on this, various common evaluation metrics can be derived to comprehensively assess the model's performance in object detection tasks. The following are the core metrics based on the confusion matrix:
[0097] (1)Precision
[0098] Accuracy measures the proportion of actual positive samples among those predicted as positive by the model, reflecting the model's detection accuracy. The calculation formula is:
[0099]
[0100] (2) Recall rate
[0101] Recall measures the proportion of all true positive samples that are correctly detected by the model, reflecting the completeness of the model's detection. Its calculation formula is:
[0102]
[0103] (3) Average Precision (AP)
[0104] AP is the area under the precision-recall curve, used to evaluate the detection performance of a model on a single class. Its calculation formula is:
[0105]
[0106] In the formula, P i —Precision value when the threshold is i; R i —Recall rate when the threshold is i.
[0107] (4) Mean Average Precision (mAP)
[0108] mAP is the average AP across all classes, used to evaluate the overall performance of a model in multi-class object detection tasks. Its calculation formula is:
[0109]
[0110] In the formula, N represents the number of categories; AP i —AP of the i-th category.
[0111] (5) Recognition speed (FPS)
[0112] FPS is used to evaluate the inference speed of a model, that is, the number of image frames that can be identified and detected per second. It is calculated as follows: after the model is trained, the trained weight file is used to detect images on a pre-divided test set. The total processing time for one image is then used to calculate the number of image frames that can be processed per second.
[0113] To further verify the performance of the improved YOLOv11 model in the cigarette brand identification and detection task, it was compared with the mainstream one-stage detection algorithms YOLOv5s, YOLOv8n, YOLOv10n, and YOLOv11n, as well as the two-stage detection algorithm Faster-RCNN. All experiments were conducted under the same experimental environment, using the same dataset and data partitioning method to ensure the fairness and comparability of the results. The comparison results are shown in Table 2. The improved YOLOv11n model exhibits the best performance in key metrics such as mean precision, precision, and recall. Compared with the original YOLOv11n model, the improved model improves the mean precision from 97.0% to 97.9%, indicating a significant advantage in overall detection performance. Furthermore, the improved YOLOv11n model shows the best performance in terms of parameter count and computational cost. The lower model complexity reduces the risk of overfitting to the training data, thereby enhancing the model's generalization ability. This advantage also makes the model easier to deploy in real-world devices. This result demonstrates that the improved YOLOv11n model is more suitable for deployment in actual cigarette brand identification and detection scenarios, effectively improving detection accuracy and ensuring real-time detection. In conclusion, the improved YOLOv11n model exhibits stronger applicability and practicality in the cigarette brand identification and detection task presented in this study.
[0114] Table 2 Comparison of results from different detection models
[0115]
[0116] Ablation experiments: Ablation experiments are an experimental method that evaluates the contribution of certain components or modules to model performance by progressively removing or modifying them. To verify the impact of the added improved modules on the overall accuracy of the model and the impact of module fusion on performance, ablation experiments of three improved modules were conducted on the baseline model YOLOv11n using a self-made dataset. The experimental results are shown in Table 3.
[0117] Table 3 Ablation Experiment Results
[0118]
[0119]
[0120] As shown in Table 3, under the same experimental conditions, the improved YOLOv11n model achieved better detection results, with a 0.9% improvement in mAP compared to the original YOLOv11n model. Specifically, the accuracy improved by merging the ADown downsampling module alone by 0.5% compared to the original YOLOv11n model. This module employs a dual-branch collaborative processing approach for adaptive downsampling, fusing multi-scale features to retain richer details while reducing spatial resolution. Furthermore, its grouped convolutions reduce redundant computation between channels, achieving a lightweight model. The fusion of ADown and iEMA improved mAP by 0.6%, and the fusion of ADown and DynamicHead improved mAP by 0.8%, further validating the effectiveness of the ADown module in improving the model. Integrating the iEMA attention mechanism alone improved the mAP by 0.3% compared to the original YOLOv11n model. Integrating the DynamicHead detector alone improved the mAP by 0.6% compared to the original YOLOv11n model. The fusion of iEMA and DynamicHead improved the mAP by 0.6%. Although the mAP was not improved based on the DynamicHead improvement, the accuracy was improved by 1.1%, indicating that this module also has a certain improvement effect on the model. The fusion of these three modules improved the mAP by 0.9%, and effectively reduced the number of parameters and computational cost, reduced the model complexity, reduced the risk of overfitting to training data, and thus enhanced the model's generalization ability.
[0121] In summary, compared with the original YOLOv11 network, the improved and optimized YOLOv11 network achieved an overall detection mAP increase of 0.9%, reaching 97.9%. While reducing the number of parameters and computational load, the detection and recognition speed reached 38.46 frames per second, meeting the requirements of real-time detection and better adapting to the detection of cigarette cartons with diverse target categories and varying target feature sizes. This provides feasible technical and theoretical support for the identification and detection of cigarette pack specifications.
[0122] Figure 7 This paper presents the results of using the improved YOLOv11n model for cigarette pack specification detection. As shown in the figures, the model's bounding box accurately selects the feature regions of the cigarette packs and accurately identifies their categories, especially in detection tasks with incomplete image features and uneven lighting conditions. This result demonstrates that the improved YOLOv11n model has strong robustness and adaptability under occlusion and complex lighting conditions, effectively addressing challenges in real-world scenarios and providing reliable support for cigarette pack specification identification and detection.
[0123] To improve the detection performance of cigarette packs in intelligent inventory tasks, this paper proposes an improved YOLOv11n cigarette pack type recognition and detection algorithm. First, addressing the issue of severely uneven distribution of categories in the dataset, a data augmentation method based on copying and pasting specific regions is designed to improve the generalization performance of the dataset. Second, the ADown downsampling module replaces the downsampling convolutional modules in the backbone and neck network, effectively preserving more feature details. Then, the iEMA attention module is introduced to enhance the model's ability to detect small and occluded targets. Finally, the DynamicHead detection head replaces the original model's detection head, performing multi-scale target detection on the feature maps extracted from the backbone and neck network, achieving accurate target localization, target classification, and improved accuracy in evaluating prediction boxes.
[0124] Experiments show that, through these optimizations, the improved YOLOv11n model achieves an average accuracy increase of 0.9% compared to the original YOLOv11n model, reaching 97.9%. The frame rate reaches 38.5 frames / s, meeting the requirements for real-time detection; and with only 1,849,678 parameters, the algorithm is easier to deploy on devices.
[0125] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for detecting the specifications of cigarette packs based on an improved YOLOv11, characterized in that, Includes the following steps: (1) Construct a tobacco product specification dataset: Collect images of tobacco boxes of different specifications in an automated warehouse using industrial cameras, and enhance a few categories of samples using a copy-paste technique based on specific regions; (2) The model is trained using an improved YOLOv11 n model, which includes: In the backbone network and feature fusion network, the ADown module is used to replace the standard convolutional downsampling module. The ADown module realizes feature fusion through a dual-branch structure, including a 3×3 convolutional branch after channel segmentation and a max pooling + 1×1 convolutional branch. An iEMA attention module is embedded in the feature fusion network. This module integrates an efficient multi-scale attention mechanism (EMA) through an inverted residual structure. The DynamicHead detection head is adopted, which includes a scale-aware attention module πL, a spatial awareness attention module πS, and a task-aware attention module πC. (3) Deploy the trained model to the stacker crane loading platform vision system to detect cigarette box specifications in real time and verify the matching with the system task.
2. The method according to claim 1, characterized in that, The region-specific copy-paste technique in step (1) includes: a. Use the Segment Anything Model (SAM) to segment the cigarette box features of the category to be enhanced; b. Generate the maximum mask region of the background image using a pre-trained YOLOv11-Seg model; c. Adapt the segmentation features to the shape of the mask region and paste them onto the background image to generate a non-overlapping composite image.
3. The method according to claim 1, characterized in that, The operations of the ADown module include: The input feature map is split into two subsets along the channel dimension; Branch 1 performs a 3×3 convolution with a stride of 2; Branch 2 executes max pooling with a stride of 2 and 1×1 convolution with a stride of 1 in sequence; The output characteristics of the two branches are integrated.
4. The method according to claim 1, characterized in that, The iEMA module achieves multi-scale attention enhancement through the following structure: Embed EMA branches in the inverted residual block (iRMB); The EMA branch performs grouped convolutions and cross-dimensional interactions to generate a spatial attention map.
5. The method according to claim 1, characterized in that, The operation process of the DynamicHead detection head satisfies: W L (F)=π C {p} S [p L (F)·F]·F}·F Where πL, πS, and πC correspond to scale, space, and task-aware attention functions, respectively.
6. The method according to claim 1, characterized in that, Step (1) also includes applying conventional data augmentation operations to the augmented dataset, including at least one of rotation, noise addition, brightness adjustment, occlusion simulation, and contrast transformation.
7. The method according to claim 1, characterized in that, A verification method for the improved YOLOv11n model trained by any one of claims 1-6, comprising the following performance evaluation steps: (a) Calculate the mean with average precision (mAP): Where N is the total number of cigarette product categories, AP i The average precision of the i-th category; (b) Calculate the average precision (AP) for each class. P i R represents the precision value when the threshold is i; i This is the recall value when the threshold is i; (c) Measurement of inference speed (FPS): Count the number of frames of test set images processed per second.
8. A cigarette pack specification target detection system based on an improved YOLOv11, characterized in that, include: Industrial cameras deployed on the stacker crane's loading platform are used to acquire real-time images of the smoke boxes; The processing unit loads the improved YOLOv11 n model trained by the method described in any one of claims 1-6; The verification module matches and verifies the product specification identification results output by the model with the system's stored tasks, and marks mixed-brand anomalies.
9. The system according to claim 8, characterized in that, The number of parameters in the improved YOLOv11 n model is ≤1.85×10. 6 Inference speed ≥ 38.5 frames / second.
10. The system according to claim 8, characterized in that, The logic for performing mixed-card detection in the verification module includes: a. Receive real-time images of the stacker crane's cargo platform and the expected product specification codes from system task instructions; b. Identify the product type of all cigarette boxes in the image and perform the following operations: -If the identified product specification matches the expected code: save the product specification information, location coordinates and detection time of the cigarette box to the inventory database to complete the real-time inventory count; -If the identified product specification does not match the expected code: immediately trigger an audible and visual alarm, and record the product specification information, coordinates and timestamp of the abnormal cigarette box to the abnormal log; c. When mixed product specifications are detected continuously at the same coordinate, a stop operation command is sent to the central control system.
Citation Information
Cited By
Cigarette case specification identification method and device based on deep learning, and electronic equipment
CN121747083A
Automatic finished product bubble removing cooperative control method and system based on machine vision
CN122143411A
A method and apparatus for detecting multi-scale targets on unmanned aerial vehicles (UAVs).
CN122416325A
