Corn pest identification method based on improved YOLOv8

By introducing a global attention mechanism and deformable convolution module in the YOLOv8 model, the problem of different sizes and sizes in corn pest detection is solved, the detection accuracy and recall rate are significantly improved, and more efficient corn pest recognition is achieved.

CN119229261AActive Publication Date: 2024-12-31GUANGDONG OCEAN UNIVERSITY

Patent Information

Application Number
CN202411687276.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-25
Publication Date
2024-12-31
Estimated Expiration
2044-11-25

AI Technical Summary

Technical Problem

The prior art is difficult to effectively deal with the problem of different sizes and sizes of pests due to different shooting heights in corn pest detection, resulting in low detection accuracy and recall.

Method used

Using the improved YOLOv8 model, the feature map is enhanced by adding global attention mechanism (GAM) to the neck network and replacing part of the C2f module into the deformable convolution (DCN) module in the backbone network, combined with the detection head of 160×160 scale Information fusion and small object detection capabilities.

Benefits of technology

Improved the accuracy, recall rate, mAP50 and mAP50-95 of corn pest detection, which was improved by 4.7%, 3.7%, 0.9% and 2.4% respectively compared with the YOLOv8 model, achieving more accurate and efficient end-to-end pest detection. .

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119229261A_ABST
    Figure CN119229261A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of corn pest detection, and discloses an improved YOLOv8-based corn pest identification method, which comprises the following steps: acquiring a corn pest image; an improved YOLOv8 model is constructed; the improved YOLOv8 model comprises a backbone network, a neck network and a head network; performing feature extraction on the corn pest image by using a backbone network, and fusing feature information based on deformable convolution to generate a multi-scale feature map containing different levels of visual information; fusing the multi-scale feature maps containing different levels of visual information by using a neck network to obtain a feature map fused with the multi-scale information; and utilizing the head network to predict a corn pest identification result according to the feature map fused with the multi-scale information. According to the invention, accurate pest detection and identification can be provided for corn crops, and high-precision end-to-end pest detection is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of corn pest detection, and in particular to a corn pest recognition method based on improved YOLOv8. Background Art

[0002] The first and most important point in the prevention and control of crop diseases and pests is how to quickly identify the diseases and pests that harm crops in a short period of time and protect the growth of crops to the greatest extent.

[0003] The fall armyworm is an insect native to tropical and subtropical regions of America. It likes to be active at night. This insect has strong adaptability, migration and omnivorousness. It has quickly become a major cross-border and intercontinental agricultural invasive pest. The fall armyworm shows its harmfulness in the larval stage. They mainly eat corn and rice. The corn borer is a common pest. It belongs to the family of Pyralidae in the order Lepidoptera. This species has a strong destructive power on cereal crops, especially corn. The larvae of the corn borer will invade corn plants and feed, which will seriously affect the growth of corn plants and even directly cause the death of young corn plants.

[0004] In order to accurately detect pests and formulate scientific prevention and control measures, it is necessary to accurately identify pests. However, the identification of fall armyworms and corn borers mainly relies on manual identification, and manual experience and knowledge are highly subjective. If ordinary people lack knowledge of corn pests, they may miss the best prevention and control period when corn pests attack corn. Therefore, deep learning technology can be used to accurately identify corn pests.

[0005] In recent years, some researchers have used image processing and machine learning to detect crop pests and diseases. However, compared with traditional machine learning and deep learning, machine learning is difficult to meet actual needs in complex scenes, and the detection effect of crop pests is poor and the accuracy is low. Deep learning has excellent performance in complex scenes and can meet actual needs. Among them, deep learning represented by convolutional neural networks has achieved great success in computer vision, automatic speech recognition, image classification and other fields. For example, AlexNet, GoogleNet, VGGNet, ResNet, and Transformer have been introduced from the field of natural language processing to the field of computer vision in recent years. Pest target detection is one of the main tasks of plant pest detection, and its purpose is to obtain the accurate location and category information of pests. Deep learning technology has shown excellent performance in image recognition, including the ability to extract occlusion and rotated objects, and directly processes image information during the learning process without the need for cumbersome processes.

[0006] Deep learning models can be divided into two-stage and single-stage models according to the framework. The two-stage model is mainly represented by the RCNN series. FAROOQ ALI et al. improved Faster-RCNN, used MobileNet as its basic network, collected local crops to make data sets, and tested them. It can solve the problems of pest sample distortion such as blur and light changes, and the model has a certain generalization ability. Tiewei Wang et al. proposed an improved recognition and counting method MPest-RCNN based on deep learning and data reorganization. They took three typical pests that harm apples as research objects, established an apple pest data set, and the accuracy of apple pest detection can reach 99.11%. AMANI ABDULRAHMAN ALBRAIKAN et al. proposed a Mask RCNN recognition method for red palm weevils that harm palm trees. They used MobileNetv2 as the backbone network, and the pre-trained network weights of the ResNet50 architecture were used for transfer learning. The data was expanded through data enhancement technology, and the detection was performed on the red palm weevil pest data set, which improved the accuracy to 99.27%.

