A corn leaf pest area detection method based on YOLOv8

CN117475299BActive Publication Date: 2026-08-21SHANDONG COMP SCI CENTNAT SUPERCOMP CENT IN JINAN +3
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311283629.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-28
Publication Date
2026-08-21
Estimated Expiration
2043-09-28

AI Technical Summary

Technical Problem

[0005]本发明旨在克服上述现有技术的至少一种缺陷,提供一种基于YOLOv8的玉米叶片虫害区域检测方法,以解决现有技术对叶片上虫害区域的检测不足以及基于实例分割的虫害区域检测无法有效定位叶片边界等问题

Benefits of technology

(1)本发明提供的一种基于YOLOv8的玉米叶片虫害区域检测方法,发明采用多边形标注方式对玉米叶片虫害区域进行标注,构建了多边形玉米虫害区域数据集PolyCorn。这种标注方式能够更好地适应虫害区域的复杂形状,从而提高检测的准确性和精度。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117475299B_ABST
    Figure CN117475299B_ABST
Patent Text Reader

Abstract

The present application belongs to the technical field of pest area detection specific computer model, more specifically, it relates to a corn leaf pest area detection method based on YOLOv8. The method comprises the following steps: constructing a data set; preprocessing the corn pest area pictures of the data set; using a lightweight annotation tool "labelme" for polygon annotation, and dividing the pest area into three categories; inputting the preprocessed corn pest area pictures into the backbone network of the Poly-YOLOv8 pest area detection model for feature extraction, then inputting the feature fusion through the neck network, and finally inputting the improved decoupling detection head to generate the detection result; and performing real-time monitoring on the corn pest area through the trained and tested Poly-YOLOv8 pest area detection model. The present application solves the problem that the prior art ignores the detection of the pest area on the leaf, the pest area detection based on instance segmentation cannot effectively locate the leaf boundary, and thus the accuracy is insufficient.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the technical field of specific computer models for detecting pest areas, and more specifically, relates to a method for detecting pest areas on corn leaves based on YOLOv8. Background Technology

[0002] During the growth of corn, pests are one of the main threats affecting corn yield and quality. Therefore, early detection and control of corn pests are crucial. Traditional pest identification methods are limited by insufficient personal experience and professional knowledge, resulting in high uncontrollability. These methods are not only slow but also inefficient, subjective, and lack timeliness, making them unsuitable for large-scale planting.

[0003] A Chinese invention patent discloses a deep learning-based method for detecting and identifying tomato diseases and pests. The method includes: using multiple tomato disease and pest images and the labeled locations of diseases and pests in each image as a first training set, performing data augmentation, and then using this set to train a Transformer-based YOLOX object detection network; labeling the disease and pest categories to which the locations of diseases and pests in the tomato disease and pest images belong, using this set as a second training set, and performing data augmentation, then using this set to train a rotation-invariant Fisher discriminant CNN network; and using the YOLOX object detection network and the rotation-invariant Fisher discriminant CNN network to locate the locations of diseases and pests in the tomato images.

[0004] In recent years, numerous studies based on computer vision technology have emerged in agricultural applications, covering many fields such as fruit detection and pest classification. Current pest research usually focuses on detecting pests, neglecting the detection of pest areas on leaves. Furthermore, the use of rectangular boxes for detection tends to include a lot of background information. In addition, pest area detection based on instance segmentation cannot effectively locate leaf boundaries, resulting in insufficient accuracy. Summary of the Invention

[0005] The present invention aims to overcome at least one of the defects of the prior art and provide a method for detecting pest areas on maize leaves based on YOLOv8, so as to solve the problems of insufficient detection of pest areas on leaves by the prior art and the inability of instance segmentation-based pest area detection to effectively locate leaf boundaries.

