Corn pest detection method based on DAS-YOLOv8
By building the DAS-YOLOv8 model, replacing the convolution module, integrating the attention mechanism and optimizing the loss function, the problems of large model parameters and poor detection effect in existing corn pest detection are solved, and lightweight and efficient pest detection is achieved.
Patent Information
- Application Number
- CN202510703255.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-29
- Publication Date
- 2025-09-19
AI Technical Summary
Existing corn pest detection methods have large model parameters and high computing resource requirements, making them difficult to apply on mobile devices. In addition, the detection effect in natural scenes is not ideal. Traditional methods have low accuracy and reliability and require a lot of manual intervention.
The DAS-YOLOv8 model is adopted. By replacing the C2f module of YOLOv8 with the C2f_DS module, using the Adown downsampling module to replace part of the traditional convolution, integrating the SimAM attention mechanism, and using the WIoU loss function, a lightweight network model is constructed.
Efficient and accurate corn pest detection is achieved on mobile devices, which reduces the number of model parameters and computational complexity and improves detection accuracy and robustness.
Smart Images

Figure CN120673223A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of target detection technology, and in particular to a corn pest detection method based on DAS-YOLOv8. Background Art
[0002] As one of the world's three major food crops, corn occupies a vital position in agricultural production. It is not only a vital source of human food but also widely used in animal husbandry, industrial raw materials, and bioenergy production. It plays an irreplaceable role in ensuring food security, promoting economic development, and maintaining social stability. However, corn is often threatened by pests such as corn borers, armyworms, and aphids during its growth process. These pests feed on leaves, stalks, and fruit, severely impacting corn growth, leading to reduced yield and deteriorating quality. Pests not only directly impact yield but can also trigger other diseases, increasing control costs. Therefore, accurate and timely pest detection is crucial for prevention and control. Understanding pest species, abundance, and distribution patterns can help develop effective control strategies, reduce pesticide overuse, lower environmental pollution and production costs, and improve agricultural efficiency.
[0003] Traditional pest detection methods are typically based on hand-designed feature extractors and classifiers, resulting in low accuracy and reliability, requiring extensive manual intervention and adjustment, and struggling to adapt to complex and changing natural scenarios. Pest detection methods based on deep learning technology, on the other hand, can automatically extract features and classify, offering higher accuracy and robustness. However, these methods require large amounts of labeled data and computing resources, and their excessive number of model parameters makes them difficult to apply on mobile devices. Therefore, to address the issues of existing models with large number of parameters and less-than-ideal detection results for natural scene images, designing efficient and accurate lightweight network models for detecting crop pest larvae is essential for pest monitoring, the development of precise control measures, and their deployment on mobile devices. Summary of the Invention
[0004] The present invention proposes a corn pest detection method based on DAS-YOLOv8.
[0005] In order to solve the above technical problems, the technical solutions of the present invention are as follows:
[0006] A corn pest detection method based on DAS-YOLOv8, comprising the following steps:
[0007] Step 1: Collect different types of corn pest image data;
[0008] Step 2: preprocess the collected corn pest data to construct a corn pest dataset;
[0009] Step 3: Build the DAS-YOLOv8 corn pest detection network model:
[0010] (3a) Construct the C2f_DS module: it contains two 3×3 convolutional layers, one Split layer, n DSBottleneck modules, and one Cancat module;
[0011] (3b) Use the C2f_DS module to replace the C2f module of YOLOv8 to reduce the number of model parameters and computational complexity;
[0012] (3c) Replace some traditional convolutions in the YOLOv8 model with Adown downsampling modules to reduce model complexity;
[0013] (3d) The SimAM attention mechanism is added to the YOLOv8 model to adaptively highlight the spatial region of the pest target while suppressing the influence of background noise;
[0014] (3e) Using WIoU to optimize the original loss function;
[0015] Step 4: Use the preprocessed data set to train the DAS-YOLOv8 model to obtain a trained DAS-YOLOv8 model;
[0016] Step 5: Corn pest detection based on the DAS-YOLOv8 model:
[0017] The image to be detected is input into the trained DAS-YOLOv8 network model to obtain the detection results, including the location, category, and confidence level of the pests.
[0018] In step 2, the preprocessing includes image rotation, horizontal flipping, spatial translation, brightness adjustment, adding Gaussian noise, and data label format conversion;
[0019] In the step (3a), the DSBottleneck module is divided into two types: DSBottleneck1 and DSBottleneck2. DSBottleneck1 consists of two 3×3 depth-separable convolutional layers and one residual connection, and DSBottleneck2 consists of two 3×3 depth-separable convolutional layers;
[0020] The depthwise separable convolutional layer consists of one 3×3 depthwise convolution and one 1×1 pointwise convolution;
[0021] In step (3b), the following method is used to replace the C2f module of YOLOv8 with the C2f_DS module:
[0022] Replace all C2f modules in the YOLOv8 model with C2f_DS modules;
[0023] In step (3c), some traditional convolutions in the YOLOv8 model are replaced with Adown downsampling modules using the following method:
[0024] Replace the Conv modules except the first and second layers of the YOLOv8 model with the Adown downsampling module;
[0025] The Adown downsampling module consists of 1 average pooling module, 1 maximum pooling module, 1 1x1 convolution layer, 1 3x3 convolution layer, 1 Split module, and 1 Concat module;
[0026] In step (3d), the SimAM attention mechanism is added to the YOLOv8 model using the following method:
[0027] After adding SimAM attention to the backbone network, the features extracted by the backbone network are enhanced and its output is connected to the neck of YOLOv8 to ensure seamless transmission of information in the network;
[0028] SimAM is a parameter-free attention mechanism. Its core concept is to evaluate the importance of each neuron in the feature map through an energy function, automatically generating attention weights and applying them to the original feature map. This allows the model to adaptively allocate attention across different spatial and channel locations, thereby improving the ability to extract key features. Compared to traditional attention mechanisms, SimAM does not require the introduction of additional trainable parameters, reducing computational complexity while simultaneously capturing contextual information in both channel and spatial dimensions.
[0029] In step (3e), the WIoU loss function is defined as:
[0030]
[0031] L IoU =1-IoU
[0032] L WIoU =r×R WIoU ×L IoU
[0033]
[0034] Where IoU is the intersection-over-union ratio between the real box and the predicted box, B gt is the actual bounding box, B prd To predict the bounding box, (x, y) and (x gt ,y gt ) represent the center coordinates of the predicted box and the real box respectively; W g and H gRepresents the width and height of the minimum bounding rectangle, and r represents the gradient gain coefficient.
[0035] The step 4 comprises:
[0036] Step 4.1: Use the preprocessed image dataset as the input of the DAS-YOLOv8 model, and perform mosaic data enhancement and adaptive image scaling in sequence;
[0037] Step 4.2: Extract features in the feature extraction backbone network through the Conv module, C2f_DS module, Adown downsampling module and SimAM attention;
[0038] Step 4.3: In the neck network Neck module, a combination of feature pyramid FPN and path aggregation network PAN is used to perform multi-scale fusion of different feature maps;
[0039] Step 4.4: Use the WIoU loss function to calculate the score of the target proposal box;
[0040] Step 4.5: Use non-maximum suppression (NMS) to suppress the suggestion boxes smaller than the threshold and retain the suggestion boxes larger than the threshold.
[0041] Step 4.6: Set the number of training rounds. When the maximum number of training rounds is reached, the trained network model is obtained.
[0042] Compared with the prior art, the beneficial effects of the present invention are as follows: the present invention proposes a corn pest detection method based on DAS-YOLOv8. Specifically, the present invention replaces the C2f module of YOLOv8 with the C2f_DS module, significantly reducing the number of parameters and computational complexity while retaining the feature extraction capability. In addition, some traditional convolutions in the YOLOv8 model are replaced with the Adown downsampling module, reducing the complexity of the model. Furthermore, the SimAM parameter-free attention mechanism is integrated to enhance the model's spatial focusing ability on pest targets without increasing trainable parameters. At the same time, the WIoU dynamic focusing loss function is used to solve the problem of the existing loss function and achieve more accurate regression results. The DAS-YOLOv8 lightweight network model proposed in the present invention provides an effective technical solution for the detection of corn pests. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 Flowchart of the corn pest detection method based on DAS-YOLOv8 in Example 1
[0044] Figure 2 Part of the data enhancement picture of Example 1
[0045] Figure 3The number of categories and labels of the IP11-Corn dataset in Example 1
[0046] Figure 4 This is the C2f_DS module structure diagram of Example 1
[0047] Figure 5 This is the DSBottleneck module structure diagram of Example 1
[0048] Figure 6 This is the depth-separable convolution structure diagram of Example 1
[0049] Figure 7 Adown downsampling module structure diagram of Example 1
[0050] Figure 8 The overall structure diagram of the DAS-YOLOv8 network model of Example 1
[0051] Figure 9 The test result diagram of Example 1 DETAILED DESCRIPTION
[0052] The present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0053] Reference Figure 1 The implementation steps of the present invention are described in further detail.
[0054] Example 1
[0055] Step 1: Collect different types of corn pest image data:
[0056] The corn pest image data collected comes from the IP102 dataset, which contains images of 11 corn pest species: grub, mole cricket, wireworm, black cutworm, large cutworm, yellow cutworm, red spider, corn borer, army worm, aphid, Potosiabre vitarsis, and peach borer.
[0057] Step 2: Preprocess the collected corn pest data to construct a corn pest dataset. The preprocessing includes image rotation, horizontal flipping, spatial translation, brightness adjustment, Gaussian noise addition, and data label format conversion.
[0058] The original dataset was randomly divided into training set, validation set and test set in a ratio of 7:2:1. The original training set was augmented using data augmentation technology, while the validation set and test set were not processed. Specific operations included image rotation, horizontal flipping, spatial translation, brightness adjustment and adding Gaussian noise. The amplified dataset is the final dataset IP11-Corn, which contains 7,875 corn pest images. Finally, the data labels were converted from XML format to TXT format suitable for YOLO. Some data augmentation images are shown below. Figure 2 As shown, the specific number of categories and labels are as follows Figure 3 As shown;
[0059] Step 3: Build the DAS-YOLOv8 corn pest detection network model:
[0060] (3a) Construct the C2f_DS module, and its network structure is shown in the following figure. Figure 4 As shown, it contains 2 3×3 convolutional layers, 1 Split layer, n DSBottleneck modules, and 1 Cancat module;
[0061] In step (3a), the DSBottleneck module is divided into two types: DSBottleneck1 and DSBottleneck2. The network structure diagram is as follows: Figure 5 As shown, DSBottleneck1 consists of two 3×3 depth-separable convolutional layers and one residual connection. DSBottleneck1 consists of two 3×3 depth-separable convolutional layers;
[0062] The 3×3 depthwise separable convolutional layer performs deep convolution on the input feature map to extract features, while the residual connection can alleviate the problem of vanishing gradients. The DSBottleneck1 module maintains the original residual structure of Bottleneck and is used in the backbone network to prevent the occurrence of deep network degradation. DSBottleneck2 is composed of two cascades of depthwise separable convolutions. The C2f module containing DSBottleneck2 is used in the feature fusion network.
[0063] In step (3a), the depthwise separable convolution layer consists of one 3×3 depthwise convolution and one 1×1 pointwise convolution. The convolution process is as follows: Figure 6 shown.
[0064] Depthwise separable convolution decomposes the standard convolution operation into two parts: the first part is depthwise convolution, which uses an independent convolution kernel for convolution of each input channel, and the output is the spatial information of each channel; the second part is pointwise convolution, which linearly combines the output of depthwise convolution with a 1×1 convolution kernel to generate the final feature map. This decomposition operation greatly reduces the number of convolution kernels, and because the convolution of each channel is performed independently, the amount of computation is significantly reduced;
[0065] (3b) Use the C2f_DS module to replace the C2f module of YOLOv8 to reduce the number of model parameters and computational complexity;
[0066] Replace all C2f modules in the YOLOv8 model with C2f_DS modules;
[0067] (3c) Replace some traditional convolutions in the YOLOv8 model with Adown downsampling modules to reduce model complexity;
[0068] Replace the Conv modules except the first and second layers of the YOLOv8 model with the Adown downsampling module;
[0069] In step (3c), the Adown downsampling module consists of 1 average pooling module, 1 maximum pooling module, 1 1×1 convolution layer, 1 3×3 convolution layer, 1 Split module, and 1 Concat module;
[0070] The Adown downsampling module structure is as follows Figure 7 As shown in the figure, the feature map first undergoes 2×2 average pooling with a step size of 1, which can effectively reduce the edge effect while retaining spatial information. Then, the feature map is evenly divided into two parts and divided into two branches. The number of channels of each branch is halved, thereby effectively reducing the computational overhead while ensuring information transmission. The first branch extracts local spatial features through 3×3 convolution, and further improves the detection accuracy by enhancing the model's perception of feature areas. The second branch first undergoes a maximum pooling operation, and then performs channel reorganization through 1×1 convolution to highlight the spatial position and intensity of significant features and reduce the interference of redundant information. This design can effectively retain the key features in the image without adding additional computational burden. The outputs of the last two branches are spliced through the Concat module to obtain the output of the Adown downsampling module;
[0071] (3d) The SimAM attention mechanism is added to the YOLOv8 model to adaptively highlight the spatial region of the pest target while suppressing the influence of background noise;
[0072] After adding SimAM attention to the backbone network, the features extracted by the backbone network are enhanced and its output is connected to the neck of YOLOv8 to ensure seamless transmission of information in the network. The overall structure of the DAS-YOLOv8 network model is shown in the figure below. Figure 8 As shown;
[0073] In step (3d), SimAM is a parameter-free attention mechanism. Its core idea is to evaluate the importance of each neuron in the feature map through an energy function, thereby automatically generating attention weights and applying them to the original feature map. This allows the model to adaptively allocate attention across different spatial and channel locations, thereby improving the ability to extract key features. Compared to traditional attention mechanisms, SimAM does not require the introduction of additional trainable parameters, which not only reduces computational complexity but also captures contextual information simultaneously in the channel and spatial dimensions.
[0074] Specifically, for the input feature map X, SimAM first defines a unified energy function to measure the degree of neuron activation at each spatial position. For a spatial position in the feature map, its minimum energy function can be expressed as:
[0075]
[0076] Where σ 2 is the variance of all neuron values in the entire channel, λ is the regularization coefficient, t is the value of the target neuron, and μ represents the mean of all neuron values in the entire channel. By minimizing this energy function, SimAM is able to quantify the relative importance of each spatial position. Regions with lower importance correspond to higher energy values, while regions with higher importance correspond to lower energy values. The lower the energy, the greater the difference between the neuron and the surrounding neurons, that is, the more linearly separable the two neurons are, the higher their importance. Based on this, the attention weight can be calculated by 1 / e t * It is generated in the form of and acts on the original feature map to enhance the feature expression of the key area. The final output can be expressed as:
[0077]
[0078] Where E will all e t * Grouping across channels and spatial dimensions. The role of the Sigmoid activation function is to limit the E value from being too large and not affect the importance of each neuron;
[0079] (3e) Using WIoU to optimize the original loss function;
[0080] In order to accelerate the convergence of the network model and improve detection accuracy, the WIoU loss function is introduced to enable the model to more balancedly optimize samples of different scales and difficulties during training. WIoU can reduce the competitiveness of high-quality anchor frames while reducing the harmful gradients generated by low-quality samples by dynamically adjusting the gradient gain and loss weight. The WIoU loss function can assign small gradient gains to low-quality anchor frames and focus more attention on anchor frames of average quality, which has a good effect on improving model performance and generalization. The WIoU loss function is defined as:
[0081]
[0082] L IoU =1-IoU
[0083] L WIoU =r×R WIoU ×L IoU
[0084]
[0085] Where IoU is the intersection-over-union ratio between the real box and the predicted box, B gt is the actual bounding box, B prd To predict the bounding box, (x, y) and (x gt ,y gt ) represent the center coordinates of the predicted box and the real box respectively; W g and H g represents the width and height of the minimum bounding rectangle, and r represents the gradient gain coefficient;
[0086] Step 4: Use the preprocessed dataset to train the DAS-YOLOv8 model to obtain the trained DAS-YOLOv8 model, including:
[0087] Step 4.1: Use the preprocessed image dataset as the input of the DAS-YOLOv8 model, and perform mosaic data enhancement and adaptive image scaling in sequence;
[0088] Step 4.2: Extract features in the feature extraction backbone network through the Conv module, C2f_DS module, Adown downsampling module and SimAM attention;
[0089] Step 4.3: In the neck network Neck module, a combination of feature pyramid FPN and path aggregation network PAN is used to perform multi-scale fusion of different feature maps;
[0090] Step 4.4: Use the WIoU loss function to calculate the score of the target proposal box;
[0091] Step 4.5: Use non-maximum suppression (NMS) to suppress the suggestion boxes smaller than the threshold and retain the suggestion boxes larger than the threshold.
[0092] Step 4.6: Set the number of training rounds. When the maximum number of training rounds is reached, the trained network model is obtained.
[0093] In this embodiment, a 640*640 image is input at the input end, and mosaic data enhancement and adaptive image scaling processing are performed in sequence. In the feature extraction backbone network (Backbone), the Conv module, C2f_DS module, Adown downsampling module and SimAM attention module are sequentially performed to extract features. In the neck (Neck), a combination of feature pyramid (FPN) and path aggregation network (PAN) is used to perform multi-scale fusion of features. The fused features are then first subjected to the WIoU loss function to calculate the difference between the predicted border and the actual border to obtain the score of the target suggestion box. The non-maximum suppression NMS is then used to screen the score of the target suggestion box, retaining those greater than the threshold and deleting those less than the threshold.
[0094] Step 5: Corn pest detection based on the DAS-YOLOv8 model:
[0095] Input the image to be detected into the trained DAS-YOLOv8 network model to obtain the detection results, including the location, category and confidence of the pests, such as Figure 9 shown.
[0096] Table 1 Experimental environment and parameter settings
[0097]
[0098] The specific experimental environment and parameter settings for this example are as follows: All experiments were conducted on a computer configured with an Intel(R) Xeon(R) Platinum 8362 CPU @ 2.80GHz, an RTX 3090 (24GB) GPU, and Windows 10. A DAS-YOLOv8 network model was constructed based on the PyTorch framework and trained using the SGD optimizer. The image input size was 640×640, the batch size was 16, the learning rate was 0.01, and a cosine annealing strategy was used for training. Training was performed for 150 epochs, and model performance was evaluated at the end of each epoch, with the optimal model weights saved. The details are shown in Table 1.
[0099] In order to better illustrate the technical effects of the present invention, in this embodiment, the performance of the method proposed in the present invention is compared with the existing target detection algorithm.
[0100] Table 2 Performance comparison of DAS-YOLOv8 and existing target detection models
[0101]
[0102] As shown in Table 2, DAS-YOLOv8 is compared with SSD, Faster-R-CNN, YOLOv3, YOLOv5n, YOLOv6n, YOLOv7-tiny, YOLOv8n and YOLOv11n target detection models in terms of mAP value, parameter amount (Params), floating point number (FLOPs), and FPS indicators, where GFLOPs = 10 9 FLOPs.
[0103] As shown in Table 2, compared to other object detection algorithms, the proposed method achieves the highest mAP value. Furthermore, the proposed method has fewer model parameters and computational complexity, and also achieves a high FPS.
[0104] The above description is merely a specific embodiment of the present invention and is not intended to limit the manner in which the present invention is to be practiced. However, those skilled in the art will recognize that any modification, equivalent substitution, or improvement that violates the spirit and principles of the present invention is prohibited. Any modification, equivalent substitution, or improvement that is within the spirit and principles of the present invention is intended to be within the scope of protection of the present invention.
Claims
1. A corn pest detection method based on DAS-YOLOv8, characterized in that: The following steps are involved: Step 1: Collect different types of corn pest image data; Step 2: preprocess the collected corn pest data to construct a corn pest dataset; Step 3: Build the DAS-YOLOv8 corn pest detection network model: (3a) Construct the C2f_DS module; (3b) Use the C2f_DS module to replace the C2f module of YOLOv8 to reduce the number of model parameters and computational complexity; (3c) Replace some traditional convolutions in the YOLOv8 model with Adown downsampling modules to reduce model complexity; (3d) The SimAM attention mechanism is added to the YOLOv8 model to adaptively highlight the spatial region of the pest target while suppressing the influence of background noise; (3e) Using WIoU to optimize the original loss function; Step 4: Use the preprocessed data set to train the DAS-YOLOv8 model to obtain a trained DAS-YOLOv8 model; Step 5: Corn pest detection based on the DAS-YOLOv8 model: The image to be detected is input into the trained DAS-YOLOv8 network model to obtain the detection results, including the location, category, and confidence level of the pests.
2. A corn pest detection method based on DAS-YOLOv8 according to claim 1, characterized in that: The preprocessing in step 2 includes image rotation, horizontal flipping, spatial translation, brightness adjustment, adding Gaussian noise and data label format conversion.
3. The corn pest detection method based on DAS-YOLOv8 according to claim 1, characterized in that: The C2f_DS module in step (3a) includes two 3×3 convolutional layers, one Split layer, n DSBottleneck modules, and one Cancat module.
4. The corn pest detection method based on DAS-YOLOv8 according to claim 1, characterized in that: In step (3b), the following method is used to replace the C2f module of YOLOv8 with the C2f_DS module: Replace all C2f modules in the YOLOv8 model with C2f_DS modules.
5. The corn pest detection method based on DAS-YOLOv8 according to claim 1, characterized in that: In step (3c), the following method is used to replace part of the traditional convolution in the YOLOv8 model with the Adown downsampling module: Replace the Conv modules in the YOLOv8 model except the first and second layer networks with the Adown downsampling module.
6. The corn pest detection method based on DAS-YOLOv8 according to claim 1, characterized in that: In step (3d), the SimAM attention mechanism is added to the YOLOv8 model using the following method: After adding SimAM attention to the backbone network, the features extracted by the backbone network are enhanced and its output is connected to the neck of YOLOv8 to ensure seamless transmission of information in the network.
7. The corn pest detection method based on DAS-YOLOv8 according to claim 1, characterized in that: In step (3e), the following method is used to define WIoU and optimize the original loss function: The WIoU loss function is defined as: L IoU =1-IoU L WIoU =r×R WIoU ×L IoU Where IoU is the intersection-over-union ratio between the real box and the predicted box, B gt is the actual bounding box, B prd To predict the bounding box, (x, y) and (x gt ,y gt ) represent the center coordinates of the predicted box and the real box respectively; W g and H g Represents the width and height of the minimum bounding rectangle, and r represents the gradient gain coefficient.
8. The corn pest detection method based on DAS-YOLOv8 according to claim 1, characterized in that: The step 4 comprises: Step 4.1: Use the preprocessed image dataset as the input of the DAS-YOLOv8 model, and perform mosaic data enhancement and adaptive image scaling in sequence; Step 4.2: Extract features in the feature extraction backbone network through the Conv module, C2f_DS module, Adown downsampling module and SimAM attention; Step 4.3: In the neck network Neck module, a combination of feature pyramid FPN and path aggregation network PAN is used to perform multi-scale fusion of different feature maps; Step 4.4: Use the WIoU loss function to calculate the score of the target proposal box; Step 4.5: Use non-maximum suppression (NMS) to suppress the suggestion boxes smaller than the threshold and retain the suggestion boxes larger than the threshold. Step 4.6: Set the number of training rounds. When the maximum number of training rounds is reached, the trained network model is obtained.
Citation Information
Cited By
End-cloud collaborative optimization method and device, computer equipment and storage medium
CN122157069A
Crushed material and waste material sorting method and system based on improved YOLOv8
CN122265663A