[0007] The single-stage network integrates the entire process of generating candidate boxes. It is mainly represented by the YOLO series. Lijuan Zhang et al. proposed a YOLOv5 deep learning algorithm, which integrates the lightweight convolution module C3M of the mobileNetV3 network into the YOLOv5 model, and adds the GAM attention mechanism to the neck of the model, further improving the detection ability of the model. The pests of the public dataset IP102 are detected with an accuracy of 2.4% higher than the original model. Lianpeng et al. selected corn leaf spot as the research object, used the YOLOv5 model combined with MLFF (multi-feature fusion layer), added CABM attention module and detection Transformer (DETE), and constructed a pest and disease detection MCD-Yolov5 model, which realized the dynamic adjustment of the weights of the input image feature layer features. In addition, a drone platform was established for field testing. The model can achieve an accuracy of 88.12% for pest and disease recognition. Shuai et al. proposed a Maize-YOLO network based on YOLOv7. Through the CSPResNeXt-50 module and the VoVGSCSP module, it has faster detection accuracy and detection speed than the original model, and has a mAP of 76.3% on the public dataset IP102. Zhang et al. took corn borer, fall weevils and cotton bollworm as research objects, and proposed a corn pest identification method that combines the Adan optimizer to replace the optimizer of YOLOv7. The Adan optimizer is used to perceive the surrounding gradient information in advance and reduce the computing power of the model. The corn pest dataset was constructed by data expansion and compared with traditional methods and other commonly used network models. The improved method is 2.79%-11.83% higher than the original YOLOv7, and the computing power far exceeds the original network performance.

[0008] The two-stage algorithm needs to generate candidate regions and then identify them. The single-stage algorithm is an integrated process that saves detection time. Summary of the invention

[0009] In view of the above-mentioned deficiencies in the prior art, the present invention provides a corn pest recognition method based on improved YOLOv8 to solve the problem that corn pests have different sizes due to different shooting heights.

[0010] In order to achieve the above-mentioned object of the invention, the technical solution adopted by the present invention is:

[0011] A corn pest identification method based on improved YOLOv8, comprising the following steps:

[0012] Obtain corn pest images;

[0013] Constructing an improved YOLOv8 model; the improved YOLOv8 model includes a backbone network, a neck network and a head network;

[0014] The backbone network is used to extract features from corn pest images and the feature information is fused based on deformable convolution to generate a multi-scale feature map containing visual information at different levels.

[0015] The neck network is used to fuse multi-scale feature maps containing visual information at different levels to obtain a feature map that fuses multi-scale information;

[0016] The head network is used to predict corn pest recognition results based on feature maps that fuse multi-scale information.

[0017] Furthermore, the obtaining of corn pest images also includes:

[0018] The acquired corn pest images are subjected to image enhancement processing.

[0019] Furthermore, the image enhancement processing of the acquired corn pest image includes:

[0020] The acquired corn pest image is flipped and rotated.

[0021] Furthermore, the backbone network includes a first CBS module, a second CBS module, a first C2f module, a third CBS module, a second C2f module, a fourth CBS module, a third C2f module, a fifth CBS module, a deformable convolution module and an SPPF module, which are arranged in sequence from top to bottom.

[0022] Furthermore, the deformable convolution module first performs a convolution on the input feature map, then generates a compensation field for the output feature map through a convolution layer, interpolates the compensation field to obtain an offset, and finally obtains the offset feature map according to the output feature map and the offset.

[0023] Furthermore, a first global attention mechanism module is also included between the fifth convolution module and the deformable convolution module;

[0024] The first global attention mechanism module first obtains the channel attention weight through a multi-layer perceptron, and then multiplies the channel attention weight with the input feature map to obtain the channel attention feature map; then uses the convolution layer to perform spatial information fusion on the channel attention feature map to obtain the spatial attention weight, and finally multiplies the channel attention feature map with the spatial attention weight to obtain the global attention feature map.

[0025] Further, the neck network comprises:

[0026] The first upsampling module, the first splicing module, the fourth C2f module, the second upsampling module, the second splicing module, the fifth C2f module, the third upsampling module, the third splicing module and the sixth C2f module are arranged from bottom to top, and the second global attention mechanism module, the sixth CBS module, the fourth splicing module, the seventh C2f module, the seventh CBS module, the fifth splicing module, the eighth C2f module, the eighth CBS module, the sixth splicing module and the ninth C2f module are arranged from top to bottom;

[0027] The input end of the first upsampling module is connected to the output end of the SPPF module, the input end of the first splicing module is connected to the output end of the deformable convolution module, the input end of the second splicing module is connected to the output end of the second C2f module, the input end of the third splicing module is connected to the output end of the first C2f module, the input end of the second global attention mechanism module is connected to the output end of the sixth C2f module, the input end of the fourth splicing module is connected to the output end of the fifth C2f module, the input end of the fifth splicing module is connected to the output end of the fourth C2f module, and the input end of the sixth splicing module is connected to the output end of the SPPF module.

[0028] Furthermore, the head network includes:

[0029] A first detection head with a size of 20×20, a second detection head with a size of 40×40, a third detection head with a size of 80×80, and a fourth detection head with a size of 160×160;

[0030] The input end of the first detection head is connected to the output end of the ninth C2f module, the input end of the second detection head is connected to the output end of the eighth C2f module, the input end of the third detection head is connected to the output end of the seventh C2f module, and the input end of the fourth detection head is connected to the output end of the second global attention mechanism module.

[0031] Furthermore, the loss function of the improved YOLOv8 model is:

[0032] ;

[0033] in, , Respectively represent the square of the distance between the upper left point and the lower right point between the predicted box and the real box, and Represent the width and height of the predicted box and the real box respectively, Represents the overlap ratio between the predicted box and the true box.

[0034] The present invention has the following beneficial effects:

[0035] In order to improve the detection accuracy of corn pests and solve the problem of different sizes of corn pests, this study proposes a corn pest detection method based on improved YOLOv8. First, a global attention mechanism (GAM) module is added to the neck network part to enhance the feature map information, retain the mapping features, and improve the fusion ability and detection accuracy of the model. Then, some C2f modules are replaced with deformable convolution (DCN) modules before the SPPF layer of the backbone network, and the information of the feature map is fused with different convolution weights, and the detection ability of small targets is enhanced by combining the 160×160 scale detection head; the experimental results show that for corn pests, the improved GD-YOLOv8 model improves the accuracy, recall rate, mAP50, and mAP50-95 by 4.7, 3.7, 0.9, and 2.4 percentage points respectively compared with the YOLOv8 model. This method can provide accurate pest detection and identification for corn crops and achieve high-precision end-to-end pest detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 It is a flowchart of a corn pest identification method based on improved YOLOv8;

[0037] Figure 2 To improve the YOLOv8 model structure diagram;

[0038] Figure 3 Schematic diagram of the head network structure;

[0039] Figure 4 This is a precision diagram;

[0040] Figure 5 Schematic diagram of Recall accuracy. DETAILED DESCRIPTION

[0041] The specific implementation modes of the present invention are described below so that those skilled in the art can understand the present invention. However, it should be clear that the present invention is not limited to the scope of the specific implementation modes. For those of ordinary skill in the art, as long as various changes are within the spirit and scope of the present invention as defined and determined by the attached claims, these changes are obvious, and all inventions and creations utilizing the concept of the present invention are protected.

[0042] like Figure 1 As shown, a corn pest identification method based on improved YOLOv8 provided by an embodiment of the present invention includes the following steps S1 to S5:

[0043] S1, obtaining corn pest images;

[0044] S2. Construct an improved YOLOv8 model; the improved YOLOv8 model includes a backbone network, a neck network and a head network;

[0045] S3, using the backbone network to extract features from corn pest images and fuse feature information based on deformable convolution to generate a multi-scale feature map containing visual information at different levels;

[0046] S4, using the neck network to fuse the multi-scale feature maps containing visual information at different levels to obtain a feature map that fuses the multi-scale information;

[0047] S5. Use the head network to predict corn pest recognition results based on feature maps that integrate multi-scale information.

[0048] In an optional embodiment of the present invention, due to the impact of various factors such as ecology and climate change on the growth of pests, it makes collecting agricultural pest data quite challenging. This embodiment organizes the pest data set publicly available on the Kaggle website, and obtains a total of 278 original images of pests. These images are stored in JPG format of different sizes, with high clarity and rich colors, fully showing the morphological characteristics of the pests. Among them, the collected images of fall armyworm and corn borer pests contain different life cycles. Some of these pests are similar to the background, and some have complex image backgrounds. These factors make the identification of corn pests more difficult.