[0006] The detailed technical solution of this invention is as follows: S1. Constructing the dataset: Collect the required number of multi-scene, multi-scale images of corn pest areas. The dataset is divided into 70% for training and 30% for testing. S2. Preprocess the corn pest infestation area images in the dataset: Use the lightweight annotation tool "labelme" to perform polygon annotation and divide the pest infestation areas into 3 categories: feeding area, infected area and aggregation area; Furthermore, polygonal annotations are performed on the corn pest infestation area images, with the number of points in the annotation box in the range of [3, 6], and the shape of the pest infestation area is adaptively learned according to the maximum number of annotation points. Specifically, the coordinates of the last point are used to fill in the annotation data. The filled annotation data has the coordinates of 6 points, and the coordinates of each annotation point consist of x and y values, for a total of 12 coordinate values; the information of the filled coordinate points. ,in , They represent the first The horizontal and vertical coordinates of each point. Simultaneously, this invention sets up real-world labels. This is used to distinguish between real points and filled points. (0 represents a filled point, 1 represents a real point) indicates the first... Are the points real points?

[0007] S3. Input the preprocessed corn pest area image into the backbone network of the Poly-YOLOv8 pest area detection model for feature extraction, then perform feature fusion through the neck network, and finally input it into the improved decoupled detection head to generate the detection result. The improved decoupled detection head includes a category branch, a coordinate prediction branch, and a target bounding box prediction branch. The category branch outputs the classification result; the coordinate prediction branch outputs the coordinate result; and the target bounding box prediction branch outputs the target bounding box position.

[0008] Furthermore, the feature extraction process of the backbone network specifically includes: The backbone network uses multiple feature fusion modules to slice the input image and extract features from it, while integrating operations based on multiple feature fusion modules and gradient changes in the feature maps; during the backbone network feature extraction process, the model generates feature maps at three different scales: , , ; in It is a feature map with a scale of 20×20×(512×w), used to capture pest information of smaller size in the image; It is a feature map with a scale of 40×40×(512×w) used to capture pest information of medium size; It is a feature map with a scale of 80×80×(256×w), used to capture larger-scale pest information; where It is an adjustment factor used to adapt to model parameters of different sizes. In this invention, it is set... The value is 1.

[0009] Furthermore, the feature fusion of the neck network specifically includes: The feature maps of three different scales output by the backbone network are used as input to the neck network. The neck network combines upsampling, downsampling and feature fusion modules, and finally outputs a feature map of the same scale as the backbone network.

[0010] The improved decoupled detection head is a polygon detection head designed based on the decoupled head mechanism. The polygon detection head includes a coordinate prediction branch, a target box prediction branch, and a category branch. The feature maps at three different scales output by the neck network are used as input to the polygon detection head, using a size of [size missing]. The convolution kernel is used to perform convolution operations to predict 12-dimensional coordinate information related to the feature map. ,in , indicating the first Coordinate information of each predicted point; In the coordinate prediction branch, the convolution operation aims to extract the actual existence information of the coordinate points. The mathematical expression of this information extraction process is shown in formula (1): (1) in The output of the coordinate prediction branch, Convolution operation Generally refers to feature maps; Next, the order of the real coordinate points was used as a reference, and an order-insensitive algorithm was used to select the points closest to the real coordinate points from the subset of predicted coordinate points. These points formed a set D of coordinate loss pairs (loss_pair) for calculating the loss. Then, formula (2) is used to calculate the coordinate regression loss for each prediction box. : (2); in, Represents a set The number of elements in Represents a set One of the elements in the coordinate loss pair; This indicates the probability that the predicted bounding box exists in the coordinate loss pair; and These represent the x-coordinate and y-coordinate of the true bounding box in the coordinate loss pair, respectively. and These represent the x and y coordinates of the predicted bounding box in the coordinate loss, respectively. Then, the perimeter of the predicted bounding box is obtained from the output set D of the order-insensitive algorithm, and a scaling factor is introduced as an additional step. ,in , This represents the perimeter of the actual bounding box. The perimeter of the predicted bounding box is given, and then formula (3) is used to calculate the coordinate existence loss. : (3); This invention defines coordinate regression loss. .

