Visual detection method for tobacco pests based on improved target detection model
By integrating a multi-scale feature perception and attention module into the YOLOv5 backbone network, the problem of insufficient utilization of feature information in tobacco insect detection in tobacco storage workshops is solved, and the accuracy of tobacco insect identification is improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA TOBACCO HENAN IND CO LTD
- Filing Date
- 2023-05-09
- Publication Date
- 2026-06-05
AI Technical Summary
Traditional YOLOv5 target detection networks struggle to extract sufficient information about tobacco insect targets in the complex environment of tobacco storage workshops, resulting in insufficient accuracy in tobacco insect identification.
A multi-scale feature-aware attention module is introduced into the backbone network of YOLOv5. By combining the context-aware pyramid feature extraction module and the channel attention module, the utilization of tobacco insect feature information is enhanced, focusing on high-level semantic features and low-level spatial structure features, and the feature channel relationship is guided by the attention mechanism.
It improves the reliability and accuracy of tobacco insect quantity and precision identification, thus enhancing the effectiveness of tobacco insect detection.
Smart Images

Figure CN116524305B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of cigarette manufacturing, and in particular to a visual detection method for tobacco insects based on an improved target detection model. Background Technology
[0002] Object detection is a crucial research topic in computer vision, primarily involving the classification and localization of objects in images. With the development of neural networks, breakthroughs have been achieved in object detection. Currently, neural network-based object detection methods are widely applied in various fields, such as video surveillance, autonomous driving, facial recognition, and defect detection. In the tobacco industry, there is also active exploration of the organic integration of object detection technology with tobacco production. For example, this invention focuses on the specific application scenario of using object detection to identify tobacco beetles (hereinafter referred to as tobacco beetles): Pests and diseases are a serious problem during tobacco storage and processing, and tobacco beetles are one of the most common pests. In particular, cigarette factory storage workshops require reliable detection of tobacco beetles to understand their numbers and facilitate timely control of infestations.
[0003] In practice, the traditional YOLOv5 was used as the detection network, whose structure consists of a backbone network, a neck network, and an output layer. The convolutional layers in the backbone network use 6×6 kernels with a stride S of 2 and padding P of 2. Compared to the focus structure in other networks, this not only avoids the loss of original information but also facilitates network derivation, thus significantly improving detection performance. However, in the complex environment of tobacco storage workshops, it was found that the traditional detection network struggles to extract effective information about tobacco insect targets, resulting in insufficient utilization of insect features during identification. Consequently, there is still considerable room for improvement in the accuracy of tobacco insect identification. Summary of the Invention
[0004] In view of the above, the present invention aims to provide a visual detection method for tobacco insects based on an improved target detection model, so as to solve the problem of insufficient utilization of the target feature information of tobacco insects.
[0005] The technical solution adopted in this invention is as follows:
[0006] This invention provides a visual detection method for tobacco insects based on an improved target detection model, including:
[0007] After preprocessing the pre-created tobacco worm dataset, it was divided into training set, validation set and test set;
[0008] A multi-scale feature perception and attention module is constructed based on the backbone network of the YOLOv5 object detection model.
[0009] Using the training set and the validation set, the YOLOv5 object detection model that incorporates the multi-scale feature perception attention module is trained to obtain the trained weights;
[0010] By selecting the optimal weights and using the test set as input images, the improved target detection model is used to detect the number and accuracy of tobacco insects.
[0011] In at least one of the possible implementations, the multi-scale feature-aware attention module is a feature enhancement network composed of a context-aware pyramid feature extraction module and a channel attention module connected in series.
[0012] In at least one possible implementation, the pyramid feature extraction module is constructed in the following ways:
[0013] We obtain the raw features output by the CSP layer in YOLOv5 and capture contextual information using convolutional layers with different dilation rates.
[0014] By cross-channel splicing, feature maps and dimensionality reduction features from different convolutional layers are combined to obtain features of different scales and context-aware information, and then upsampling is performed.
[0015] Feature fusion is performed again through cross-channel splicing to obtain multi-scale pyramid features as the output of the pyramid feature extraction module.
[0016] In at least one possible implementation, the channel attention module is constructed in the following ways:
[0017] The multi-scale pyramid features are compressed according to the spatial dimension to obtain the receptive field feature map.
[0018] Based on the receptive field feature map, the dependency relationship of each channel information is obtained, and the channel weights are obtained;
[0019] The channel weights are fused with the multi-scale pyramid features to obtain channel attention features;
[0020] The original features are added to the channel attention features to obtain the final features output by the multi-scale feature perception attention module.
[0021] In at least one possible implementation, the feature compression includes: converting each two-dimensional feature channel into a real number having a global receptive field.
[0022] In at least one possible implementation, obtaining the channel weights by acquiring the dependency relationship of each channel information based on the receptive field feature map includes: performing a first fully connected layer operation on the receptive field feature map, then performing a second fully connected layer operation after passing through a ReLU layer, and then obtaining the channel weights through a sigmoid function.
[0023] Compared to existing technologies, the main design concept of this invention lies in integrating a multi-scale feature perception attention module into the backbone network of the traditional YOLOv5 algorithm, targeting multi-scale high-order feature maps. This module focuses on effective high-level semantic features and low-level spatial structure features in tobacco insect image data, thereby obtaining contextual information about the tobacco insects to be identified. Furthermore, an attention mechanism is used as a guide for feature channel relationships to obtain more valuable low-level information about the tobacco insect target. Practical application has shown that this invention improves the reliability and accuracy of tobacco insect quantity and precision identification compared to traditional YOLOv5 target detection results. Attached Figure Description
[0024] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described below with reference to the accompanying drawings, wherein:
[0025] Figure 1 This is a flowchart illustrating the visual detection method for tobacco insects based on an improved target detection model provided in an embodiment of the present invention.
[0026] Figure 2 A structural diagram of the context-aware pyramid feature extraction module provided in an embodiment of the present invention;
[0027] Figure 3 A schematic diagram of the overall network structure of the improved YOLOv5 provided in this embodiment of the invention;
[0028] Figure 4a This is a schematic diagram illustrating the detection performance of a traditional object detection network.
[0029] Figure 4b This is a schematic diagram illustrating the detection effect of the improved network provided in an embodiment of the present invention. Detailed Implementation
[0030] Embodiments of the present invention are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.
[0031] This invention proposes an embodiment of a visual detection method for tobacco insects based on an improved target detection model. Specifically, as follows: Figure 1 As shown, it includes:
[0032] Step S1: After preprocessing the pre-created tobacco worm dataset, divide it into training set, validation set and test set;
[0033] Step S2: Construct a multi-scale feature perception attention module based on the backbone network of the YOLOv5 object detection model;
[0034] The core objective of this step is to improve the original YOLOv5 algorithm to enhance information about tobacco insect features, adapting it to tobacco insect detection scenarios. Specifically, the multi-scale feature-aware attention module can be a feature enhancement network composed of a context-aware pyramid feature extraction module and a channel attention module connected in series.
[0035] Furthermore, combined Figure 2 As illustrated, the specific construction method of the context-aware pyramid feature extraction module can be referred to as follows:
[0036] First, we take CspLayer2, CspLayer3, and CspLayer4 from YOLOv5 as the basic high-level features F. C×H×W Next, to ensure the final extracted high-level features include scale- and shape-invariant features, atrous convolutions with different dilation rates (3, 5, and 7, respectively) are used to capture multi-receptor field context information. Then, feature maps from different atrous convolutional layers are combined with 1×1 dimensionality-reduced features via cross-channel concatenation. This results in three distinct scale features and context-aware information, with the two smaller features upsampled to the largest. Finally, these are combined via cross-channel concatenation. As the output of the Multi-Scale Pyramid Feature Extraction (MSPFE) module.
[0037] The specific construction method of the channel attention module can be referenced as follows:
[0038] First is the Squeeze operation, which is to sort the data according to spatial dimensions. Feature compression transforms each two-dimensional feature channel into a real number, which to some extent possesses a global receptive field, and the output dimension matches the number of input feature channels. This represents the global distribution of the response across the feature channels and allows layers closer to the input to also obtain global receptive field feature maps.
[0039]
[0040] In the formula, F represents the global receptive field feature map. sq (·) indicates the extrusion process. CspLayer2, CspLayer3, and CspLayer4 are multi-scale pyramid features, where C is the channel number, and W and H are the width and height of the feature map, respectively.
[0041] Next is the excitation operation, first multiplied by ω1. This involves a fully connected layer operation where ω has a dimension of C / r×C, where r is a scaling parameter, for example, 16. This parameter aims to reduce the number of channels and thus reduce computational cost. Then, it passes through a ReLU layer, maintaining the same output dimension. Next, it is multiplied by ω², which is also a fully connected layer process. Finally, it passes through a sigmoid function to obtain the channel weights.
[0042]
[0043] S represents the channel weight, F ex (·) represents the Excitation operation, and σ represents the sigmoid function;
[0044] Then a scaling operation is performed, that is, the channel weights are scaled with the feature F. C C×H×W Multiplication yields channel attention features:
[0045]
[0046] Where F A This indicates channel attention features and matrix multiplication.
[0047] Finally, in order to preserve the original feature information, the original feature F C×H×W Channel attention characteristics The summation yields the multi-scale perceptual attention feature F′:
[0048]
[0049] Step S3: Using the training set and the validation set, train the YOLOv5 object detection model that integrates the multi-scale feature perception attention module to obtain the trained weights;
[0050] Step S4: Select the optimal weights and use the test set as input images to improve the object detection model (refer to...). Figure 3 (Illustration) The detection is performed to obtain information on the number and precision of tobacco insects.
[0051] As can be seen from actual verification, Figure 4a The accuracy of the tobacco insect quantity and precision information obtained by the traditional target detection algorithm shown is significantly lower than that of the traditional algorithm. Figure 4b The improved algorithm's recognition performance is shown.
[0052] In summary, the main design concept of this invention lies in integrating a multi-scale feature perception attention module into the backbone network, based on the traditional YOLOv5 algorithm, to focus on effective high-level semantic features and low-level spatial structure features in tobacco insect image data. This allows for the acquisition of contextual information about the tobacco insects to be identified. Furthermore, an attention mechanism is used as a guide for feature channel relationships to obtain more valuable low-level information about the tobacco insect target. Practical application has shown that this invention improves the reliability and accuracy of tobacco insect quantity and precision identification compared to traditional YOLOv5 target detection results.
[0053] In this embodiment of the invention, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent the existence of A alone, A and B simultaneously, or B alone. A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects have an "or" relationship. "At least one of the following" and similar expressions refer to any combination of these items, including any combination of singular or plural items. For example, at least one of a, b, and c can represent: a, b, c, a and b, a and c, b and c, or a and b and c, where a, b, and c can be single or multiple.
[0054] The above description of the structure, features, and effects of the present invention is based on the embodiments shown in the figures. However, the above are only preferred embodiments of the present invention. It should be noted that the technical features involved in the above embodiments and their preferred methods can be reasonably combined and matched by those skilled in the art to form a variety of equivalent solutions without departing from or changing the design concept and technical effects of the present invention. Therefore, the present invention is not limited to the scope of implementation shown in the figures. Any changes made in accordance with the concept of the present invention, or modifications to equivalent embodiments, that do not exceed the spirit covered by the specification and figures, should be within the protection scope of the present invention.
Claims
1. A visual detection method for tobacco insects based on an improved target detection model, characterized in that, include: After preprocessing the pre-created tobacco worm dataset, it was divided into training set, validation set and test set; Based on the backbone network of the YOLOv5 target detection model, a multi-scale feature perception and attention module is constructed. The multi-scale feature perception and attention module is a feature enhancement network composed of a context-aware pyramid feature extraction module and a channel attention module connected in series and directly embedded into the backbone network. It is used to focus on effective high-level semantic features and low-level spatial structure features in tobacco insect image data, thereby obtaining the context information of the tobacco insect to be identified. Combined with the attention mechanism as a guide for feature channel relationships, it is used to obtain more valuable low-level information of tobacco insect targets. The pyramid feature extraction module is constructed by: acquiring the original features output by the CSP layer in YOLOv5 and capturing contextual information using convolutional layers with different dilation rates; combining feature maps and dimensionality reduction features from different convolutional layers through cross-channel concatenation to obtain different scale features and context-aware information, and performing upsampling; and then performing feature fusion again through cross-channel concatenation to obtain multi-scale pyramid features as the output of the pyramid feature extraction module. Using the training set and the validation set, the YOLOv5 object detection model that incorporates the multi-scale feature perception attention module is trained to obtain the trained weights; By selecting the optimal weights and using the test set as input images, the improved target detection model is used to detect the number and accuracy of tobacco insects. Furthermore, the channel attention module is constructed in the following ways: The multi-scale pyramid features are compressed according to the spatial dimension to obtain the receptive field feature map. Based on the receptive field feature map, the dependency relationship of each channel information is obtained, and the channel weights are obtained; The channel weights are fused with the multi-scale pyramid features to obtain channel attention features; The original features are added to the channel attention features to obtain the final features output by the multi-scale feature perception attention module.
2. The visual detection method for tobacco insects based on an improved target detection model according to claim 1, characterized in that, The feature compression includes converting each two-dimensional feature channel into a real number, wherein the real number has a global receptive field.
3. The visual detection method for tobacco insects based on an improved target detection model according to claim 2, characterized in that, The process of obtaining the channel weights by acquiring the dependency relationship of each channel information based on the receptive field feature map includes: performing a first fully connected layer operation on the receptive field feature map, then performing a second fully connected layer operation after passing through a ReLU layer, and finally obtaining the channel weights through the sigmoid function.