[0049] Therefore, after acquiring the corn pest image, this embodiment further includes:

[0050] Perform image enhancement processing on the acquired corn pest images.

[0051] Furthermore, the image enhancement processing of the acquired corn pest image includes:

[0052] The acquired corn pest image is flipped and rotated.

[0053] This embodiment uses data enhancement technology to effectively expand the data set to solve the network fitting problem and the data sample imbalance problem. This embodiment expands the original data set by flipping, rotating and other data enhancement methods to obtain 668 pictures. According to the image, it is divided into a training set, a test set, and a validation set according to 8:1:1.

[0054] In an optional embodiment of the present invention, YOLOv8 is a new network framework based on the YOLO series of algorithms. On the basis of the previous YOLO version, it integrates a number of new technologies to improve the detection speed and accuracy of the model. YOLOv8 is designed based on the concept of fast, accurate, higher performance, and easy to use, making it an excellent choice for a wide range of object detection, image segmentation, and image classification tasks.

[0055] YOLOv8 is mainly composed of three parts: backbone network, neck network and head network. The backbone network is mainly composed of multiple C2f modules, which are optimized based on the CSPDarknet network structure design. The characteristic of the CSPDarknet network structure is that the entire network is divided into two main parts, each of which is composed of multiple residual blocks. This design not only ensures that the network can fully learn and extract the deep features of the input data, but also effectively alleviates the problem of gradient disappearance through residual connections, making the model more stable during training.

[0056] The Neck part of the neck network adopts the PAN-FPN structure. Compared with the feature pyramid network (FPN), PAN-FPN adopts a bidirectional pathway architecture. This means that feature information can flow not only from high-level to low-level, but also from low-level to high-level. This bidirectional flow design enhances the flow of contextual information of features, allowing features to be more effectively integrated between different levels. In YOLOv8, the network structure has been further optimized. By removing the upsampling convolution structure, the transmission of underlying feature information to the high-level network becomes more direct and efficient. This simplification not only reduces the complexity of the network, but also promotes the effective integration of feature information between different levels.

[0057] The head network uses an Anchor-Free detection method that directly predicts the center point and width-height ratio of the target instead of predicting the position and size of the anchor box. In this way, the model can reduce the number of anchor boxes to improve the detection speed and accuracy of the model.

[0058] In an optional embodiment of the present invention, Figure 2 As shown, the backbone network includes a first CBS module, a second CBS module, a first C2f module, a third CBS module, a second C2f module, a fourth CBS module, a third C2f module, a fifth CBS module, a deformable convolution module and an SPPF module, which are arranged in sequence from top to bottom.

[0059] The deformable convolution module first performs a convolution on the input feature map, then generates a compensation field for the output feature map through a convolution layer, interpolates the compensation field to obtain an offset, and finally obtains the offset feature map according to the output feature map and the offset.

[0060] In the traditional convolutional neural network architecture, the convolution unit, also known as the convolution kernel, is responsible for sampling the input feature map at a fixed position. The features of the local area are extracted and integrated into the new feature map through the convolution operation. After the convolution layer, it is usually followed by the pooling layer, whose main function is to gradually reduce the dimension of the feature map, thereby reducing the number of parameters of the model and preventing overfitting to a certain extent. The pooling layer reduces the size of the feature map by selecting the maximum, minimum or average value of a specific area.

[0061] The pooling layer is another important component in CNN. The region of interest (RoI) pooling layer is a special type of pooling layer that generates a RoI (Region of Interest) with spatial position restrictions. The RoI pooling layer can map RoIs of different sizes to feature maps of fixed sizes, thereby facilitating subsequent operations such as classification or regression. However, despite the remarkable success of these network layers in image processing, they still have some limitations.

[0062] A major limitation is that due to the fixed weights of the convolution kernels, the size of the network's receptive field remains the same when processing different locations in the image. This feature means that the network's receptive field cannot be adaptively adjusted according to the size changes of objects in the image, which limits the network's flexibility in encoding position information. In practical applications, different areas of an image may correspond to objects of different scales or have undergone different deformations, which requires the model to automatically adjust its scale to adapt to these changes. Therefore, in order to more effectively handle geometric transformations in images, a mechanism that can adaptively adjust the scale is needed to better handle this situation.

[0063] Deformable ConvNets (DCN) does not change the way convolution is calculated, but adds a learnable parameter to the scope of the convolution operation. . Similarly, for each output , all from Upsample 9 positions, these 9 positions are the center positions ( ) diffused to the surroundings, but more , allowing the sampling points to diffuse into non-gird shapes, expressed as:

[0064] ;