[0011] In the target box prediction branch, this invention uses the polygon intersection-union ratio (IoU) loss function to constrain the shape of the target box. First, the real target box and the predicted target box are binarized respectively. Then, the IoU value of the pest area is obtained by calculating their intersection and union. Specifically, the IoU loss calculation formula is shown in formula (4): (4); in, For IoU loss, Represents the pixels covered by the actual bounding box. This represents the pixels covered by the predicted bounding box.

[0012] In the category branch, use Convolution kernels to predict target class probabilities The prediction process is shown in formula (5): (5); Next, this invention uses the binary cross-entropy loss function to calculate the loss for target classification. The specific formula for loss calculation is shown in formula (6): (6); in, This represents the loss for target classification. This represents the probability of the true label of the predicted bounding box. The predicted probability of the prediction box is represented by the formula (7). Taking into account these three losses, this invention uses formula (7) to calculate the total loss L of the model. (7); in, This represents the number of samples in the training set. This represents the index of the sample. The model will then use backpropagation to update the weights of the gradient optimization model.

[0013] Specifically, the order-insensitive algorithm includes an input of: a set of real coordinate points. Probability of the actual existence of coordinates , Set of predicted coordinate points , Probability of existence of predicted coordinates : The algorithm is initialized as follows: , where is an empty set. Then, a first-level loop operation is performed between the first point and the sixth point of the predicted coordinate points: If the probability of existence of the predicted coordinate point is 0, the first-level loop is exited; if the probability of existence of the predicted coordinate point is not 0, the following operations are performed: Initialize the distance dist = 0, the coordinate point index z = 0, and the probability of existence of the predicted coordinate v = 0. Next, a second-level loop operation is performed from the first point to the sixth point of the predicted points: Calculate the real point and the predicted point Euclidean distance . If the Euclidean distance of the calculated next point satisfies < dist, update the current value of dist to , update the current value of z to q, and update the current value of v to ; otherwise, keep the current values of dist, z, and v unchanged; After all operations are completed, exit the second-level loop operation. Finally, form a loss calculation triple loss_pair = < , , > with the point with the minimum distance and the corresponding probability of existence, and update the set , update the set , exit the first-level loop, and finally the algorithm outputs the set D.

[0014] S4. Use the trained and tested Poly-YOLOv8 pest area detection model to monitor the corn pest area in real time.

[0015] Compared with the prior art, the beneficial effects of the present invention are as follows: (1) A method for detecting corn leaf pest areas based on YOLOv8 provided by the present invention uses a polygon annotation method to annotate the corn leaf pest areas and constructs a polygon corn pest area dataset PolyCorn. This annotation method can better adapt to the complex shapes of pest areas, thereby improving the accuracy and precision of detection.

[0016] (2) This invention provides a method for detecting pest-infested areas on maize leaves based on YOLOv8. This invention combines the YOLOv8 model with polygon detection and proposes a new target detection model, Poly-YOLOv8. By utilizing the superior performance of the YOLOv8 model in the field of target detection, the detection capability of the Poly-YOLOv8 model for polygonal pest-infested areas is improved, solving the problems of background redundancy in traditional rectangular prediction boxes and the inability to locate boundaries in instance segmentation, thus achieving efficient and accurate pest-infested area detection.

[0017] (3) The present invention provides a method for detecting pest areas on corn leaves based on YOLOv8. The proposed order-insensitive algorithm solves the problem of overfitting the order of coordinate points during loss calculation and reduces loss sensitivity. It also helps to balance the feature learning ability of target boxes of different sizes, thereby improving the detection ability of small-sized pest areas and further improving the accuracy and precision of model detection. Attached Figure Description

[0018] Figure 1 This is a schematic diagram of the detection process described in this invention.

[0019] Figure 2 This is the image annotation of the corn pest infestation area in Embodiment 1 of the present invention.

