Novel rice pest detection method and system

By using the FasterNet backbone network, Dynamic Head detection head and Inner-IoU loss function in the YOLOv8n model, the YOLOv8-FDI model was constructed, which solved the shortcomings of YOLOv8n in complex background and small object detection, and achieved high-precision and real-time rice pest detection.

CN119723344APending Publication Date: 2025-03-28HUAZHONG AGRI UNIV
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411813720.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-11
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

There is still room for improvement in the performance of the existing YOLOv8n algorithm when dealing with complex backgrounds or small targets, especially in fine-grained object detection tasks, which are prone to missed or misdetection, and there are limitations when dealing with scenarios with large changes in the shape and scale of the target.

Method used

FasterNet is used as the backbone network, and Dynamic Head technology and Inner-IoU loss function are introduced to build the YOLOv8-FDI model. FasterNet optimizes the calculation process through partial convolution, Dynamic Head dynamically adjusts the detection head through scale, space and task-aware attention mechanism, and Inner-IoU loss function dynamically adjusts the loss calculation through auxiliary bounding boxes and scale factors.

Benefits of technology

The identification accuracy and generalization ability of different types of rice pest characteristics have been significantly improved, and real-time accurate detection of rice pests in complex backgrounds has been achieved, with an average accuracy of 97.1%, which is better than the YOLOv3-tiny, YOLOv5n, YOLOv7-tiny and standard YOLOv8n models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119723344A_ABST
    Figure CN119723344A_ABST
Patent Text Reader

Abstract

According to the novel rice pest detection method and system provided by the invention, a rice pest detection model YOLOv8-FDI model based on an improved YOLOv8n algorithm is constructed, FasterNet is adopted as a backbone network, and a Dynamic Head technology and an Inner-IoU loss function are introduced, so that the recognition precision and generalization ability of characteristics of different types of pests of rice are remarkably improved, and the method and the system have good application prospects. According to the method, the function of accurately detecting the rice pests under the complex background in real time is achieved, a data set IP14-RICE containing various rice pest images under the complex natural environment condition is successfully constructed to be used for model contrast tests, and various typical rice pest scenes are included; and the model can be ensured to fully learn and identify various insect pest characteristics in training and testing stages. Experimental results show that the YOLOv8-FDI model has excellent performance on a test set, compared with other common models, namely YOLOv3-tin, YOLOv5n and YOLOv7-tin, the performance of the YOLOv8-FDI model is remarkably improved, and a powerful technical support is provided for real-time monitoring of agricultural pests.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of image processing, and in particular relates to a novel rice pest detection method and system. Background Art

[0002] Rice is the staple food of my country, and its output is directly related to my country's food security and social stability. Among them, rice pests directly affect rice yields. Therefore, how to accurately detect rice pests in real time under complex backgrounds has become an important research direction in agricultural science today.

[0003] As the mainstream model in the current target detection field, the YOLOv8n algorithm has become the first choice of researchers due to its significant advantages in speed and accuracy. YOLOv8n's backbone network Backbone adopts CSPDarknet to realize feature extraction, and improves the performance of the model by adopting the C2f structure with richer gradient flow. In terms of feature fusion, YOLOv8n inherits the core ideas of the feature fusion networks FPN (Feature Pyramid Networks) and PANet (Path Aggregation Network), and enhances features through top-down and bottom-up paths. The three feature maps after feature enhancement are then sent to the detection head. When processing the detection results, YOLOv8n uses a non-maximum suppression strategy to filter overlapping detection boxes, and screens out the final detection results by setting confidence thresholds and IoU thresholds. The YOLOv8n model structure is as follows Figure 1 shown.

[0004] YOLOv8n performs well in practical applications and is an ideal choice for target detection tasks. However, its application in some specific scenarios still has some shortcomings. First, there is room for improvement in YOLOv8n's performance when dealing with complex backgrounds or small targets, especially in fine-grained target detection tasks, which are prone to missed detections or false detections. Second, although YOLOv8n introduces an anchor-free detection method, it still has certain limitations when dealing with scenes with large changes in target shape and scale.

[0005] Although the backbone network CSPDarknet of the YOLOv8n model performs well in feature extraction, it has a large number of convolutional layers and a complex structure, which increases the computational burden and running time of the model to a certain extent. To make up for this shortcoming, many researchers have borrowed the design methods of lightweight networks, such as GhostNet, MobileNet, and ShuffleNet. These networks reduce the complexity of the model to a certain extent through technologies such as Depthwise Separable Convolution (DSC), GhostConv, and Group Shuffle Convolution (GSConv). However, while these convolution methods realize feature extraction, they also introduce additional data processing operations such as connection, shuffling, and pooling, which increases the running time of the model. In addition, the frequent memory access of deep convolution operations also has an adverse effect on the real-time performance of the detection model.