[0065] in, Represents the position on the output feature map The pixel value, represents the weight, Represents the input feature map Indicates the location of the central sampling point; Indicates the sampling point location; Indicates the index number of each block; represents weight; Indicates the sampling point location The offset relative to the center position; Represents the mapping relationship between the original image and the feature map obtained by convolution.

[0066] This embodiment introduces a deformable convolutional network, replaces some C2F modules of the YOLOv8 network model with a deformable convolutional DCN, extracts features of different sizes of feature graph scales, and realizes feature extraction of pests of different scales.

[0067] In an optional embodiment of the present invention, a first global attention mechanism module is also included between the fifth convolution module and the deformable convolution module.

[0068] The first global attention mechanism module first obtains the channel attention weight through a multi-layer perceptron, and then multiplies the channel attention weight with the input feature map to obtain the channel attention feature map; then uses the convolution layer to perform spatial information fusion on the channel attention feature map to obtain the spatial attention weight, and finally multiplies the channel attention feature map with the spatial attention weight to obtain the global attention feature map.

[0069] The global attention mechanism module also includes a global average pooling layer and a global maximum pooling layer;

[0070] The global average pooling layer performs a global average pooling operation on the input feature map, extracts the global features of each channel, and then outputs the global features of each channel to the multi-layer perceptron;

[0071] The global maximum pooling layer performs a global maximum pooling operation on the input feature map, extracts the global features of each channel, and then outputs the global features of each channel to the multi-layer perceptron.

[0072] The global attention mechanism module also includes a convolutional layer;

[0073] The convolution layer performs a convolution operation on the input feature map and outputs the output feature map to the global average pooling layer and the global maximum pooling layer respectively.

[0074] The global attention mechanism module also includes a pooling layer;

[0075] The pooling layer performs feature fusion on the global attention feature map to obtain the final output feature map.

[0076] The purpose of incorporating the global attention mechanism (GAM) into the YOLOv8 network in this embodiment is to improve the efficiency and quality of image feature extraction. The goal of the global attention mechanism is to improve the overall performance of the deep neural network by optimizing information flow and enhancing global interactions between features. GAM, based on CBAM, sequentially adjusts the channel-space attention mechanism and reconstructs the submodules. In particular, in the spatial attention submodule, a double-layer convolution structure is adopted. This structure enables spatial information to be more effectively integrated through multi-level information fusion, thereby increasing the attention to spatial features. In order to avoid the information loss that may be caused by the maximum pooling operation, the pooling operation is deleted in this module. This is because the maximum pooling operation may also cause the loss of some important information while reducing the feature dimension. By omitting this step, the feature map can be better retained, thereby improving the accuracy of feature extraction. However, the spatial attention module may lead to an increase in the number of parameters. In order to effectively control the number of parameters, the module uses grouped convolution with channel shuffling function. This technology can not only reduce the number of parameters to a certain extent, but also improve the generalization ability of the model, thereby further enhancing the performance of the model.

[0077] The global attention mechanism (GAM) is an improvement on the convolutional block attention module (CBAM). CBAM applies attention mechanisms in the channel and spatial dimensions respectively, while GAM further introduces a global attention mechanism, which comprehensively considers the attention weights of the three dimensions of channel, spatial width and spatial height, significantly improving the performance of the model in object detection tasks.

[0078] GAM uses a unique approach to channel attention. First, it uses global average pooling and global maximum pooling operations to extract the global features of each channel. These two global features contain information at all positions in the channel and can fully reflect the importance of the channel.

[0079] Next, GAM feeds these two global features into a shared multi-layer perceptron (MLP). MLP transforms and reduces the global features through multiple layers of nonlinear transformations, further extracting the dependencies and high-level features between channels. The output of MLP is used as the basis for calculating the attention weights of each channel, which can reflect the importance of different channels in the target detection task.

[0080] After calculating the attention weights of each channel, GAM multiplies these weights with the original feature map to achieve channel attention weighting. In this way, the model will pay more attention to channels with higher weights in the subsequent feature extraction and object detection process, thereby improving the performance of the model.

[0081] This embodiment uses the global attention mechanism GAM to integrate deformable convolution and GAM attention with the YOLOv8 network, so that the improved YOLOv8 model can further enhance the feature image information extraction capability.