[0020] Figures 3(a)-3(c) show the image classification and annotation of corn pest areas in Embodiment 1 of the present invention.

[0021] Figure 4 This is a structural diagram of the Poly-YOLOv8 model in Embodiment 1 of the present invention.

[0022] Figure 5 This is a structural diagram of the improved polygonal detection head in Embodiment 1 of the present invention.

[0023] Figures 6(a)-6(c) are schematic diagrams of the shape of the target box constrained by the overfitting and polygon intersection-union ratio loss function in Embodiment 1 of the present invention. Detailed Implementation

[0024] The present disclosure will be further described below with reference to the accompanying drawings and embodiments.

[0025] It should be noted that the following detailed descriptions are exemplary and intended to provide further illustration of this disclosure. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this disclosure pertains.

[0026] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the exemplary embodiments according to this disclosure. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms “comprising” and / or “including” are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.

[0027] Where there is no conflict, the embodiments and features described herein can be combined with each other.

[0028] Example 1 This embodiment provides a method for detecting pest-infested areas on maize leaves based on YOLOv8, such as... Figure 1 As shown: S1. Constructing the dataset: Collect the required number of multi-scene, multi-scale images of corn pest areas. The dataset is divided into 70% for training and 30% for testing. The dataset in this example uses 2225 multi-scene, multi-scale corn images, including different lighting and angles.

[0029] S2. Preprocess the corn pest infestation area images in the dataset: Use the lightweight annotation tool "labelme" to perform polygon annotation and divide the pest infestation areas into 3 categories: feeding area, infected area and aggregation area; In this dataset, this embodiment uses the lightweight annotation tool "labelme" for annotation. The images of corn pest infestation areas and their corresponding annotations are shown below. Figure 2 As shown.

[0030] In this embodiment, the pest-infested areas in the images are divided into three categories during annotation, as shown in Figure 3 below. These are the feeding area (Figure 3(a)), the infected area (Figure 3(b)), and the aggregation area (Figure 3(c)), thus constructing a leaf pest-infested area dataset (PolyCorn). Specifically, in this embodiment, the corn pest area image is labeled with polygons. In order to adapt to pest areas of different shapes and sizes, the number of points in the label box is between 3 and 6. The shape of the pest area is adaptively learned according to the maximum number of labeled points, so that the model can adapt to different numbers of labeled points.

[0031] This embodiment uses the coordinates of the last point to fill in the annotation data. The filled annotation data has the coordinates of 6 points, and the coordinates of each annotation point consist of x and y values, for a total of 12 coordinate values; the information of the filled coordinate points. ,in , They represent the first The x and y coordinates of each point. Simultaneously, this embodiment sets up real-world labels. This is used to distinguish between real points and filled points. (0 represents a filled point, 1 represents a real point) indicates the first... Are these points real points? S3. Training and testing using the Poly-YOLOv8 pest area detection model: Input the preprocessed corn pest area image into the backbone network of the Poly-YOLOv8 pest area detection model for feature extraction, then perform feature fusion through the neck network, and finally input it into the improved decoupled detection head to generate the detection result. The improved decoupled detection head includes a category branch, a coordinate prediction branch, and a target bounding box prediction branch. The category branch outputs the classification result; the coordinate prediction branch outputs the coordinate result; and the target bounding box prediction branch outputs the target bounding box position.

[0032] Specifically, corn pest images captured in real-world scenarios typically contain multiple leaves and complex backgrounds, including weeds and soil, making it difficult to distinguish the pests. To effectively extract features, this embodiment selects YOLOv8 as the backbone network. However, YOLOv8 still uses bounding boxes for target detection; therefore, this embodiment designs a new target detection model based on YOLOv8, named Poly-YOLOv8, for detecting irregular pest areas.

