An improved agricultural pest target detection method based on hybrid attention mechanism
By introducing GCT and CBAM modules into the agricultural pest target detection model, combining EIOU functions to optimize channel and spatial feature extraction, the problems of data imbalance and target diversity are solved, and detection accuracy and generalization capabilities are improved.
Patent Information
- Application Number
- CN202510373438.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-27
- Publication Date
- 2025-09-05
- Estimated Expiration
- 2045-03-27
AI Technical Summary
The existing agricultural pest target detection model is affected by uneven data distribution, diversification of target sizes and high image similarity in the field environment, resulting in insufficient feature extraction and reduced generalization capabilities, affecting detection accuracy.
The object detection method based on the improved hybrid attention mechanism is adopted, and the channel feature extraction is optimized by introducing the GCT module, combining the CBAM module to perform feature extraction on the channel and spatial dimensions, and using the EIOU function in the output network to improve the loss function and improve the target positioning ability.
The detection accuracy and generalization ability of the model to target agricultural pests is improved, especially in the case of multi-scale and large similarity, which significantly improves the detection effect.
Smart Images

Figure CN119963824B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of agricultural pest target detection, and specifically to an improved agricultural pest target detection method based on a hybrid attention mechanism. Background Art
[0002] In the field of agricultural plant protection, the occurrence of insect pests can significantly impact the quality and yield of agricultural products. Identifying agricultural pests requires cross-examination by plant protection experts, which consumes significant manpower and resources. Farmers lacking plant protection experience find it difficult to accurately identify pest types. Based on the development of neural network technology, the research and application of computer vision technology in the agricultural field has become a hot topic, and a growing number of scholars are applying deep neural networks to agricultural pest identification tasks.
[0003] Traditional classification networks can obtain richer features for pest target detection based on deep learning methods. The feature representation ability and robustness are better than traditional target detection methods. Mainstream deep learning target detection methods can be divided into two-stage target detection methods and single-stage target detection methods according to the network structure. The two-stage detection method first generates candidate regions, and then classifies and regresses the candidate regions. The single-stage detection method directly predicts the category and region of the input. The two-stage detection method is more flexible, allowing different parts of the model to focus on different tasks, and the ability of regression box positioning and target classification is more prominent. Jianwu Lin et al. proposed a hierarchical complementary network (HCNet) to capture the feature representation of pests and perform complementary fusion to obtain hierarchical complementary information. First, a "shallow to deep" strategy was used to capture the hierarchical representation of pest images. Secondly, a spatial feature recognition (SFD) module was proposed, which captures the key information in the hierarchical representation by enhancing the spatial features of the current stage and suppressing the spatial features of the next stage. Finally, a coordinated attention-guided feature complementarity (CAFC) module was designed to fuse the complementary information between the features extracted from the SFD module, achieving an accuracy of 75.36% on the IP102 pest dataset.
[0004] The above method improves the recognition performance of the model in some aspects, but in experiments, we found that the performance of the model is often affected by multiple aspects. Due to the limitations of the data collection environment, the data distribution is often unbalanced, the amount of image data is insufficient, and the small number of training samples will amplify the impact of noise to a certain extent. At the same time, the lack of images in multiple scenes leads to an uneven distribution of image features in the dataset; the target sizes in agricultural pest samples are diverse, and some images have a high degree of similarity, which will lead to insufficient extraction of target features by the model and reduced generalization ability; the above reasons make it more difficult for the model to extract features, which puts higher requirements on the model's generalization and feature extraction capabilities.
[0005] Based on the above defects, an improved agricultural pest target detection method based on the hybrid attention mechanism is proposed. Aiming at the problem of difficult detection and identification of agricultural pest targets in field environments, the multi-faceted features of pests are accurately extracted to improve the accuracy of target detection of agricultural pests. Summary of the Invention
[0006] The purpose of the present invention is to provide an improved agricultural pest target detection method based on a hybrid attention mechanism to solve the problems raised in the above background technology.
[0007] The purpose of the present invention can be achieved through the following technical solutions:
[0008] A method for detecting agricultural pest targets based on an improved hybrid attention mechanism is disclosed. The detection method comprises the following steps: storing agricultural pest images captured by a camera into a storage device, reading image data from the storage device, inputting the image data into a target detection network improved based on the hybrid attention mechanism, extracting features of the pests, and realizing a pest target detection function based on the pest features. The target detection network improved based on the hybrid attention mechanism comprises a feature extraction network, a feature pyramid network, a candidate recognition region, and an output network. The target detection network improved based on the hybrid attention mechanism takes a FasterRCNN network as a basic model. In the backbone of its feature extraction network, the original Bottlenect module in the backbone is replaced with a GBottlenect module. The GBottlenect module consists of a GCT and three convolutional layers. The GCT is a feature module for extracting the relationship between calculation channels. The three convolutional layers are used to extract the main features.
[0009] Preferably, the feature pyramid network is composed of features of different scales, which are extracted by GBottlenect modules on different layers. These features of different scales are sent to each layer of the feature pyramid. The feature pyramid network consists of five layers: P2, P3, P4, P5 and P6. Each layer extracts a feature map of the corresponding scale separately. The feature pyramid fuses the semantic information of the high-level feature map with the spatial information of the low-level feature map by upsampling the deep semantic features and downsampling the shallow semantic features, thereby increasing the model's detection accuracy for multi-scale targets.
[0010] Preferably, a CBAM feature extraction module is added after the last GBottlenect module in the feature extraction network to extract feature key areas through two dimensions, channel and space. The input features first pass through the channel attention module to form a channel feature map, and then pass through the spatial attention module to form a spatial feature map. Finally, the channel and spatial feature maps are multiplied respectively to obtain the output feature map.
[0011] Preferably, the image data is first input into the feature extraction network for primary feature extraction, and the extracted primary features are subjected to channel feature extraction on the channel through the GCT module. Then the feature map is sent to two branches, one branch is to extract and fuse the channel features on different feature layers through the feature pyramid network, and the other branch is to send the bottom channel features into the CBAM feature extraction module to extract important features in the channel and space. Finally, the important features are sent to the candidate recognition area, and the features are output through the output network. In the output network, the IOU loss function is replaced by the EIOU loss function to achieve accurate detection of pest targets.
[0012] Preferably, the output network is based on the existing output network model, and the IOU loss function is modified and replaced with the EIOU function. EIOU is based on IOU and adds the aspect ratio penalty term of the aspect ratio prediction box and the real box and the distance penalty term between the center point of the target box and the center point of the prediction box to improve the model's ability to locate the target. The loss function is shown in formula (1), L IOU represents the overlap loss, L dis Indicates the distance loss, L asp Indicates width and height loss:
[0013]
[0014] Among them, b and b gt Represent the center points of the predicted box and the real box, w and w respectively gt Represents the width of the predicted box and the real box, h and h respectively gt Represents the height of the predicted box and the real box respectively, ρ represents the Euclidean distance between the center points, C 2 Represents the diagonal distance of the minimum bounding rectangle formed by the real box and the predicted box, Indicates the width of the minimum enclosing rectangle, Indicates the height of the minimum enclosing rectangle.
[0015] Preferably, the GCT consists of three modules: M1, M2 and M3. The M1 module uses Global Context Embedding. Pooling is performed as shown in formula (2), where are the values of each pixel, ε is a very small constant, α c is the weighting factor.
[0016]
[0017] Preferably, the M2 module of the GCT is normalized using L2 regularization, as shown in formula (3), where is the scale factor and C is the different channels.
[0018]
[0019] Preferably, the M3 module of the GCT implements a gating mechanism by using gating weights and biases, as shown in formula (4):
[0020]
[0021] in, γ is the weight and β is the bias.
[0022] Beneficial effects of the present invention:
[0023] 1. The present invention introduces the GCT module into the feature extraction network. The GCT attention mechanism optimizes the role of different channels in extracting significant features. Through normalization and gating mechanisms, the feature relationship between different channels is modeled, and the competition and cooperation relationship between channel features is calculated, thereby improving the adaptability between different channels and improving the accuracy of target feature detection.
[0024] 2. The present invention connects the feature extraction network to the CBAM feature extraction module and performs attention calculations in both channel and spatial dimensions. The attention in the channel dimension helps to improve the representation of features in different channels, while the attention mechanism in the spatial dimension helps to enhance the extraction of key information of features at different spatial positions, thereby strengthening the target features of pests.
[0025] 3. The present invention improves the model's ability to locate the target by modifying the IOU loss function of the output network and introducing the EIOU function. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, those skilled in the art can derive other drawings based on these drawings without inventive effort.
[0027] Figure 1 It is the overall flow chart of the method of the present invention;
[0028] Figure 2 This is the structural diagram of the GCT gated attention mechanism of the present invention;
[0029] Figure 3 This is a diagram of the improved network structure of the present invention;
[0030] Figure 4 It is the structural diagram of CBAM of the present invention;
[0031] Figure 5It is a schematic diagram of the EIOU of the present invention; DETAILED DESCRIPTION
[0032] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making any creative efforts shall fall within the scope of protection of the present invention.
[0033] An improved agricultural pest target detection method based on hybrid attention mechanism, such as Figure 1 、 Figure 3 、 Figure 4 、 Figure 5 As shown, the detection method is as follows: storing agricultural pest images collected by a camera into a storage device, reading image data from the storage device, inputting the image data into a target detection network improved based on a hybrid attention mechanism, extracting features of the pests, and realizing the pest target detection function according to the pest features. The target detection network improved based on the hybrid attention mechanism includes a feature extraction network, a feature pyramid network, a candidate recognition area and an output network. The target detection network improved based on the hybrid attention mechanism is based on the Faster RCNN network as a basic model. In the Backbone of its feature extraction network, the original Bottlenect module in the Backbone is replaced with a GBottlenect module. The GBottlenect module consists of GCT and three convolutional layers. GCT is a feature module for extracting the relationship between calculation channels. The three convolutional layers are used to extract the main features.
[0034] The improved detection network based on the hybrid attention mechanism is used to extract target features as a method for agricultural pest target detection to improve the accuracy of agricultural pest target detection.
[0035] In Faster RCNN, the candidate recognition region is obtained by mapping the candidate recognition box generated by RPN (Region Proposal Network) to the Feature Map. This is an existing technology that normalizes candidate recognition regions of different sizes and shapes into a target recognition region of fixed size.
[0036] In order to solve the problem of low detection model accuracy caused by diverse target scales and high similarity between categories in the agricultural pest target detection task, the hybrid attention mechanism is improved. Combined with the improved hybrid attention mechanism, the feature extraction network, feature pyramid network, candidate recognition area and output network are coordinated for agricultural pest target detection. The target features are extracted and enhanced, and feature detection is performed at both channel and spatial levels, with good detection effect.
[0037] Firstly, a target detection dataset Insect25 containing 25 agricultural pests was constructed to enrich the distribution of features in the dataset. Secondly, this detection method was used to extract more discriminative features. Finally, the accuracy of the model was improved by introducing the EIOU function, which can reduce the interference of multi-scale and large similarity and improve the detection effect.
[0038] like Figure 3 As shown in the figure, the feature pyramid network is composed of features of different scales, which are extracted by GBottlenect modules on different layers. These features of different scales are sent to each layer of the feature pyramid. The feature pyramid network consists of five layers: P2, P3, P4, P5 and P6. Each layer extracts feature maps of corresponding scales separately. The feature pyramid fuses the semantic information of high-level feature maps with the spatial information of low-level feature maps by upsampling deep semantic features and downsampling shallow semantic features, thereby increasing the model's detection accuracy for multi-scale targets.
[0039] The FPN network is a deep learning network structure used to solve multi-scale problems in target detection and semantic segmentation. By constructing a feature pyramid, feature maps of different scales are fused to generate feature representations with rich multi-scale information. It mainly solves the problem of performance degradation of traditional object detection models when processing small targets.
[0040] The core idea of FPN is to utilize the multi-scale feature maps inherent in deep convolutional neural networks, and combine high-level semantic information with low-level spatial information through bottom-up and top-down feature fusion paths to improve the detection performance of objects of different scales.
[0041] like Figure 3 As shown in the figure, a CBAM feature extraction module is added after the last GBottlenect module in the feature extraction network to extract feature key areas through the two dimensions of channel and space. The input features first pass through the channel attention module to form a channel feature map, and then pass through the spatial attention module to form a spatial feature map. Finally, the channel and spatial feature maps are multiplied respectively to obtain the output feature map.
[0042] A CBAM feature extraction module is added after the last GBottlenect module of the Backbone feature extraction network to extract key feature areas in both channel and spatial dimensions. The input features first pass through the channel attention module to form a channel feature map, and then pass through the spatial attention module to form a spatial feature map. Finally, the channel and spatial feature maps are multiplied to obtain the output feature map.
[0043] Attention in the channel dimension helps improve the representation of features in different channels, while the attention mechanism in the spatial dimension helps enhance the extraction of key information of features at different spatial positions. This dual-branch attention mechanism can fully capture the key information in the features while suppressing irrelevant information and noise.
[0044] like Figure 4 As shown in the figure, the CBAM attention module (feature extraction module) first sends the features to the channel attention module (CAM). The CAM focuses on the channel information in the image and calculates the importance of each channel. The spatial attention module (SAM) focuses on the spatial pixel information in the image and calculates the importance of each local space. Finally, the channel attention weight and the spatial attention weight jointly determine the attention feature.
[0045] like Figure 3 As shown, the image data is first input into the feature extraction network for primary feature extraction, and the extracted primary features are subjected to channel feature extraction on the channel through the GCT module. Then the feature map is sent to two branches. One branch is to extract and fuse the channel features on different feature layers through the feature pyramid network, and the other branch is to send the bottom channel features to the CBAM feature extraction module to extract important features in the channel and space. Finally, the important features are sent to the candidate recognition area, and the features are output through the output network. In the output network, the IOU loss function is replaced by the EIOU loss function to achieve accurate detection of pest targets.
[0046] The hybrid attention mechanism is a dual-branch structure that integrates channel attention and spatial attention. It uses channel and spatial attention to weight channel features and spatial features respectively, making full use of the attention information in channels and space, and improving the network's ability to extract discriminative features.
[0047] The GCT attention mechanism (module) can reflect the collaboration and competition relationship between channels. Therefore, the GCT attention mechanism can effectively extract the attention information between channels. The model structure is as follows: Figure 2 shown.
[0048] like Figure 5 As shown, the output network is based on the existing output network model, and the IOU function is modified and replaced with the EIOU function. EIOU is based on IOU and adds the aspect ratio penalty term of the aspect ratio prediction box and the real box and the distance penalty term between the center point of the target box and the center point of the prediction box to improve the model's ability to locate the target. The loss function is shown in formula (1), L IOU represents the overlap loss, L dis Indicates the distance loss, L asp Indicates width and height loss:
[0049]
[0050] Among them, b and b gt Represent the center points of the predicted box and the real box, w and w respectively gt Represents the width of the predicted box and the real box, h and h respectively gt Represents the height of the predicted box and the real box respectively, ρ represents the Euclidean distance between the center points, C 2 Represents the diagonal distance of the minimum bounding rectangle formed by the real box and the predicted box, Indicates the width of the minimum enclosing rectangle, Indicates the height of the minimum enclosing rectangle.
[0051] The GCT attention mechanism consists of three parts: M1, M2 and M3 modules. The channel attention weight is extracted according to the competition and cooperation relationship between channels. In the deep neural network, the fully connected layer (fc) integrates the features extracted by the feature layer to facilitate the classification and regression of the output layer. However, due to its large number of parameters, it cannot be used in all layers and is generally added to the last layer of the network. Secondly, the fc layer uses dense connections, which makes it difficult to analyze the correlation between channels and characterize the role of channels. In addition, a large receptive field can capture more pixel information in the image and avoid ambiguity in the extracted local features. Therefore, the M1 module is used in the Global Context Embedding. Pooling is performed as shown in formula (2), where are the values of each pixel, ε is a very small constant, α c is the weighting factor.
[0052]
[0053] Normalization layer (LN) is widely used in deep networks, where local normalization can calculate the information in the domain between channels. Global pooling will fail in some cases because the normalization layer fixes the average of each channel. For any output, the global average pooling is fixed. The M2 part uses the most effective L2 regularization for normalization to simulate the competition or cooperation relationship between channels, as shown in formula (3). is the scale factor and C is the different channels.
[0054]
[0055] The M3 part implements the gating mechanism by using gating weights and biases. The weights and biases are used to control whether the features on the channel are activated. When a channel weight is activated, GCT promotes the channel to compete with other channels. When the weight is suppressed, GCT promotes the channel to cooperate with other channels, as shown in formula (4):
[0056]
[0057] in, γ is the weight and β is the bias.
[0058] An improved agricultural pest target detection method based on the hybrid attention mechanism is proposed. By introducing the GCT attention mechanism and the EIOU function, the role of different channels in extracting significant features is optimized, the model's ability to locate targets is improved, and the CBAM attention module is integrated to perform attention calculations in both channel and spatial dimensions, thereby improving the accuracy of pest target detection.
[0059] Test-related data and test results
[0060] Data collection and processing: In a field environment, a variety of pests were photographed with image resolutions ranging from 7360*4912 pixels to 6016*4016 pixels. To enrich the sample representation in the dataset, the data was collected from various hosts, backgrounds, angles, and distances. The collected pest and disease images were cleaned and cross-identified by plant protection experts to obtain accurate image data. To make the details of small targets more prominent, the original image was subjected to target highlighting and cropping, and the cropped image was merged with the original image. The sample images were then enhanced using data augmentation methods, with Gaussian blurring, random noise, and brightness enhancement applied to each type of data. Rectangular annotation was performed using the LabelImg annotation tool. The annotated XML file contains the category and location coordinate information required for model runtime. The annotated dataset was converted to the VOC format required by Faster RCNN and divided into training, validation, and test sets according to the commonly used 8:1:1 ratio.
[0061] Experimental platform: The graphics card model selected is Tesla V100 PCle with a memory size of 32G; the PyTorch1.12.1 deep learning framework based on CUDA11.3 and CUDNN 8302 is used, and the code running environment is Python3.7.
[0062] Test results
[0063] Table 1 compares the effects of different models on the Insect25 dataset. E-Faster RCNN represents the model after the ECA module is integrated into Faster RCNN, S-Faster RCNN represents the model after the SE module is integrated into Faster RCNN, CBAM-Faster RCNN represents the model after the C module is integrated into Faster RCNN, G-Faster RCNN represents the model after the GCT module is integrated into Faster RCNN, and GC-Faster RCNN is the model proposed in this study. The experimental results show that the model proposed in this study is superior to Faster RCNN, E-Faster RCNN, S-Faster RCNN, C-Faster RCNN and G-Faster RCNN in mAP. 0.5:0.95 The accuracy of the indicators increased by 20.8%, 6.3%, 6.2%, 5.8% and 5%, respectively, and the mAR 0.5:0.95 The recall rate of the indicators is improved by 16.6%, 4.9%, 4.6%, 4.5% and 4.4%. 0.5 、mAP 0.75 and mAP 0.5:0.95 From the changes in , we can see that the GC-Faster RCNN model improves the detection accuracy and the detection recall rate, especially when the IOU threshold is high, which can improve the model's ability to extract fine-grained discriminative features.
[0064] Table 1 Performance comparison of different models
[0065] model <![CDATA[mAP 0.5 ]]> <![CDATA[mAP 0.75 ]]> <![CDATA[mAP 0.5:0.95 ]]> <![CDATA[mAR 0.5:0.95 ]]> FasterRCNN 0.925 0.735 0.611 0.674 E-FasterRCNN 0.981 0.924 0.756 0.791 S-FasterRCNN 0.974 0.918 0.757 0.794 C-FasterRCNN 0.977 0.921 0.761 0.795 G-FasterRCNN 0.978 0.917 0.769 0.796 GC-FasterRCNN(ours) 0.970 0.939 0.819 0.840
[0066] Ablation experiment:
[0067] Table 2 compares the experimental results of different attention mechanisms on the Pest25 dataset. Original is the detection effect of FasterRCNN without adding any attention module. 0.5 、mAP 0.75 and mAP 0.5:0.95 The average precision of each category is 0.925, 0.735 and 0.611, and the recall rate mAR 0.5:0.95The value is 0.674. The performance of the CBAM hybrid attention mechanism is higher than that of the Original, ECA, and SE attention mechanisms, and the performance of the GCT attention mechanism is slightly higher than that of CBAM. The GCAM method proposed in this study adds GCT before each convolution layer in Bottlenect to calculate the collaborative relationship between channels. It adds the CBAM module after the feature extraction network to perceive the importance of different channels, focusing on both important channel features and important spatial features. 0.5:0.95 The accuracy is higher than that of CBAM and GCT attention modules, and is better than the original FasterRCNN network performance in mAP. 0.5:0.95 and mAR 0.5:0.95 The indicators increased by 16.8 and 14.9 percentage points respectively.
[0068] Table 2 Performance comparison of different attention mechanisms
[0069] AM Optimizer IOU <![CDATA[mAP 0.5 ]]> <![CDATA[mAP 0.75 ]]> <![CDATA[mAP 0.5:0.95 ]]> <![CDATA[mAR 0.5:0.95 ]]> Original SGD - 0.925 0.735 0.611 0.674 ECA SGD - 0.981 0.924 0.756 0.791 SE SGD - 0.974 0.918 0.757 0.794 CBAM SGD - 0.977 0.921 0.761 0.795 GCT SGD - 0.978 0.917 0.769 0.796 GCAM SGD - 0.963 0.923 0.779 0.823
[0070] According to the experimental suggestions of the GCT attention mechanism, the effects of different improved methods and hybrid attention mechanisms are compared. The experiments are shown in Table 3. The combinations of different methods and AM are all based on the SGD loss function optimization method and the improved warm-up ConsineAnnealing learning rate update method. Layer2,3 means that the GCT module is added before the last two convolutional layers in each ResBlock, and layer1,2,3 means that the GCT module is applied to all convolution operations in the ResBlock. The experiment shows that adding the GCAM module to layer1,2,3 has the best effect, and its mAP is 0.5:0.95 The mAP is 0.819, which is 0.4% higher than that of GCT+SAM, 0.7% higher than that of GCAM in layer 2 and 3, and 1.2 percentage points higher than that of GCT+SAM. 0.5 ,,mAP 0.75 and AP 0.5:0.95 It can be seen from the changes that the improved model improves the detection accuracy and the detection recall rate. The improvement effect is obvious under the condition of a high IOU threshold, which can improve the model's ability to extract fine-grained discriminative features.
[0071] Table 3 Performance of different improved models
[0072] method AM IOU <![CDATA[mAP 0.5 ]]> <![CDATA[mAP 0.75 ]]> <![CDATA[mAP 0.5:0.95 ]]> <![CDATA[mAR 0.5:0.95 ]]> layer2,3 GCT+SAM EIOU 0.971 0.939 0.807 0.830 layer2,3 GCAM(ours) EIOU 0.971 0.941 0.812 0.840 layer1,2,3 GCT+SAM EIOU 0.972 0.936 0.815 0.841 layer1,2,3 GCAM(ours) EIOU 0.970 0.939 0.819 0.840
[0073] This study proposed an improved agricultural pest target detection method based on the hybrid attention mechanism, which introduced the GCT attention mechanism and EIOU function, optimized the role of different channels in extracting significant features, improved the model's ability to locate targets, integrated the CBAM attention module, performed attention calculations in both channel and spatial dimensions, and improved the accuracy of pest target detection.
[0074] The basic principles, main features, and advantages of the present invention are shown and described above. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The above embodiments and descriptions are merely illustrative of the principles of the present invention. Various changes and modifications may be made to the present invention without departing from the spirit and scope of the present invention, and such changes and modifications fall within the scope of the invention as claimed.
Claims
1. An improved agricultural pest target detection method based on hybrid attention mechanism, characterized in that: The detection method comprises storing an image of agricultural pests captured by a camera into a storage device, reading image data from the storage device, inputting the image data into a target detection network improved based on a hybrid attention mechanism, extracting features of the pests, and implementing a pest target detection function based on the pest features. The target detection network improved based on the hybrid attention mechanism comprises a feature extraction network, a feature pyramid network, a candidate recognition region, and an output network. The target detection network improved based on the hybrid attention mechanism uses a Faster RCNN network as a basic model. In the backbone of its feature extraction network, the original Bottlenect module in the backbone is replaced with a GBottlenect module. The GBottlenect module is composed of a GCT and three convolutional layers. The GCT is a feature module for extracting and calculating the relationship between channels. The three convolutional layers are used to extract the main features. The feature pyramid network is composed of features of different scales, which are extracted by GBottlenect modules on different layers. These features of different scales are sent to each layer of the feature pyramid. The feature pyramid network consists of five layers: P2, P3, P4, P5 and P6. Each layer extracts feature maps of corresponding scales separately. The feature pyramid fuses the semantic information of high-level feature maps with the spatial information of low-level feature maps by upsampling deep semantic features and downsampling shallow semantic features, thereby increasing the model's detection accuracy for multi-scale targets. The CBAM feature extraction module is added after the last GBottlenect module in the feature extraction network to extract the key feature areas in the channel and space dimensions. The input features are first passed through the channel attention module to form a channel feature map, and then through the spatial attention module to form a spatial feature map. Finally, the channel and spatial feature maps are multiplied to obtain the output feature map. The image data is first input into the feature extraction network for primary feature extraction, and the GCT module is used to extract channel features on the extracted primary features. Then the feature map is sent to two branches. One branch is used to extract and fuse channel features on different feature layers through the feature pyramid network, and the other branch is used to send the bottom channel features to the CBAM feature extraction module to extract important channel and spatial features. Finally, the important features are sent to the candidate recognition area, and the features are output through the output network. In the output network, the IOU loss function is replaced by the EIOU loss function to achieve accurate detection of pest targets.
2. The improved agricultural pest target detection method based on hybrid attention mechanism according to claim 1 is characterized in that: The output network is based on the existing output network model, and the IOU loss function is modified and replaced with the EIOU function. EIOU is based on IOU and adds the aspect ratio penalty term of the aspect ratio prediction box and the real box and the distance penalty term between the center point of the target box and the center point of the prediction box to improve the model's ability to locate the target. The loss function is shown in formula (1), L IOU represents the overlap loss, L dis Indicates the distance loss, L asp Indicates width and height loss: Among them, b and bgt represent the center points of the predicted box and the real box respectively, w and w gt Represent the width of the predicted box and the real box respectively, h and hgt represent the height of the predicted box and the real box respectively, ρ represents the Euclidean distance between the center points, C 2 Represents the diagonal distance of the minimum bounding rectangle formed by the real box and the predicted box, Indicates the width of the minimum enclosing rectangle, Indicates the height of the minimum enclosing rectangle.
3. The improved agricultural pest target detection method based on hybrid attention mechanism according to claim 2 is characterized in that: The GCT consists of three parts: M1, M2 and M3 modules. The M1 module uses Global Context Embedding Pooling is performed as shown in formula (2), where are the values of each pixel, ε is a very small constant, α c is the weighting factor.
4. The improved agricultural pest target detection method based on hybrid attention mechanism according to claim 3 is characterized in that: The M2 module of the GCT uses L2 regularization for normalization, as shown in formula (3), where is the scale factor and C is the different channels.
5. The improved agricultural pest target detection method based on hybrid attention mechanism according to claim 4 is characterized in that: The M3 module of the GCT implements the gating mechanism by using gating weights and biases, as shown in formula (4): Among them, γ is the weight and β is the bias.
Citation Information
Patent Citations
Crop pest detection method based on TSD-Faster RCNN and network thereof
CN115115887A
Road disease detection method based on scale difference
CN119206176A