[0006] YOLOv8n's bounding box regression uses the complete intersection-over-union (CIoU) as the loss function. CIoU is an improvement over the traditional IoU, which not only considers the overlapping area of ​​the bounding boxes, but also the distance between the center points of the bounding boxes and the similarity of their aspect ratios, thus providing a more comprehensive similarity metric. However, CIoU still uses a fixed scale to calculate the loss and does not distinguish between samples with different IoU values, which results in its lack of sufficient generalization ability in different detection tasks. Summary of the invention

[0007] The technical problem to be solved by the present invention is to provide a novel rice pest detection method and system for real-time and accurate detection of rice pests under complex backgrounds.

[0008] The technical solution adopted by the present invention to solve the above technical problems is: a new rice pest detection method, comprising the following steps: S1: After obtaining crop pest data and preprocessing, construct the rice pest dataset IP14-RICE; S2: Construct a YOLOv8-FDI model including a backbone network, a neck structure, and a network detection head for detecting rice pests; the backbone network uses FasterNet; the network detection head uses Dynamic Head; Inner-IoU is set as the loss function of the YOLOv8-FDI model; S3: Training and evaluating the YOLOv8-FDI model.

[0009] According to the above scheme, in step S1, the specific steps are: S11: Screening rice pest data from the large pest dataset IP102; S12: Enhance and annotate the rice pest data to obtain the rice pest dataset IP14-RICE.

[0010] Furthermore, in step S12, the specific steps of enhancing the rice pest data are as follows: Perform horizontal flipping, vertical flipping and mirror symmetry operations on the data to simulate observation of pests in different directions and viewing angles; Affine transformation operations including scaling, tilting and multi-angle rotation are performed on the data to simulate various orientations and perspective deformations of pests; Adding random noise is used to simulate insufficient lighting, sensor errors, or interference in complex environments; By adjusting the contrast of the image, it is used to simulate the image changes under different lighting conditions; Scale transformation and image translation are used to simulate different shooting distances and capture position changes.

[0011] According to the above scheme, in step S2, FasterNet includes four stages, each stage includes a stack of FasterNet blocks, and includes an embedding layer or a merging layer before each stage; the embedding layer performs spatial downsampling through a 4×4 convolution operation; the fusion layer expands the number of channels through a 2×2 convolution operation.

[0012] According to the above scheme, in step S2, the FasterNet block includes a partial convolution and two point-by-point convolutions; the partial convolution PConv is used to perform conventional convolution processing on a part of the channels.

[0013] According to the above scheme, in step S2, the Dynamic Head includes a scale-aware attention module deployed on the feature level dimension, a space-aware attention module deployed on the space dimension, and a task-aware attention module deployed on the channel dimension; The scale-aware attention module is used to learn the relative importance of different semantic levels; The spatially aware attention module is used to learn consistent discriminative representations in spatial locations; The task-aware attention module is used to guide different feature channels to support different tasks respectively.

[0014] Furthermore, in the step S2, the features of different levels of the neck structure output are defined as a feature pyramid; the feature pyramid is scaled by upsampling or downsampling to obtain a three-dimensional tensor representing scale perception, space perception and task perception respectively; the attention function applied to the three different dimensions of the tensor unifies the three attention mechanisms of scale, space and task perception.

[0015] According to the above scheme, in step S2, Inner-IoU dynamically adjusts the loss calculation through the auxiliary bounding box and the scale factor.

[0016] According to the above scheme, in step S3, the indicators for evaluating the YOLOv8-FDI model include accuracy, recall rate, average precision mean and F1 score.

[0017] A new rice pest detection system The data processing submodule is used to obtain crop pest data and construct the rice pest dataset IP14-RICE after preprocessing; The model building submodule is used to build a YOLOv8-FDI model including a backbone network, a neck structure, and a network detection head for detecting rice pests; the backbone network uses FasterNet; the network detection head uses Dynamic Head; Inner-IoU is set as the loss function of the YOLOv8-FDI model; Model evaluation submodule, used to train and evaluate the YOLOv8-FDI model.

[0018] The beneficial effects of the present invention are: 1. A novel rice pest detection method and system of the present invention, by constructing a rice pest detection model YOLOv8-FDI model based on the improved YOLOv8n algorithm, using FasterNet as the backbone network, and introducing Dynamic Head technology and Inner-IoU loss function, significantly improves the recognition accuracy and generalization ability of characteristics of different types of rice pests, and realizes the function of real-time and accurate detection of rice pests in complex backgrounds.

[0019] 2. The present invention successfully constructed a dataset IP14-RICE containing a variety of rice pest images under complex natural environment conditions for model comparison experiments. The IP14-RICE dataset contains various typical rice pest scenes, ensuring that the model can fully learn and identify a variety of pest characteristics during the training and testing stages. The experimental results show that the average accuracy of the proposed YOLOv8-FDI model on the test set of the IP14-RICE dataset is 97.1%, which is 3.5%, 1.1%, 2.3% and 1.7% higher than the YOLOv3-tiny, YOLOv5n, YOLOv7-tiny and standard YOLOv8n models, respectively. This further verifies the superior performance of the proposed model, indicating that it has great potential and broad application prospects in actual rice pest detection applications.