[0033] The Poly-YOLOv8 model diagram is shown below. Figure 4 As shown The feature extraction process of the backbone network specifically includes: The backbone network of the Poly-YOLOv8 model is responsible for extracting features from the input image. The backbone network uses multiple feature fusion modules to slice the input image and extract features from it, enhancing the focusing ability during feature extraction. Simultaneously, based on the integration of multiple feature fusion modules and gradient changes in the feature maps, the network's expressive power and feature richness are improved, enabling the network to better capture features and semantic information in the image. During the backbone network feature extraction process, the model generates feature maps at three different scales. In this embodiment, the feature outputs at the three different scales are defined as follows: , , ,in It is a feature map with a scale of 20×20×(512×w), used to capture pest information of smaller size in the image; It is a feature map with a scale of 40×40×(512×w) used to capture pest information of medium size. It is a feature map with a scale of 80×80×(256×w), used to capture larger-scale pest information; where It is an adjustment factor used to adapt to model parameters of different sizes; in this embodiment, it is set to... The value is 1.

[0034] The feature fusion of the neck network specifically includes: The feature maps of three different scales output by the backbone network are used as input to the neck network. The neck network combines upsampling, downsampling and feature fusion modules, and finally outputs a feature map of the same scale as the backbone network.

[0035] The improved decoupled detection head is a polygon detection head designed based on a decoupled head mechanism. The polygon detection head includes a coordinate prediction branch, a bounding box prediction branch, and a category branch, such as... Figure 5 As shown; The three different scale feature maps output by the neck network are used as input to the polygon detection head. In this embodiment, a size of [size missing] is used. The convolution kernel is used to perform convolution operations to predict 12-dimensional coordinate information related to the feature map. ,in , indicating the first The coordinate information of each predicted point. However, traditional polygon calculation methods are easily affected by the order of predicted points when predicting coordinate points. Overemphasizing the order of predicted points can lead to overfitting, as shown in Figure 6(a). However, as shown in Figure 6(b), when the predicted bounding box is close to the ground truth bounding box, overemphasizing the order of the predicted points can make the regression loss sensitive. This sensitivity increases the model's loss value, thereby weakening the model's ability to learn the shape of the detected target region. In addition, overfitting the order of coordinate points also reduces the robustness of the model, meaning that the model is easily affected by noise during training. In this embodiment, this phenomenon is called coordinate order sensitivity.

[0036] Therefore, to address this issue, this embodiment proposes a regression loss calculation method that does not consider the order of coordinate points, i.e., an order-insensitive algorithm. This improves the model's robustness to target shape, reduces loss sensitivity, and thus improves the performance of target region detection.

[0037] First, this embodiment introduces a branch called coordinate prediction. This branch uses convolution operations to extract the actual existence information of coordinate points so that the model can learn whether each coordinate point represents an actual point, usually represented in a binary manner (0 indicates non-existence, 1 indicates existence). The mathematical expression of this information extraction process is shown in formula (1): (1); in It is the output of the coordinate prediction branch.

[0038] Next, taking the order of the true coordinate points as a reference, based on this, in this embodiment, Algorithm 1 is used to separately select the points closest to the true coordinate points from the subset of predicted coordinate points, and these points form a set D of coordinate loss pairs (loss_pair) for calculating the loss.

[0039] The algorithm name of Algorithm 1 is the order-insensitive algorithm, and the inputs of this algorithm are: the set of true coordinate points , the probability of the true existence of coordinates , the set of predicted coordinate points , the probability of the existence of predicted coordinates : The algorithm first initializes: , where is an empty set. Then, a first-level loop operation is performed from the first point to the sixth point of the predicted coordinate points: if the existence probability of this predicted coordinate point is 0, then jump out of the first-layer loop; if the existence probability of this predicted coordinate point is not 0, then perform the following operations: initialize the distance dist = 0, the coordinate point subscript index z = 0, and the predicted coordinate existence probability v = 0. Next, a second-layer loop operation is performed from the first point to the sixth point of the predicted points respectively: calculate the Euclidean distance between the true point and the predicted point . If the Euclidean distance of the calculated next point satisfies < dist, then update the current value of dist to , update the current value of z to q, and update the current value of v to ; otherwise, keep the current values of dist, z, and v unchanged; After performing all operations, exit the second-layer loop operation. Finally, form a loss calculation triple loss_pair = < , , > with the point with the minimum distance and the corresponding existence probability, and update the set , update the set , exit the first-layer loop, and finally the algorithm outputs the set D. Then, formula (2) is used to calculate the coordinate regression loss of each predicted bounding box , (2); Among them, represents the number of elements in the set , represents an element in the set , that is, a coordinate loss pair. This indicates the probability that the predicted bounding box exists in the coordinate loss pair. and These represent the x-coordinate and y-coordinate of the true bounding box in the coordinate loss pair, respectively. and These represent the x and y coordinates of the predicted bounding box in the coordinate loss, respectively.