[0082] This embodiment introduces the GAM global attention mechanism in the Backbone part and replaces some C2f modules in the YOLOv8 network with C2f-DCN. First, the data-enhanced picture is input and convolved, mainly to expand the channel, reduce the feature map, and extract the deep features. Then the image enters the C2f module to obtain richer gradient information. Before entering the SPPF layer, we add the GAM attention mechanism to the network, the image is convolved, and the convolution layer uses a convolution kernel with a step size of 2 for downsampling operation to obtain a 1024*20*20 feature map. Then the input feature map is subjected to maximum pooling and average pooling, and after being processed separately by MLP, the maximum pooling and average pooling of the feature map are superimposed, and then convolution is performed, and Sigmoid activation is performed. Then, the feature map is input, and ordinary convolution is performed on the input image first, and then a convolution layer is added to the feature map. This is to obtain the offset of the deformable convolution. The offset uses the difference algorithm and is learned through back propagation to make it easier to focus on the pest features. Finally, the feature map is input into the pooling layer for feature fusion to achieve richer gradient combinations.

[0083] In an optional embodiment of the present invention, the neck network comprises:

[0084] The first upsampling module, the first splicing module, the fourth C2f module, the second upsampling module, the second splicing module, the fifth C2f module, the third upsampling module, the third splicing module and the sixth C2f module are arranged from bottom to top, and the second global attention mechanism module, the sixth CBS module, the fourth splicing module, the seventh C2f module, the seventh CBS module, the fifth splicing module, the eighth C2f module, the eighth CBS module, the sixth splicing module and the ninth C2f module are arranged from top to bottom;

[0085] The input end of the first upsampling module is connected to the output end of the SPPF module, the input end of the first splicing module is connected to the output end of the deformable convolution module, the input end of the second splicing module is connected to the output end of the second C2f module, the input end of the third splicing module is connected to the output end of the first C2f module, the input end of the second global attention mechanism module is connected to the output end of the sixth C2f module, the input end of the fourth splicing module is connected to the output end of the fifth C2f module, the input end of the fifth splicing module is connected to the output end of the fourth C2f module, and the input end of the sixth splicing module is connected to the output end of the SPPF module.

[0086] The head network includes:

[0087] A first detection head with a size of 20×20, a second detection head with a size of 40×40, a third detection head with a size of 80×80, and a fourth detection head with a size of 160×160;

[0088] The input end of the first detection head is connected to the output end of the ninth C2f module, the input end of the second detection head is connected to the output end of the eighth C2f module, the input end of the third detection head is connected to the output end of the seventh C2f module, and the input end of the fourth detection head is connected to the output end of the second global attention mechanism module.

[0089] Based on YOLOv8n, this embodiment uses the C2f-DCN convolutional network structure to replace the C2f module in YOLOv8n, introduces the GAM attention mechanism, and adds an additional small target detection head with a scale of 160×160. MPDIoU is used as the loss function to solve the problem of inaccurate recognition of the YOLOv8 model for complex backgrounds, corn pests of different sizes, and crops blocking pests.

[0090] In the self-built dataset, due to different shooting angles, the pests photographed have inconsistent sizes in the images. Large target pests have more obvious morphological, size and color features, while the features of small target pests may become blurred and difficult to identify. The original YOLOv8 detection layer outputs three feature maps of different sizes, namely 20×20, 40×40 and 80×80. When the pest target is too small, it cannot be detected. This embodiment is expanded on the basis of the YOLOv8n model architecture, specifically by adding a 160×160 resolution small target detection branch to the model to enhance the detection sensitivity of small target pests. GD-YOLOv8 performs feature extraction in the sixth layer of the backbone network to preliminarily capture key feature information. The Concat operation is used to implement the feature fusion strategy, and the features extracted in the shallow stage of the neck network are integrated with the GAM attention mechanism. By obtaining more small target feature information, the ability of the GD-YOLOv8 model to detect small target pests is greatly improved, and the false detection and missed detection of pests at different scales are effectively reduced. The improved detection layer is as follows Figure 3 shown.

[0091] During the shooting of corn pests, the stalks and leaves of corn will cause a certain degree of occlusion to the corn pests. In order to solve this problem, the overlapping or non-overlapping area, the center point distance, and the deviation of width and height are considered as the loss function. The IoU is calculated by minimizing the point distance between the predicted bounding box and the true bounding box, thereby simplifying the calculation process. The calculation formula is as follows:

[0092] ;

[0093] Among them, the bounding box and the real box represent the predicted bounding box and the real bounding box, ( ), ), ), ) are the coordinates of the upper left and lower right points of the bounding box and the ground truth box, respectively. , Respectively represent the square of the distance between the upper left point and the lower right point between the predicted box and the real box, and Represent the width and height of the predicted box and the real box respectively, Represents the overlap ratio between the predicted box and the true box.

[0094] In this embodiment, through the improvement of the above loss function, GD-YOLOv8 is more sensitive to occluded small targets in corn pest detection than the YOLOv8 model.