[0020] 3. Experimental results show that the YOLOv8-FDI model achieved excellent performance on the test set, with mAP@0.5 and mAP@0.5:0.95 reaching 98.8% and 88.4% respectively, an increase of 2.5% compared with the original model YOLOv8n, and significant improvement compared with other commonly used models YOLOv3-tiny, YOLOv5n, and YOLOv7-tiny, providing strong technical support for real-time detection and rapid diagnosis of pests in smart agriculture.

[0021] Of course, any product implementing the present invention does not necessarily need to achieve all of the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0023] Figure 1 This is the existing YOLOv8n model structure diagram.

[0024] Figure 2 It is a YOLOv8-FDI model structure diagram of an embodiment of the present invention.

[0025] Figure 3 is a FasterNet block diagram of an embodiment of the present invention.

[0026] Figure 4 It is a partial convolution graph of an embodiment of the present invention.

[0027] Figure 5 4 is a flow chart of a Dynamic Head method according to an embodiment of the present invention.

[0028] Figure 6 This is a graph of the detection results of different models on the IP14-RICE dataset.

[0029] Figure 7 is a flow chart of an embodiment of the present invention. DETAILED DESCRIPTION

[0030] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0031] Example 1 See also Figure 7 , the specific steps of a new rice pest detection method are as follows: S1: After obtaining crop pest data and preprocessing, construct the rice pest dataset IP14-RICE; S2: Construct a YOLOv8-FDI model including a backbone network, a neck structure, and a network detection head for detecting rice pests; the backbone network uses FasterNet; the network detection head uses Dynamic Head; Inner-IoU is set as the loss function of the YOLOv8-FDI model; S3: Training and evaluating the YOLOv8-FDI model.

[0032] Furthermore, in step S1, the specific steps are: S11: Screening rice pest data from the large pest dataset IP102; S12: Enhance and annotate the rice pest data to obtain the rice pest dataset IP14-RICE.

[0033] Furthermore, in step S12, the specific steps of enhancing the rice pest data are as follows: Perform horizontal flipping, vertical flipping and mirror symmetry operations on the data to simulate observation of pests in different directions and viewing angles; Affine transformation operations including scaling, tilting and multi-angle rotation are performed on the data to simulate various orientations and perspective deformations of pests; Adding random noise is used to simulate insufficient lighting, sensor errors, or interference in complex environments; By adjusting the contrast of the image, it is used to simulate the image changes under different lighting conditions; Scale transformation and image translation are used to simulate different shooting distances and capture position changes.

[0034] In step S2, FasterNet includes four stages, each stage includes a stack of FasterNet blocks, and includes an embedding layer or a merging layer before each stage; the embedding layer performs spatial downsampling through a 4×4 convolution operation; the fusion layer expands the number of channels through a 2×2 convolution operation.

[0035] In step S2, the FasterNet block includes one partial convolution and two point-by-point convolutions; the partial convolution PConv is used to perform conventional convolution processing on a part of the channels.

[0036] In step S2, Dynamic Head includes a scale-aware attention module deployed on the feature level dimension, a space-aware attention module deployed on the space dimension, and a task-aware attention module deployed on the channel dimension; The scale-aware attention module is used to learn the relative importance of different semantic levels; The spatially aware attention module is used to learn consistent discriminative representations in spatial locations; The task-aware attention module is used to guide different feature channels to support different tasks respectively.

[0037] In step S2, the features of different levels of the neck structure output are defined as a feature pyramid; the feature pyramid is scaled by upsampling or downsampling to obtain a three-dimensional tensor representing scale perception, space perception and task perception respectively; the attention function applied to the three different dimensions of the tensor unifies the three attention mechanisms of scale, space and task perception.

[0038] In step S2, Inner-IoU dynamically adjusts the loss calculation through the auxiliary bounding box and the scale factor.

[0039] In step S3, the indicators for evaluating the YOLOv8-FDI model are set to include precision, recall, mean average precision, and F1 score.

[0040] This embodiment constructs a rice pest detection model YOLOv8-FDI model based on the improved YOLOv8n algorithm, adopts FasterNet as the backbone network, and introduces Dynamic Head technology and Inner-IoU loss function, which significantly improves the recognition accuracy and generalization ability of characteristics of different types of rice pests, and realizes the function of real-time and accurate detection of rice pests in complex backgrounds.

[0041] Example 2 The steps of this embodiment are the same as those of Embodiment 1, except that each step is applied to a specific example. Specifically, the following steps are included: S1: After obtaining rice pest data and preprocessing, construct the rice pest dataset IP14-RICE; In order to meet the challenge of real-time and accurate detection of rice pests at multiple scales under complex backgrounds, this embodiment constructs the rice pest dataset IP14-RICE based on the public large-scale pest dataset IP102 and the actual situation of rice field pests. The construction process of this dataset mainly includes two parts: screening rice pest data from the IP102 dataset, data enhancement and annotation.