[0040] Furthermore, to balance the difference in loss values ​​between large and small bounding boxes and improve the detection performance for small insect-infested areas, this embodiment obtains the perimeter of the predicted box based on the output set D of the order-insensitive algorithm and introduces an additional scaling factor. ,in . This represents the perimeter of the actual bounding box. The perimeter of the predicted bounding box is given, and then formula (3) is used to calculate the coordinate existence loss. .

[0041] (3); This embodiment defines coordinate regression loss. .

[0042] In the target bounding box prediction branch, this embodiment uses the polygon intersection-union ratio (IoU) loss function to constrain the shape of the target bounding box, as shown in Figure 6(c). Since the shape of the pest area is usually a non-convex polygon, this embodiment uses the following steps to calculate the IoU: First, the real target bounding box and the predicted target bounding box are binarized respectively, and then the IoU value of the pest area is obtained by calculating their intersection and union. Specifically, the formula for calculating the IoU loss is shown in formula (4): (4); in, Represents the pixels covered by the actual bounding box. This represents the pixels covered by the predicted bounding box.

[0043] In the category branch, this embodiment uses Convolutional kernels to predict target class probabilities The prediction process is shown in formula (5): (5); Next, this embodiment uses the binary cross-entropy loss function to calculate the loss for target classification. The specific formula for loss calculation is shown in formula (6): (6); in, This represents the probability of the true label of the predicted bounding box. The predicted probability of the prediction box is represented by the formula (7). Taking into account these three types of loss, this embodiment uses formula (7) to calculate the total loss L of the model. (7); in, This represents the number of samples in the training set. This represents the index of the sample. The model will then use backpropagation to update the weights of the gradient optimization model.

[0044] Optimizing the loss function is a crucial part of model training. By minimizing the loss function, the model gradually improves its performance on the training data, enabling it to produce more accurate predictions. The design of the loss function influences how the model balances classification and localization tasks, and how it handles errors. After training, the model's parameters are optimized, and then the test dataset is used to calculate the model's accuracy, recall, and mAP (most-applied-to-analyze) scores. These metrics reflect the model's performance in real-world applications.

[0045] S4. Real-time monitoring: The trained and tested Poly-YOLOv8 pest detection model is used to monitor corn pest areas in real time.

[0046] Experimental results This embodiment compares the Poly-YOLOv8 model with five state-of-the-art object detection baseline models in this field. Specifically, the five baseline models are Mask R-CNN, Poly-YOLO, DPPD, CenterPoly, and CenterPolyV2. During the experiment, the number of GPUs (NVIDIA A100 40G) was set to 2, the number of training epochs was 300, 16 images were loaded on each GPU, and the input image size during training was [size missing]. The experimental results are shown in Table 1 below: Table 1 Comparison of Model Results

[0047] Analysis of the data in Table 1 leads to the following conclusions: The Poly-YOLOv8 proposed in this embodiment exhibits the best detection performance. Compared with Poly-YOLO, which also uses YOLO as its backbone network, Poly-YOLOv8's performance in various metrics is 14.24%, 12.47%, 12.8%, and 16.29% higher, respectively. This demonstrates that Poly-YOLOv8 has a significant advantage in detecting irregular pest areas.

