Pest detection method and system based on MDCA and FFEM feature fusion
By embedding MDCA and FFEM feature fusion modules in the YOLOV8n network, the problems of low efficiency and poor accuracy of existing pest detection methods are solved, and more efficient and accurate pest detection is achieved.
Patent Information
- Application Number
- CN202411596613.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-11
- Publication Date
- 2025-04-01
AI Technical Summary
Existing pest detection methods rely on individual subjective cognition and experience, have low detection efficiency, and in the context of complex rice fields, machine learning methods require high-quality images and manual feature extraction, affecting detection accuracy and speed.
Using a pest detection method based on MDCA and FFEM feature fusion, by embedding MDCA modules and FFEM feature fusion networks in the YOLOV8n network, the feature extraction efficiency is improved, the receptive field is expanded, and the channel feature fusion ability is enhanced.
It realizes the perception of surrounding targets on a larger scale while being lightweight, adaptive channel feature fusion, captures important information in pest images, improves detection accuracy and speed, and enhances the generalization ability of the model.
Smart Images

Figure CN119741731A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a pest detection method and system, and in particular to a pest detection method and system based on MDCA and FFEM feature fusion. Background Art
[0002] Pests are one of the main causes of agricultural safety and rice production. Rice and other food crops occupy an important share in the world's agricultural production sector, and a large number of food products are seriously affected by pests. China has a wide range of food crops. Pests such as rice planthoppers and rice leaf rollers directly suck rice juice or eat leaves, causing rice growth to be blocked, affecting photosynthesis and nutrient accumulation. And its pests spread very quickly, and without prevention and control, it will easily cause a lot of losses. Therefore, timely and accurate detection of rice pest types has great scientific research, economic and social value, can quickly take targeted prevention and control measures, reduce the production losses of rice caused by pests, and avoid blind use of pesticides to cause ecological and environmental pollution. At the same time, it has great practical significance and broad application prospects for studying effective rice pest control methods and environment, protecting the ecological environment, and achieving sustainable agricultural development.
[0003] The traditional method of pest detection is to use the naked eye to perceive the color, appearance and other attributes of insects, and compare them with existing specimens, or classify them based on existing pest maps. It relies too much on individual subjective cognition and experience, and there are limited experts and technicians who master pest detection, so the detection efficiency is too low. With the application of machine learning technology in agricultural pest detection, such as multi-layer perceptron and BP neural network, the above problems can be solved to a certain extent by analyzing color, texture and size. However, the use of machine learning requires high-quality images and manual feature extraction. In real rice fields, the background is complex and in a moving state, which will significantly affect the detection accuracy and speed of pests.
[0004] In order to deal with pest image data with complex features, deep learning target detection methods have gradually become the mainstream choice. At present, domestic and foreign researchers have conducted research in this area. For example, Cheng et al. used Alexnet and residual learning to identify pest images in complex farmland backgrounds. Compared with traditional BP neural networks, this method has stronger recognition performance. Yang et al. used feature pyramids to connect low-level features with high-level features, and improved the lightweight SqueezeNet model to make the network model suitable for the study of garden insects. However, there are still certain limitations when targeting small target insects. Xiao Deqin et al. proposed an end-to-end MPFR-CNN based on the FasterR-CNN model. By deepening the number of backbone network layers and combining FPN to detect pests trapped by yellow boards, it is difficult to deploy it in actual scenarios due to its complex model and long running time. These problems directly affect the performance of the model to a certain extent, resulting in poor model detection results. Summary of the invention
[0005] Purpose of the invention: The purpose of the present invention is to provide a pest detection method and system based on MDCA and FFEM feature fusion, which can improve feature extraction efficiency, expand the receptive field of feature extraction, and enhance channel feature fusion capability.
[0006] Technical solution: The pest detection method based on MDCA and FFEM feature fusion described in the present invention comprises:
[0007] Collect pictures containing pest targets, build a data set, and divide the data set into training set, test set, and validation set;
[0008] Improvements are made based on the YOLOV8n network to establish a pest detection model; the improvements include replacing the original C2f module with the MDCA module to reduce the model parameters while expanding the receptive field through depth-separable convolutions with different convolution steps, and replacing the original SPPF module with the FFEM feature fusion network to enhance the recognition ability of different models and reduce parameters and calculations;
[0009] The pest detection model is trained using a training set and a test set, and pest targets are detected using the trained pest detection model.
[0010] Furthermore, the collection of pictures containing pest targets, establishing a data set, and dividing the data set into a training set, a test set, and a validation set includes:
[0011] Collect pictures containing pest targets, convert all pictures into a preset format, and make a data set; annotate all picture data sets; divide the prepared data set into training set, test set, and validation set according to the preset ratio.
[0012] Furthermore, the MDCA module includes a convolution block and a depthwise separable convolution block; the MDCA module first subjects the input feature map to a 1×(2d-1) depthwise separable convolution operation to generate a first intermediate feature map, and then the intermediate feature map undergoes a (2d-1)×1 depthwise separable convolution twice, and a 1×(k / d) and (2d-1)×1 depthwise separable convolution once each, and then the obtained feature map is subjected to a (k / d)×1 depthwise separable convolution, and finally a 1×1 convolution operation to obtain a third feature map output by MDCA, where k is the kernel size and d is the dilation rate.
[0013] Furthermore, the FFEM feature fusion network implementation method is:
[0014] The feature map extracted from the YOLOv8n backbone network is divided into multiple parts, the feature expression is enhanced through the normalization and activation function of the MBConv module, the local information is captured by deep convolution, and the features of different parts are fused through splicing operations. Finally, the features are refined through 1x1 convolution and the comprehensive feature map is output.
[0015] Furthermore, the MBConv module is a basic building block, and the implementation method of the MBConv module is: using 1x1 convolution to increase the dimension of the feature, then performing a depth-wise separable convolution DW operation, and then passing the feature through a Squeeze-and-Excitation module, and then using 1×1 convolution again to reduce the dimension.
[0016] Furthermore, the use of the training set and the test set to train the pest detection model includes:
[0017] The training set is input into the pest detection model for training, and a number of pictures are trained in each batch, and one round of training is defined as one round of training in which all pictures in the training set are trained once. During training, the picture size is adjusted to a preset size, and the pest detection model continuously extracts features and performs two-fold upsampling on the input picture until the feature map size reaches a preset size. The prediction head performs prediction on feature maps of several preset sizes, and after reaching a specified training round, the result with the highest training parameter among all rounds is selected and saved.
[0018] Furthermore, the FFEM feature fusion network also includes performing DropPath regularization and Shortcut connection operations after finally refining the features through 1x1 convolution.
[0019] Based on the same inventive concept, the present invention also provides a pest detection system based on MDCA and FFEM feature fusion, comprising:
[0020] The preprocessing module is used to collect pictures containing pest targets, build a data set, and divide the data set into a training set, a test set, and a validation set;
[0021] A model building module, used to improve the YOLOV8n network and establish a pest detection model; the improvements include replacing the original C2f module with the MDCA module to reduce the model parameters while expanding the receptive field through depth-separable convolutions with different convolution steps, and replacing the original SPPF module with the FFEM feature fusion network to enhance the recognition ability of different models and reduce parameters and calculations;
[0022] The monitoring module is used to train the pest detection model using a training set and a test set, and detect pest targets using the trained pest detection model.
[0023] Based on the same inventive concept, the present invention also provides a computing device, comprising: one or more processors, one or more memories and one or more programs, wherein the programs are stored in the memories and configured to be executed by the processors, and when the programs are loaded into the processors, the steps of the pest detection method based on MDCA and FFEM feature fusion as described in any one of the above items are implemented.
[0024] Based on the same inventive concept, the present invention also provides a storage medium, which stores a computer program, and the computer program includes program instructions, which, when executed by a processor, enable the processor to perform the steps of the pest detection method based on MDCA and FFEM feature fusion according to any of the above items.
[0025] Beneficial effects: Compared with the prior art, the present invention embeds the MDCA module and the FFEM feature fusion network in YOLOv8n, which can perceive surrounding targets in a larger range while being lightweight, and fuse and weight features from different stages to make full use of their complementarity, and capture important information in pest images through adaptive channel feature fusion; the present invention designs the MDCA module and uses deep separable convolution combined with different convolution steps to effectively extract and fuse features of different scales and directions, thereby enhancing the expressiveness of features; these operations not only improve the utilization efficiency of parameters, but also help capture long-distance dependencies in the input feature map, thereby providing a richer and more robust feature representation for subsequent target detection tasks; the present invention designs the FFEM feature fusion network and uses convolution kernels of different sizes to effectively capture and enhance the model's recognition ability for targets of different sizes; in addition, it adopts deep separable convolution and compound scaling methods to significantly reduce the number of parameters and the amount of calculation while maintaining high performance, thereby improving parameter and calculation efficiency; at the same time, it further incorporates the DropPath regularization technology, which helps to prevent overfitting and enhance the generalization ability of the model, showing strong adaptability. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 is a flow chart of a method according to an embodiment of the present invention;
[0027] Figure 2 This is a schematic diagram of the MDCA module structure of an embodiment of the present invention;
[0028] Figure 3 This is a schematic diagram of the FFEM feature fusion structure of an embodiment of the present invention;
[0029] Figure 4 Schematic diagram of the MBConv module structure according to an embodiment of the present invention;
[0030] Figure 5 A schematic diagram of the structure of a pest detection model according to an embodiment of the present invention;
[0031] Figure 6 Schematic diagram of the detection results of an embodiment of the present invention. DETAILED DESCRIPTION
[0032] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0033] As attached Figure 1 As shown, the pest detection method based on MDCA and FFEM feature fusion of this embodiment includes:
[0034] S1: Collect pictures containing pest targets, build a dataset, and divide the dataset into training set, test set, and validation set;
[0035] S2: Improvements are made based on the YOLOV8n network to establish a pest detection model; the improvements include replacing the original C2f module with the MDCA module to reduce the model parameters while expanding the receptive field through depthwise separable convolutions with different convolution steps, and replacing the original SPPF module with the FFEM feature fusion network to enhance the recognition ability of different models and reduce parameters and calculations;
[0036] S3: Use the training set and the test set to train the pest detection model, and use the trained pest detection model to detect pest targets.
[0037] The specific steps are as follows:
[0038] S1. Create a picture dataset containing pest targets, annotate the dataset, and divide it into appropriate proportions.
[0039] Create an image dataset containing pest targets, annotate the dataset, and divide it according to an appropriate ratio; convert all images into jpg format; annotate all image datasets, use labelimg as the annotation tool, use a rectangular annotation box, and annotate pest targets; the rectangular annotation box must be the minimum rectangle that encloses a single target, and multiple targets can be annotated in one image; modify all image file names to match the corresponding label file names.
[0040] The created data set is divided into a training set, a test set, and a validation set in a ratio of 8:1:1. In this embodiment, 1158 training set images, 124 test set images, and 73 validation set images are obtained.
[0041] S2. Design MDCA module and FFEM feature fusion module and integrate them into YOLOv8n. MDCA module (Multi-scale Depthwise Convolutional Aggregator) refers to a lightweight feature extraction module with expanded receptive field, which can perceive surrounding targets in a wider range while being lightweight; FFEM feature fusion network refers to the systematic expansion to different model sizes through composite model scaling, so that it can efficiently adapt to different input image sizes and improve its scalability.
[0042] For the MDCA module, its structure is as follows Figure 2As shown in the figure, it consists of two types of convolutions, namely ordinary convolution and depth-wise separable convolution. The two ordinary convolutions are convolutions with a convolution kernel size of 3×3 and a convolution kernel size of 1×1; the three depth-wise separable convolutions are depth-wise separable convolutions with strides of 1, 2, and 3.
[0043] The specific process of the MDCA module is as follows: after the input feature map, it first undergoes a 1x(2d-1) depthwise separable convolution operation to generate the first intermediate feature map. Then the feature map undergoes two (2d-1)x1 depthwise separable convolutions, and one 1x(k / d) and one (2d-1)x1 depthwise separable convolution to further process the feature map. Next, the fifth intermediate feature map undergoes a (k / d)x1 depthwise separable convolution to form the sixth intermediate feature map. Finally, the sixth intermediate feature map undergoes a 1x1 convolution operation to obtain the third feature map output by MDCA, completing a series of depthwise separable convolution processing of the feature map.
[0044] The MDCA module mainly uses depthwise separable convolution. This structure can significantly reduce the number of model parameters and make the model lightweight. The use of convolution modules with different step lengths can help the model capture more semantic information of pests and bring better results for pest feature extraction.
[0045] like Figure 3 As shown, for the FFEM feature fusion structure, the details are as follows:
[0046] The feature map extracted from the YOLOv8n backbone network is divided into multiple parts, and then the feature expression is enhanced through the normalization and activation function of the MBConv module, the local information is captured by deep convolution, and the features of different parts are fused through splicing operations. Finally, the features are further refined through 1x1 convolution and a comprehensive feature map is output. The MBConv module is as follows Figure 4 shown.
[0047] The FFEM feature fusion module realizes the effective processing and enhancement of input features, providing a richer and more robust feature representation for subsequent tasks (such as classification, detection, etc.), which enables the deep neural network to more accurately capture the characteristics of the target when detecting pest targets, thereby improving the detection performance.
[0048] Integrate the MDCA module and FFEM feature fusion structure into YOLOv8n, and build a model like Figure 5 shown.
[0049] In S3, the training set and the test set are used to train the built model and obtain the training results. The specific implementation process is as follows:
[0050] The data set was input into the built model for training. Each batch of 16 images was trained. One round of training was completed after all the images in the training set were trained. A total of 200 rounds were trained. The initial learning rate was set to 0.01, and the final learning rate was 0.001. The training used a variety of data enhancement strategies such as random splicing, random mixing, and random left-right flipping. The usage rate of random splicing was 100%, the usage rate of random left-right flipping was 50%, the usage rate of random mixing was 15%, and the usage rate of random copy and paste was 50%. The total video memory used for model training was 32G, consisting of two GPUs with 16G video memory. The GPU model was Teala V100. The details of the training environment are shown in Table 1.
[0051] Table 1 Training environment information table
[0052]
[0053] During training, the image size is uniformly adjusted to 640×640. The model will continuously extract features and downsample the input image by two times until the feature map size reaches 20×20. The prediction head will make predictions on feature maps of 80×80, 40×40, and 20×20. The prediction will generate a rectangular box to mark the target location and predict the category, which includes brown spot disease, rice blast disease, and bacterial leaf blight disease. After reaching the specified training round, the best result of all rounds is selected and saved to obtain the training weight file Train_Result.pt. The training results are shown in Table 2.
[0054] Table 2 Training results
[0055]
[0056]
[0057] In the table, map@.5 represents the mean average precision when the IoU threshold is 0.5, and map@.5.95 represents the mean average precision at different IoU thresholds [0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95].
[0058] Compared with YOLOv8n, the pest detection method based on MDCA and FFEM feature fusion shows good precision, recall rate and map@.5. The specific data are shown in Table 3.
[0059] Table 3 Detection effect comparison table
[0060]
[0061] The specific steps of using the training results to detect pest targets are as follows:
[0062] Use the above Train_Result.pt to detect the pictures in the test set; the detection results are marked with a rectangular box, and the category information and confidence value are marked, such as Figure 6 shown.
[0063] Based on the same inventive concept, this embodiment also provides a pest detection system based on MDCA and FFEM feature fusion, including:
[0064] The preprocessing module is used to collect pictures containing pest targets, build a data set, and divide the data set into a training set, a test set, and a validation set;
[0065] A model building module, used to improve the YOLOV8n network and establish a pest detection model; the improvements include replacing the original C2f module with the MDCA module to reduce the model parameters while expanding the receptive field through depth-separable convolutions with different convolution steps, and replacing the original SPPF module with the FFEM feature fusion network to enhance the recognition ability of different models and reduce parameters and calculations;
[0066] The monitoring module is used to train the pest detection model using a training set and a test set, and detect pest targets using the trained pest detection model.
[0067] Based on the same inventive concept, this embodiment also provides a computing device, including: one or more processors, one or more memories, and one or more programs, wherein the programs are stored in the memories and configured to be executed by the processors, and when the programs are loaded into the processors, the steps of the pest detection method based on MDCA and FFEM feature fusion as described in any one of the above items are implemented.
[0068] Based on the same inventive concept, this embodiment also provides a storage medium, which stores a computer program, and the computer program includes program instructions. When the program instructions are executed by a processor, the processor executes the steps of the pest detection method based on MDCA and FFEM feature fusion according to any of the above items.
[0069] The storage media may include RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage or other magnetic storage, flash memory, or any other medium that can be used to store the desired program code in the form of instructions or data structures and that can be accessed by a computer.
[0070] The processor is used to execute the computer program stored in the memory to implement each step of the method involved in the above embodiment.
Claims
1. A pest detection method based on MDCA and FFEM feature fusion, characterized in that: include: Collect pictures containing pest targets, build a data set, and divide the data set into training set, test set, and validation set; Improvements are made based on the YOLOV8n network to establish a pest detection model; the improvements include replacing the original C2f module with the MDCA module to reduce the model parameters while expanding the receptive field through depth-separable convolutions with different convolution steps, and replacing the original SPPF module with the FFEM feature fusion network to enhance the recognition ability of different models and reduce parameters and calculations; The pest detection model is trained using a training set and a test set, and pest targets are detected using the trained pest detection model.
2. The pest detection method based on MDCA and FFEM feature fusion according to claim 1, characterized in that: The method collects pictures containing pest targets, establishes a data set, and divides the data set into a training set, a test set, and a validation set, including: Collect pictures containing pest targets, convert all pictures into a preset format, and make a data set; annotate all picture data sets; divide the prepared data set into training set, test set, and validation set according to the preset ratio.
3. The pest detection method based on MDCA and FFEM feature fusion according to claim 1, characterized in that: The MDCA module includes a convolution block and a depthwise separable convolution block; the MDCA module first subjects the input feature map to a 1×(2d-1) depthwise separable convolution operation to generate a first intermediate feature map, and then the intermediate feature map undergoes a (2d-1)×1 depthwise separable convolution twice, and a 1×(k / d) and (2d-1)×1 depthwise separable convolution once each, and then the obtained feature map is subjected to a (k / d)×1 depthwise separable convolution, and finally a 1×1 convolution operation to obtain the third feature map output by MDCA, where k is the kernel size and d is the dilation rate.
4. The pest detection method based on MDCA and FFEM feature fusion according to claim 1, characterized in that: The FFEM feature fusion network implementation method is: The feature map extracted from the YOLOv8n backbone network is divided into multiple parts, the feature expression is enhanced through the normalization and activation function of the MBConv module, the local information is captured by deep convolution, and the features of different parts are fused through splicing operations. Finally, the features are refined through 1x1 convolution and the comprehensive feature map is output.
5. The pest detection method based on MDCA and FFEM feature fusion according to claim 4, characterized in that: The MBConv module is a basic building block. The implementation method of the MBConv module is as follows: use 1x1 convolution to increase the dimension of the feature, then perform a depth-wise separable convolution DW operation, and then pass the feature through the Squeeze-and-Excitation module, and then use 1×1 convolution again to reduce the dimension.
6. The pest detection method based on MDCA and FFEM feature fusion according to claim 1, characterized in that: The method of using the training set and the test set to train the pest detection model includes: The training set is input into the pest detection model for training, and a number of pictures are trained in each batch, and one round of training is defined as one round of training in which all pictures in the training set are trained once. During training, the picture size is adjusted to a preset size, and the pest detection model continuously extracts features and performs two-fold upsampling on the input picture until the feature map size reaches a preset size. The prediction head performs prediction on feature maps of several preset sizes, and after reaching a specified training round, the result with the highest training parameter among all rounds is selected and saved.
7. The pest detection method based on MDCA and FFEM feature fusion according to claim 4, characterized in that: The FFEM feature fusion network also includes performing DropPath regularization and Shortcut connection operations after finally refining the features through 1x1 convolution.
8. A pest detection system based on MDCA and FFEM feature fusion, characterized in that: include: The preprocessing module is used to collect pictures containing pest targets, build a data set, and divide the data set into a training set, a test set, and a validation set; A model building module, used to improve the YOLOV8n network and establish a pest detection model; the improvements include replacing the original C2f module with the MDCA module to reduce the model parameters while expanding the receptive field through depth-separable convolutions with different convolution steps, and replacing the original SPPF module with the FFEM feature fusion network to enhance the recognition ability of different models and reduce parameters and calculations; The monitoring module is used to train the pest detection model using a training set and a test set, and detect pest targets using the trained pest detection model.
9. A computing device, characterized in that include: One or more processors, one or more memories and one or more programs, wherein the programs are stored in the memories and configured to be executed by the processors, and when the programs are loaded into the processors, the steps of the pest detection method based on MDCA and FFEM feature fusion according to any one of claims 1 to 7 are implemented.
10. A storage medium storing a computer program, characterized in that: The computer program comprises program instructions, which, when executed by a processor, enable the processor to perform the steps of the pest detection method based on MDCA and FFEM feature fusion according to any one of claims 1 to 7.