[0042] S11: Screening rice pest data from the large pest dataset IP102; This embodiment screened out all 14 types of pests related to rice pests from the IP102 data set. Specifically including: 166 cases of Asian rice borer, 111 cases of brown planthopper, 25 cases of rice leafminer, 93 cases of rice gall midge, 114 cases of rice leaf caterpillar, 117 cases of rice leaf worm, 36 cases of rice sheathworm, 28 cases of rice stem fly, 153 cases of rice water weevil, 78 cases of white-backed planthopper, 81 cases of rice stem borer, 20 cases of rice tube thrips and 52 cases of gray planthopper, a total of 1248 samples. The IP14-RICE rice pest data set constructed in this embodiment is obtained by data enhancement method based on these 1248 samples.

[0043] S12: Enhance and annotate rice pest dataset; In order to deal with the problem of insufficient samples in the rice pest identification task, this embodiment adopts a series of data enhancement strategies, including the following aspects: first, horizontal and vertical flip operations, and mirror symmetry operations to simulate the observation of pests in different directions and perspectives; second, affine transformation operations, such as scaling and tilting, and multi-angle rotation, etc., to simulate the various orientations and perspective deformations of pests; third, adding random noise to simulate insufficient illumination, sensor errors or interference in complex environments; fourth, adjusting the contrast of the image to simulate image changes under different illumination; fifth, simulating different shooting distances and capture position changes through scale transformation and image translation. Through the above data enhancement operations, a total of 9984 unlabeled rice pest enhancement data were obtained. Then, LabelImg annotation software was used to manually annotate them. Together with the original 1248 basic pictures, a total of 11232 rice pest image data were obtained after data enhancement operations as the data set of this embodiment, named IP14-RICE. The types and quantities of rice pests before and after data enhancement are shown in Table 1. Table 1 Types and numbers of rice pests before and after data enhancement

[0044] S2: Build a YOLOv8-FDI model for detecting rice pests; This embodiment aims at the real-time detection task requirements of multi-scale rice pests under complex backgrounds. Based on the YOLOv8n model, the three parts of its backbone network, network detection head, and loss function are improved to construct the rice pest detection model YOLOv8n-FDI. The specific improvement strategies are as follows: First, in order to meet the real-time requirements of rice pest detection, this embodiment adopts the more efficient FasterNet as the backbone network to optimize the network structure while maintaining sensitivity to pest characteristics, improve computing efficiency, and thus increase the network operation speed; then, by introducing the Dynamic Head (abbreviated as Dyhead) technology, the model can dynamically adjust the detection head of the output layer to better adapt to the characteristics of pests of different types and sizes, thereby improving the accuracy and generalization performance of the model. In addition, by adopting the Inner-IoU loss function, the model can automatically adjust the scale factor during the loss calculation process, thereby further improving the detection accuracy of the model while improving the target positioning accuracy and accelerating the convergence speed of model training. The rice pest detection model YOLOv8-FDI obtained after the above improvement measures is as follows Figure 2 shown.

[0045] S21: FasterNet is used as the backbone network of the YOLOv8-FDI model; Although the backbone network CSPDarknet of the YOLOv8n model performs well in feature extraction, it has a large number of convolutional layers and a complex structure, which increases the computational burden and running time of the model to a certain extent. To make up for this shortcoming, many researchers have borrowed the design methods of lightweight networks, such as GhostNet, MobileNet, and ShuffleNet. These networks reduce the complexity of the model to a certain extent through technologies such as Depthwise Separable Convolution (DSC), GhostConv, and Group Shuffle Convolution (GSConv). However, while these convolution methods realize feature extraction, they also introduce additional data processing operations such as connection, shuffling, and pooling, which increases the running time of the model. In addition, the frequent memory access of deep convolution operations also has an adverse effect on the real-time performance of the detection model.

[0046] FasterNet is a neural network architecture that pursues faster operation speed while maintaining high accuracy. It optimizes the calculation process by introducing innovative partial convolution (PConv). Its architecture design is simple and has no complex additional structure, which can make up for the shortcomings of the YOLOv8n model backbone network. Therefore, this embodiment uses FasterNet as the backbone network of the YOLOv8-FDI model. For its overall architecture, please see Figure 2 The backbone network consists of four hierarchical stages, each of which has a stack of FasterNet blocks, and each stage is preceded by an embedding or merging layer. The embedding layer achieves efficient spatial downsampling through 4×4 convolution operations; the fusion layer expands the number of channels through 2×2 convolution operations, providing a solid foundation for the subsequent capture of deep features; the FasterNet block introduces partial convolution (PConv), which only performs convolution on part of the input channels, thereby reducing the amount of computation and memory usage while maintaining the efficiency of the model. Obviously, the FasterNet block is a key component of the backbone network, which consists of a partial convolution (PConv) and two point-wise convolutions (PWConv), as shown in Figure 2. Figure 3 shown.