[0048] Compared with baseline models (DPPD, CenterPoly, CenterPolyV2) that calculate loss values ​​using polar coordinates, Poly-YOLOv8 achieves higher accuracy by 10.65%, 8.21%, and 7.31%, respectively. This demonstrates that the order-insensitive loss proposed in this embodiment enables the model to have stronger feature learning capabilities, thereby achieving better detection results.

[0049] Finally, compared with the Mask R-CNN model using ResNet-FPN as its backbone, Poly-YOLOv8 improved its performance metrics by 5.54%, 2.67%, 1.57%, and 3.93%, respectively. This indicates that the backbone network of the Poly-YOLOv8 model further enhances its feature representation capabilities and semantic information extraction. Simultaneously, the introduction of the feature fusion module helps provide richer gradient information, thus enabling better learning of important information such as the shape and texture of the target. Overall, Poly-YOLOv8 can effectively detect polygonal insect infestation regions, with detection accuracy superior to mainstream baseline models.

[0050] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the technical solutions of the present invention, and are not intended to limit the specific implementation of the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the claims of the present invention should be included within the protection scope of the claims of the present invention.

Claims

1. A method for detecting pest-infested areas on maize leaves based on YOLOv8, characterized in that, include; S1. Constructing the dataset: Collect the required number of multi-scene, multi-scale images of corn pest areas, and use the dataset for training and testing according to the required proportions. S2. Preprocess the corn pest infestation area images in the dataset: Use the lightweight annotation tool labelme to perform polygon annotation and divide the pest infestation area into 3 categories: feeding area, infection area and aggregation area; S3. Input the preprocessed corn pest area image into the backbone network of the Poly-YOLOv8 pest area detection model for feature extraction, then perform feature fusion through the neck network, and finally input it into the improved decoupled detection head to generate the detection result. The improved decoupled detection head includes a category branch, a coordinate prediction branch, and a bounding box prediction branch, wherein the category branch outputs the classification result; The coordinate prediction branch outputs coordinate results; The target bounding box prediction branch outputs the target bounding box position; The feature extraction process of the backbone network specifically includes: The backbone network uses multiple feature fusion modules to slice the input image and extract features from it, while integrating operations based on multiple feature fusion modules and gradient changes in the feature maps; during the backbone network feature extraction process, the model generates feature maps at three different scales: , , ; in It is a feature map with a scale of 20×20×(512×w); It is a feature map with a scale of 40×40×(512×w); It is a feature map with a scale of 80×80×(256×w); where It is an adjustment factor used to adapt to model parameters of different sizes. =1; The feature fusion of the neck network specifically includes: The three different scale feature maps output by the backbone network are used as input to the neck network. The neck network combines upsampling, downsampling and feature fusion modules. Finally, the neck network outputs feature maps of the same size as the backbone network. In the coordinate prediction branch, the convolution operation aims to extract the actual existence information of the coordinate points. The mathematical expression of this information extraction process is shown in formula (1): (1); in The output of the coordinate prediction branch; Next, the order of the real coordinate points was used as a reference, and an order-insensitive algorithm was used to select the points closest to the real coordinate points from the subset of predicted coordinate points. These points formed a set D of coordinate loss pairs for calculating the loss. Then, formula (2) is used to calculate the coordinate regression loss for each prediction box. : (2); in, Represents a set The number of elements in Represents a set One of the elements in the coordinate loss pair; This indicates the probability that the predicted bounding box exists in the coordinate loss pair; and These represent the x and y coordinates of the true bounding box in the coordinate loss pair, respectively. and These represent the x and y coordinates of the predicted bounding box in the coordinate loss, respectively. The set D of coordinate loss pairs is computed using an order-insensitive algorithm, wherein the order-insensitive algorithm includes: The input to the order-insensitive algorithm is: a set of real coordinate points. Probability of the actual existence of coordinates Predicted set of coordinate points Predict the probability of the existence of coordinates : The algorithm first initializes: ,in If the set is empty, then perform the first-level loop operation from the first to the sixth point of the predicted coordinates: If the probability of the existence of the predicted coordinate point is 0, then exit the first loop; if the probability of the existence of the predicted coordinate point is not 0, then perform the following operations: initialize distance dist=0, coordinate point index z=0, and predicted coordinate existence probability v=0. Next, perform the following second-layer loop operations from the first point to the sixth point of the prediction points: Calculate the true point and the prediction point 's Euclidean distance . If the Euclidean distance of the next calculated point satisfies < dist, update the current value of dist to , update the current value of z to q, and update the current value of v to ; otherwise, keep the current values of dist, z, and v unchanged; After completing all operations, exit the second loop. Finally, calculate the loss by combining the point with the smallest distance and its corresponding existence probability into a triplet: loss_pair=< , , > and update the set Update collection Exit the first loop, and the algorithm finally outputs set D; S4. The trained and tested Poly-YOLOv8 pest detection model is used to monitor corn pest areas in real time.