[0095] This embodiment integrates deformable convolution and GAM attention with the YOLOv8 network, which improves the precision, recall, mAP50, and mAP50-95 by 4%, 2.4%, 0.8%, and 1.8% respectively compared with the original model.

[0096] After the model is built, this embodiment uses Precision, Recall, and mAP as the main indicators for model verification. For target detection tasks, Precision is the best indicator to measure the detection accuracy of the model. mAP is based on the IOU between the predicted box and the real box to calculate the accuracy of the model. Recall represents the proportion of real corn pests detected. The higher the proportion, the more corn pests the model detects. The calculation formula of the verification index is as follows:

[0097] ;

[0098] ;

[0099] ;

[0100] Among them, TP (True Positive) indicates the number of positive classes predicted as positive classes, that is, the number of corn pest samples correctly predicted; FP (False Positives) indicates the number of negative classes predicted as positive classes, that is, the number of samples identified as non-pests as pests; FN (False Negative) indicates the number of positive classes predicted as negative classes, that is, the number of corn pest samples incorrectly predicted; represents the average accuracy of the i-th target, Indicates the number of target categories.

[0101] The present invention will now analyze and illustrate the performance of the method of the present invention in conjunction with specific experiments.

[0102] This experiment was conducted on servers equipped with RTX 2080 Ti (11GB) and Intel(R) Xeon(R) Platinum 8255C CPU. These GPUs were deployed based on Python 3.8 under the Linux Ubuntu 20.04 LTS operating system, and the model was built under the Pytorch 2.0.0 deep learning framework.

[0103] During the training of the corn crop pest detection model, the YOLOv8n weight parameters provided by the ultralytics framework were used as model learning initialization parameters and hyperparameter tuning to achieve the best detection performance of the entire network.

[0104] In order to distinguish the characteristics of the GAM module and the DCN module, this experiment conducts a comparative experiment, adding the GAM and DCN modules to the YOLOv8 network respectively, and analyzes the impact of each module on YOLOv8, such as Figure 4 , Figure 5 As shown in Table 1 and Table 2.

[0105] Table 1. Comparative test analysis table

[0106]

[0107] Table 2 Ablation experiment analysis table

[0108]

[0109] It can be seen that after adding the DCN module, Precision increased by 7 percentage points. The deformable convolution assigns weights to feature images with complex backgrounds, and the effect of improving precision is more significant. This shows that the deformable convolution DCN performs well in balancing model performance and precision. By adding only the GAM module, the recall rate of the model is 6.3 percentage points higher than that of the YOLOv8 model, making it pay more attention to the global information of the features and strengthening the correct identification of pests in pest samples. By integrating the two into the YOLOv8 model, the improved GD-YOLOv8 model has improved the precision, recall rate, mAP50, and mAP50-95 by 4.7, 3.7, 0.9, and 2.4 percentage points respectively compared with the YOLOv8 model, effectively improving the performance of the model and indicating the effectiveness of the proposed improved algorithm.

[0110] In complex backgrounds, the YOLOv8 model will fail to detect small targets. The improved YOLOv8 model has obvious advantages. By adding a small target detection head and using the MPDIoU loss function, it can be more sensitive to small targets.

[0111] Aiming at the rapid detection of corn pests in complex field natural environments, the present invention replaces the C2f module in the model with a deformable convolutional network structure and introduces a global attention mechanism on the basis of YOLOv8n, so as to improve the feature fusion ability of the model and enable the model to better learn the position and size of pest features. Finally, a corn pest detection model with higher detection accuracy is developed.

[0112] The model established by this invention has achieved good results in only two common corn pest identification tasks, but there are many types of corn pests. The next step of research will be to enrich the pest sample information and conduct further identification and real-time detection research. At the same time, the model is transplanted and verified and improved on the edge mobile platform to make the model lighter and easier to deploy.

[0113] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0114] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0115] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0116] The present invention uses specific embodiments to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

[0117] Those skilled in the art will appreciate that the embodiments described herein are intended to help readers understand the principles of the present invention, and should be understood that the protection scope of the present invention is not limited to such specific statements and embodiments. Those skilled in the art can make various other specific variations and combinations that do not deviate from the essence of the present invention based on the technical revelations disclosed by the present invention, and these variations and combinations are still within the protection scope of the present invention.

Claims

1. A corn pest identification method based on improved YOLOv8, characterized in that: The following steps are involved: Obtain corn pest images; Constructing an improved YOLOv8 model; the improved YOLOv8 model includes a backbone network, a neck network and a head network; The backbone network is used to extract features from corn pest images and the feature information is fused based on deformable convolution to generate a multi-scale feature map containing visual information at different levels. The neck network is used to fuse multi-scale feature maps containing visual information at different levels to obtain a feature map that fuses multi-scale information; The head network is used to predict corn pest recognition results based on feature maps that fuse multi-scale information.