[0047] Figure 3 In the partial convolution PConv, only some channels are subjected to conventional convolution, while other channels are not subjected to convolution. Usually, PConv selects P consecutive channels in the front or back of the feature map for convolution, such as Figure 4 shown.

[0048] Partial convolution PConv significantly reduces the computational complexity and memory access frequency of the model by reducing unnecessary convolution operations. Compared with ordinary convolution Conv, it improves the real-time performance of the model.

[0049] S22: Use Dynamic Head as the network detection head of the YOLOv8-FDI model; Dynamic Head is a novel dynamic detection head method. Its core idea is to unify and enhance the functions of the target detection head by introducing multiple attention mechanisms, thereby improving the accuracy and generalization ability of the model's target detection. This embodiment introduces Dynamic Head into the YOLOv8-FDI model to optimize the performance of the model's detection head, thereby improving the model's ability to detect multi-scale rice pest targets in complex backgrounds.

[0050] Specifically, if Figure 5 As shown in the figure, Dynamic Head achieves scale awareness, space awareness and task awareness by deploying three types of attention modules, namely scale-aware attention, space-aware attention and task-aware attention, at different levels, spatial positions and output channels of the feature pyramid. Among them, the scale-aware attention module is deployed on the feature level dimension to learn the relative importance of different semantic levels to enhance the features of individual targets, which are enhanced at the appropriate level based on their scale; the space-aware attention module is deployed on the spatial (i.e., height × width) dimension to learn consistent discriminative representations in spatial positions, helping the model to better identify the features of targets in different shapes, rotations and positions; the task-aware attention module is deployed on the channel dimension to guide different feature channels to support different tasks respectively.

[0051] exist Figure 5 In the above example, the feature pyramid is Figure 2 The features of the neck structure output by the YOLOv8-FDI detection model shown in the figure need to be scaled by upsampling or downsampling before being input into the Dynamic Head. After adjustment, a three-dimensional tensor F∈R is obtained. L×S×C . Among them, L, S, and C represent the three dimensions of scale perception, spatial perception, and task perception, respectively. Specifically, L represents the number of feature layers representing different scales, and S represents a dimension obtained by multiplying the height and width of the feature map, which is used to represent the spatial position information of the feature map in the tensor. C represents the number of channels, which indicates the number of channels contained in the feature vector of each spatial position.

[0052] Dynamic Head mainly realizes its core functions through scale-aware attention, space-aware attention and task-aware attention. Figure 5 As shown, π L , π S , π C are the attention functions applied to the three different dimensions of L, S, and C of the tensor F. The advantage of Dynamic Head is that it unifies the three attention mechanisms of scale, space, and task perception into one framework, forming a comprehensive attention learning problem. Although these attention mechanisms act on different feature dimensions, their performance can complement each other and jointly improve the representation ability of the target detection head without adding additional computational overhead.

[0053] Given a feature tensor , the general formula for applying self-attention is: (1) Among them, π is the attention function; The formula for applying attention to Dynamic Head is: (2) in, (3) (4) (5) In formula (3), is a hard-sigmoid function, is a linear function approximated by a 1×1 convolutional layer. Equation (4) first uses deformable convolution to sparse the attention learning, and then aggregates features across layers at the same spatial position, where K is the number of sparse sampling positions, is the self-learning spatial offset, For self-learning position is an important scalar at . In formula (5) is the feature slice of the cth channel, is a hyperparameter.

[0055] S23: Set Inner-IoU as the loss function of the YOLOv8-FDI model; YOLOv8n's bounding box regression uses complete intersection over union (CIoU) as the loss function. CIoU is an improvement on the traditional IoU. It not only considers the overlapping area of ​​the bounding boxes, but also considers the distance between the center points of the bounding boxes and the similarity of their aspect ratios, thereby providing a more comprehensive similarity metric. However, CIoU still uses a fixed scale to calculate the loss and does not distinguish samples with different IoU values, which leads to its lack of sufficient generalization ability in different detection tasks. To make up for the shortcomings of CIoU, this embodiment introduces the Inner-IoU loss function in the YOLOv8-FDI model. Inner-IoU dynamically adjusts the loss calculation by introducing auxiliary bounding boxes and scale factors, which can not only adapt to different detection tasks and data sets and improve the generalization ability of the model, but also can more effectively process high IoU and low IoU samples and accelerate the convergence of the model. The Inner-IoU loss function has higher flexibility and adaptability. It can achieve more accurate detection results in target detection tasks, especially in multi-scale target detection in complex scenes.

[0056] The calculation formula of Inner-IoU is as follows: (6) in, (7) (8) (9) (10) (11) (12) In the above formulas, the parameter ratio is the proportional factor that controls the size of the auxiliary bounding box, and its value range is [0.5, 1.5]; is the center point coordinate of the real bounding box, is the coordinate of the center point of the prediction box, and are the width and height of the true bounding box, respectively. and are the width and height of the prediction box respectively.