2. The method for detecting pest-infested areas on maize leaves based on YOLOv8 according to claim 1, characterized in that, S2 specifically includes: Polygonal annotations are performed on images of corn pest areas, with the number of points in the annotation box in the range of [3, 6]. The shape of the pest area is adaptively learned based on the maximum number of annotation points. The annotation data is filled using the coordinates of the last point. The filled annotation data contains the coordinates of 6 points, each consisting of an x-value and a y-value, for a total of 12 coordinate values. (Information on the filled coordinate points follows.) ,in , They represent the first The x and y coordinates of each point; At the same time, set real-existing tags. This is used to distinguish between real points and filled points. 0 represents a filled point, 1 represents a real point, and represents the first point. Are the points real points? 3. The method for detecting pest-infested areas on maize leaves based on YOLOv8 according to claim 2, characterized in that, The improved decoupled detection head is a polygon detection head designed based on the decoupled head mechanism. The polygon detection head includes a coordinate prediction branch, a target box prediction branch, and a category branch. The feature maps at three different scales output by the neck network are used as input to the polygon detection head, using a size of [size missing]. The convolution kernel is used to perform convolution operations to predict 12-dimensional coordinate information related to the feature map. ,in , indicating the first Coordinate information of each predicted point; Then, the perimeter of the predicted bounding box is obtained from the output set D of the order-insensitive algorithm, and a scaling factor is introduced as an additional step. ,in , This represents the perimeter of the actual bounding box. The perimeter of the predicted bounding box is given, and then formula (3) is used to calculate the coordinate existence loss. : (3); Finally, define the coordinate regression loss. ; In the target box prediction branch, the polygon intersection-union ratio (IoU) loss function is used to constrain the shape of the target box. First, the real target box and the predicted target box are binarized respectively. Then, the IoU value of the pest area is obtained by calculating their intersection and union. The formula for calculating the IoU loss is shown in formula (4): (4); in, Loss due to IoU; Represents the pixels covered by the actual bounding box. Represents the pixels covered by the predicted bounding box; In the category branch, use Convolutional kernels to predict target class probabilities The prediction process is shown in formula (5): (5); Next, the binary cross-entropy loss function is used to calculate the loss for target classification. The specific formula for loss calculation is shown in formula (6): (6); in, This represents the loss for classifying the target. This represents the probability of the true label of the predicted bounding box. The predicted probability of the prediction box is represented by the formula (7). Taking into account these three losses, the total loss L of the model is calculated using the formula (7). (7); in, This represents the number of samples in the training set. This represents the index of the sample. The model will then use backpropagation to update the weights of the gradient optimization model.

Citation Information

Patent Citations

  • Pantograph detection method based on Mask Scoring R-CNN

    CN113763326A

  • Fish visual identification method based on multi-task fusion

    CN114842215A