2. A corn pest identification method based on improved YOLOv8 according to claim 1, characterized in that: The obtaining of corn pest images also includes: The acquired corn pest images are subjected to image enhancement processing.

3. A corn pest identification method based on improved YOLOv8 according to claim 2, characterized in that: The image enhancement processing of the acquired corn pest image comprises: The acquired corn pest image is flipped and rotated.

4. A corn pest identification method based on improved YOLOv8 according to claim 1, characterized in that: The backbone network includes a first CBS module, a second CBS module, a first C2f module, a third CBS module, a second C2f module, a fourth CBS module, a third C2f module, a fifth CBS module, a deformable convolution module and an SPPF module, which are arranged in sequence from top to bottom.

5. A corn pest identification method based on improved YOLOv8 according to claim 4, characterized in that: The deformable convolution module first performs a convolution on the input feature map, then generates a compensation field for the output feature map through a convolution layer, interpolates the compensation field to obtain an offset, and finally obtains the offset feature map according to the output feature map and the offset.

6. A corn pest identification method based on improved YOLOv8 according to claim 5, characterized in that: A first global attention mechanism module is also included between the fifth convolution module and the deformable convolution module; The first global attention mechanism module first obtains the channel attention weight through a multi-layer perceptron, and then multiplies the channel attention weight with the input feature map to obtain the channel attention feature map; then uses the convolution layer to perform spatial information fusion on the channel attention feature map to obtain the spatial attention weight, and finally multiplies the channel attention feature map with the spatial attention weight to obtain the global attention feature map.

7. A corn pest identification method based on improved YOLOv8 according to claim 6, characterized in that: The neck network includes: The first upsampling module, the first splicing module, the fourth C2f module, the second upsampling module, the second splicing module, the fifth C2f module, the third upsampling module, the third splicing module and the sixth C2f module are arranged from bottom to top, and the second global attention mechanism module, the sixth CBS module, the fourth splicing module, the seventh C2f module, the seventh CBS module, the fifth splicing module, the eighth C2f module, the eighth CBS module, the sixth splicing module and the ninth C2f module are arranged from top to bottom; The input end of the first upsampling module is connected to the output end of the SPPF module, the input end of the first splicing module is connected to the output end of the deformable convolution module, the input end of the second splicing module is connected to the output end of the second C2f module, the input end of the third splicing module is connected to the output end of the first C2f module, the input end of the second global attention mechanism module is connected to the output end of the sixth C2f module, the input end of the fourth splicing module is connected to the output end of the fifth C2f module, the input end of the fifth splicing module is connected to the output end of the fourth C2f module, and the input end of the sixth splicing module is connected to the output end of the SPPF module.

8. A corn pest identification method based on improved YOLOv8 according to claim 7, characterized in that: The head network includes: A first detection head with a size of 20×20, a second detection head with a size of 40×40, a third detection head with a size of 80×80, and a fourth detection head with a size of 160×160; The input end of the first detection head is connected to the output end of the ninth C2f module, the input end of the second detection head is connected to the output end of the eighth C2f module, the input end of the third detection head is connected to the output end of the seventh C2f module, and the input end of the fourth detection head is connected to the output end of the second global attention mechanism module.

9. A corn pest identification method based on improved YOLOv8 according to claim 8, characterized in that: The loss function of the improved YOLOv8 model is: ; in, , Respectively represent the square of the distance between the upper left point and the lower right point between the predicted box and the real box, and Represent the width and height of the predicted box and the real box respectively, Represents the overlap ratio between the predicted box and the true box.

Citation Information

Patent Citations

  • High-precision cigarette beetle detection method in complex scene

    CN113239825A

  • Deformable convolutional neural network-fused rice pest detection method and system

    CN116934723A

  • Marine litter target detection method based on yov8-CA-AFPN model

    CN117523380A

  • Method for improving YOLOv8 network and application of method in strip steel surface defect detection

    CN118365599A

  • YOLOv8n-based lightweight insect small target detection method and device

    CN118470402A

Cited By

  • Lightweight low-altitude remote sensing image adaptive global feature enhancement small target detection network

    CN120655901A

  • Method and device for detecting tomato diseases and insect pests based on improved YOLOv8

    CN120708213A

  • Fresh corn appearance detection method based on image fusion and deep learning

    CN120997627A

  • Insect situation monitoring camera and monitoring method thereof

    CN121170461A