[0057] S3: Training and evaluating the YOLOv8-FDI model; S31: Set the indicators for evaluating the YOLOv8-FDI model; This embodiment uses precision, recall, mean average precision (mAP), and F1 score as evaluation indicators to comprehensively evaluate the model performance. Generally, the larger the value of these indicators, the better the performance of the model. The calculation formulas are: (13) (14) (15) (16) (17) In formulas (13) and (14), TP represents the number of true positives, FP represents the number of false positives, and FN represents the number of false negatives. In formula (15), AP represents the average precision, which reflects the overall classification performance of the model under a specific category; n represents the number of non-repeated sampling points in the recall rate, P(k) represents the accuracy corresponding to the kth recall rate point R(k), and R(k) represents the kth recall rate value. In formula (16), mAP represents the mean average precision, which is the average value of AP of all categories and is used to measure the overall performance of the model in multi-classification tasks; N represents the total number of categories, and APi represents the average precision value of the i-th category. This embodiment uses two measurement standards: mAP@0.5 and mAP@0.5:0.95. mAP@0.5 represents the average precision when the IoU threshold is 0.5, and mAP@0.5:0.95 represents the AP mean obtained by calculating the corresponding AP by taking multiple IoU thresholds from 0.5 to 0.95 with a step size of 0.05.

[0058] S32: Set up the environment for training and testing the YOLOv8-FDI model; The model training and testing of this embodiment are run in the same environment. The hardware equipment used includes Inteli9-12900k processor, NVIDIA GeForce RTX3090 graphics card, the software environment is Ubuntu 20.04 operating system, Python3.8, CUDA11.8, and the deep learning framework is Pytorch1.13.1.

[0059] S4: Experiment and analyze the results of the YOLOv8-FDI model S41: Comparative test and result analysis S411: Comparative experiments on the IP14-RICE dataset In order to verify the performance of the proposed YOLOv8-FDI rice pest detection model, this embodiment conducted a comparative experiment with YOLOv8n and other mainstream target detection models (YOLOv3-tiny, YOLOv5n, YOLOv7-tiny, etc.) on the IP14-RICE rice pest dataset constructed in this embodiment. The experimental results are shown in Tables 2 and 3. Figure 6 As shown. Because the pests detected in this embodiment are more species, Figure 6 Only the detection results of 8 representative rice pests are given.

[0060] Table 2 Experimental results of different models on the IP14-RICE dataset

[0061] As can be seen from Table 2, the improved model YOLOv8-FDI performs well in various indicators and is better than other comparison models overall. Specifically, the accuracy of the YOLOv8-FDI model reaches 0.971, the recall rate is 0.956, the F1 score is 0.9634, the mAP@0.5 is 0.988, and the mAP@0.5:0.95 is 0.884. All indicators are better than YOLOv8n (its accuracy, recall rate, F1 score, mAP@0.5 and mAP@0.5:0.95 are 0.954, 0.954, 0.9540, 0.982 and 0. 859), YOLOv7-tiny (whose precision, recall, F1 score, mAP@0.5 and mAP@0.5:0.95 are 0.948, 0.939, 0.979, 0.742 and 0.943 respectively) and YOLOv3-tiny (whose precision, recall, F1 score, mAP@0.5 and mAP@0.5:0.95 are 0.926, 0.948, 0.965, 0.77 and 0.936 respectively). Although its recall rate is slightly lower than that of YOLOv5n (only 0.4% lower than that), other indicators are much better than YOLOv5n. Overall, the performance of the YOLOv8-FDI model is also much better than that of YOLOv5n.

[0062] In addition, by Figure 6 It can be seen that the YOLOv8-FDI model has shown extremely high accuracy and stability in detecting various rice pests of different scales under complex backgrounds, and its detection confidence for various pests is higher than that of other models. For example, when detecting the two rice leaf rollers shown in the figure, its confidence is 0.85 and 0.84, which is much higher than other models. In addition, the model has more obvious advantages in detecting multi-scale rice pests. For example, in the detection of brown planthoppers, other models have different degrees of missed detection of small target brown planthoppers, while the YOLOv8-FDI model not only has no missed detection, but also has detection confidence of 0.89, 0.86 and 0.82 for the three different scales of such pests, which fully demonstrates the excellent performance of the model.

[0063] The above results show that the YOLOv8-FDI rice pest model proposed in this embodiment achieves very excellent detection results on the IP14-RICE rice pest dataset.

[0064] S412: Comparative experiment on IP102 dataset In order to verify the generalization of the model, a comparative experiment was also conducted on the IP102 large crop pest dataset. The IP102 dataset contains 18,975 images with target bounding boxes, covering the main pests of 8 types of crops, such as rice, corn, wheat, and sugar beets. The main pests of each type of crop are further divided into multiple secondary categories, totaling 102 types of pests. The experimental results are shown in Table 3. Table 3 Experimental results of different models on IP102 dataset

[0065] Since there are many categories in the IP102 dataset and their distribution is extremely uneven (the largest category has 2347 images and the smallest has only 2 images), the performance of all models on this dataset has declined. As can be seen from Table 3, YOLOv8-FDI performs best in terms of precision and F1 score, reaching 0.581 and 0.558 respectively, which shows that the model has the highest accuracy in predicting positive samples and has achieved a good balance between precision and recall; in terms of recall, YOLOv3-tiny and YOLOv5n perform best, at 0.543, showing their advantages in different missed targets; in terms of average precision mAP@0.5 and mAP@0.5:0.95, YOLOv5n achieves the best values ​​of 0.571 and 0.366, showing its superiority in detection accuracy and stability. Looking at the performance of each model on the IP102 dataset, although YOLOv8-FDI did not perform best in all indicators, it is still competitive in terms of overall performance, especially the outstanding performance in accuracy and F1 score, which proves the ability of this model in rice pest detection tasks. In addition, compared with YOLOv8n, the improvement of YOLOv8-FDI in the mAP@0.5:0.95 indicator also shows that its ability to perform target detection tasks at different scales and in complex backgrounds has improved. Overall, on the IP102 dataset, although YOLOv8-FDI still has room for optimization in some aspects, its model accuracy and F1 score are better than other models, and it still shows good generalization ability and application potential.

[0066] S42: ablation experiment; To verify the effectiveness of the proposed YOLOv8-FDI model, an ablation experiment was conducted on the rice pest dataset IP14-RICE under the same platform and parameter settings to verify the effectiveness and advancement of each improved module. This example conducted an ablation experiment on each module of the improved model, and the results are shown in Table 4.

[0067] Table 4 Ablation experiment results on IP14-RICE dataset

[0068] As can be seen from Table 4, on the IP14-RICE dataset, the performance of the basic model YOLOv8n is as follows: accuracy is 0.954, recall rate is 0.954, mAP@0.5 is 0.982, mAP@0.5:0.95 is 0.859, and F1 score is 0.9540; after replacing the backbone network CSPDarknet of YOLOv8n with FasterNet, the accuracy of the "YOLOv8n + FasterNet" model is improved to 0.961, the recall rate is significantly improved to 0.96, mAP@0.5 and mAP@0.5:0.95 are increased to 0.987 and 0.872 respectively, and the F1 score is increased to 0.9605; after replacing the detection head of YOLOv8n with Dynamic After the optimization of the backbone network and the detection head, the recall rate of the "YOLOv8n+FasterNet + Dynamic Head" model reached 0.963, the recall rate was 0.954, the mAP@0.5 was 0.985, the mAP@0.5:0.95 increased to 0.872, and the F1 score was 0.9585. Obviously, the Dynamic Head significantly improved the feature extraction ability and detection performance of the model. When the backbone network and the detection head were improved at the same time, the recall rate of the "YOLOv8n+FasterNet + Dynamic Head" model was further improved to 0.965, the mAP@0.5 and mAP@0.5:0.95 were increased to 0.988 and 0.885 respectively, and the F1 score reached 0.9610, showing its best performance under the coordinated optimization of the backbone and the detection head. On this basis, after further introducing the Inner-IOU loss function, the accuracy of the YOLOv8-FDI model was further improved to 0.971, and the F1 score increased to 0.9634. Although the mAP@0.5:0.95 decreased slightly, its overall performance was still the best.

[0069] Through the above series of ablation experiments, it can be seen that the three modules of the backbone network FasterNet, Dynamic Head dynamic detection head and Inner-IOU loss function all play an important role in improving the performance of the model. Especially when used in combination, they can significantly enhance the overall performance of the model, making the YOLOv8-FDI model show the highest precision and recall ability, thus proving the positive impact of these improvement measures on improving the effectiveness and generalization ability of rice pest target detection tasks.

[0070] S43: Real-time evaluation; In practical applications, real-time performance is one of the key indicators of target detection models. In the experiment, the average inference delay of the YOLOv8-FDI model was 0.01243 seconds, corresponding to 80.4 frames per second (FPS). This result shows that the model can process input data fast enough to ensure its real-time performance in practical scenarios. Therefore, the improved YOLOv8-FDI model has been optimized to meet the real-time requirements while ensuring high detection accuracy.

[0071] This embodiment proposes a real-time rice pest detection model named YOLOv8-FDI; the model is based on the YOLOv8n architecture and adopts the more efficient FasterNet as the backbone network, which can effectively capture the feature information in the image, optimize the network structure while maintaining sensitivity to pest features; by introducing the Dynamic Head technology, the model can dynamically adjust the detection head of the output layer to better adapt to the features of pests of different types and sizes, thereby improving the accuracy and generalization ability of the model; by adopting the Inner-IoU loss function, the model can automatically adjust the scale factor during the loss calculation process, improve the positioning accuracy of the bounding box, not only speed up the training convergence speed of the model, but also further improve the performance of the model.

[0072] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0073] Example 3 This embodiment is used to implement the principle construction system of the above method embodiment, including a data processing submodule, a model construction submodule and a model evaluation submodule; The data processing submodule is used to obtain crop pest data and construct the rice pest dataset IP14-RICE after preprocessing; The model building submodule is used to build a YOLOv8-FDI model including a backbone network, a neck structure, and a network detection head for detecting rice pests; the backbone network uses FasterNet; the network detection head uses Dynamic Head; Inner-IoU is set as the loss function of the YOLOv8-FDI model; Model evaluation submodule, used to train and evaluate the YOLOv8-FDI model.

[0074] Each sub-module is mainly used to implement each step of the method embodiment, which will not be described in detail here.

[0075] It should be pointed out that, according to the needs of implementation, the various steps / components described in this application can be split into more steps / components, and two or more steps / components or partial operations of steps / components can be combined into new steps / components to achieve the purpose of the present invention.

[0076] The above embodiments are only used to illustrate the design ideas and features of the present invention, and their purpose is to enable those skilled in the art to understand the content of the present invention and implement it accordingly. The protection scope of the present invention is not limited to the above embodiments. Therefore, any equivalent changes or modifications made based on the principles and design ideas disclosed by the present invention are within the protection scope of the present invention.

Claims

1. A novel rice pest detection method, characterized in that: The following steps are involved: S1: After obtaining crop pest data and preprocessing, construct the rice pest dataset IP14-RICE; S2: Construct a YOLOv8-FDI model including a backbone network, a neck structure, and a network detection head for detecting rice pests; the backbone network uses FasterNet; the network detection head uses Dynamic Head; Inner-IoU is set as the loss function of the YOLOv8-FDI model; S3: Training and evaluating the YOLOv8-FDI model.

2. A novel rice pest detection method according to claim 1, characterized in that: In the step S1, the specific steps are: S11: Screening rice pest data from the large pest dataset IP102; S12: Enhance and annotate the rice pest data to obtain the rice pest dataset IP14-RICE.

3. A novel rice pest detection method according to claim 2, characterized in that: In step S12, the specific steps of enhancing the rice pest data are as follows: Perform horizontal flipping, vertical flipping and mirror symmetry operations on the data to simulate observation of pests in different directions and viewing angles; Affine transformation operations including scaling, tilting and multi-angle rotation are performed on the data to simulate various orientations and perspective deformations of pests; Adding random noise is used to simulate insufficient lighting, sensor errors, or interference in complex environments; By adjusting the contrast of the image, it is used to simulate the image changes under different lighting conditions; Scale transformation and image translation are used to simulate different shooting distances and capture position changes.

4. A novel rice pest detection method according to claim 1, characterized in that: In the step S2, FasterNet includes four stages, each stage includes a stack of FasterNet blocks, and includes an embedding layer or a merging layer before each stage; the embedding layer performs spatial downsampling through a 4×4 convolution operation; and the fusion layer expands the number of channels through a 2×2 convolution operation.

5. A novel rice pest detection method according to claim 1, characterized in that: In the step S2, the FasterNet block includes a partial convolution and two point-by-point convolutions; the partial convolution PConv is used to perform conventional convolution processing on a portion of the channels.

6. A novel rice pest detection method according to claim 1, characterized in that: In step S2, the Dynamic Head includes a scale-aware attention module deployed on the feature level dimension, a space-aware attention module deployed on the space dimension, and a task-aware attention module deployed on the channel dimension; The scale-aware attention module is used to learn the relative importance of different semantic levels; The spatially aware attention module is used to learn consistent discriminative representations in spatial locations; The task-aware attention module is used to guide different feature channels to support different tasks respectively.

7. A novel rice pest detection method according to claim 6, characterized in that: In the step S2, the features of different levels of the neck structure output are defined as a feature pyramid; the feature pyramid is scaled by upsampling or downsampling to obtain a three-dimensional tensor representing scale perception, space perception and task perception respectively; the attention function applied to the three different dimensions of the tensor unifies the three attention mechanisms of scale, space and task perception.

8. A novel rice pest detection method according to claim 1, characterized in that: In step S2, Inner-IoU dynamically adjusts the loss calculation through the auxiliary bounding box and the scale factor.

9. A novel rice pest detection method according to claim 1, characterized in that: In step S3, the indicators for evaluating the YOLOv8-FDI model include accuracy, recall rate, average precision mean and F1 score.

10. A novel rice pest detection system, characterized in that: The data processing submodule is used to obtain crop pest data and construct the rice pest dataset IP14-RICE after preprocessing; The model building submodule is used to build a YOLOv8-FDI model including a backbone network, a neck structure, and a network detection head for detecting rice pests; the backbone network uses FasterNet; the network detection head uses Dynamic Head; Inner-IoU is set as the loss function of the YOLOv8-FDI model; Model evaluation submodule, used to train and evaluate the YOLOv8-FDI model.

Citation Information

Cited By

  • Rice disease and pest grade monitoring method, device and equipment based on YOLOv8s algorithm and medium

    CN121504927A