Crop-oriented small target pest detection method and system

By constructing a small target pest detection model including backbone network, feature fusion network and detection head network, the problem of low detection accuracy of small target pests in crops is solved, and efficient and accurate small target pest detection is achieved.

CN119540523AActive Publication Date: 2025-02-28SOUTH CHINA AGRICULTURAL UNIVERSITY
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411526135.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-30
Publication Date
2025-02-28
Estimated Expiration
2044-10-30

AI Technical Summary

Technical Problem

The prior art has low detection accuracy of small and medium-sized target pests in crop pest detection, making it difficult to meet the real-time detection needs.

Method used

A small-target pest detection method for crops is adopted, and a small-target pest detection model including backbone network, feature fusion network and detection head network is constructed. The total loss function is set for training to improve detection accuracy and speed.

Benefits of technology

The detection accuracy of small target pests in crops is improved, the robustness of the model is enhanced, the occurrence of overfitting is reduced, and the accurate and rapid detection of small target pests is achieved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119540523A_ABST
    Figure CN119540523A_ABST
Patent Text Reader

Abstract

The invention discloses a crop-oriented small target pest detection method and system, and relates to the technical field of computer vision and target detection, and the method comprises the steps: obtaining a crop pest data set which comprises a plurality of crop pest images with pest labels; preprocessing the crop pest data set to obtain a preprocessed crop pest data set, inputting the preprocessed crop pest data set into the small target pest detection model, setting a total loss function for training, and when the total loss function value is minimum, obtaining a trained small target pest detection model; and obtaining a to-be-detected crop image, inputting the to-be-detected crop image into the trained small target pest detection model, obtaining detection results and positioning results of all pests in the to-be-detected crop image, and performing NMS non-maximum suppression to obtain a final pest detection result of the to-be-detected crop image. According to the invention, small target pests in crops can be accurately and rapidly detected.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer vision and target detection, and more specifically, to a method and system for detecting small target pests of crops. Background Art

[0002] Pests can cause serious harm to crop production, leading to reduced or even destroyed crop yields. To this end, it is necessary to develop efficient and accurate pest detection methods and publish pest monitoring information in a timely manner to help farmers and relevant management departments take timely response measures to avoid major losses caused by pest outbreaks. At present, my country mainly uses manual methods for pest monitoring. However, manual pest monitoring consumes a lot of manpower and financial resources, and cannot guarantee the accuracy of detection. To solve this problem, with the development of machine vision, image processing and other technologies, researchers have proposed a variety of automatic detection methods for crop pests, which have made up for the shortcomings of manual methods.

[0003] In the early days, the crop pest detection method based on traditional machine learning was mainly used. The crop pest detection method based on traditional machine learning relies on manual feature design, and the detection performance depends on the designed manual features, so the overall detection performance is affected to a certain extent. In recent years, the crop pest detection method based on deep learning has become a better option. The target detection algorithm based on deep learning can automatically extract features and is mainly divided into two categories: target detection method based on two stages and target detection method based on single stage. The crop pest detection method based on two stages has a higher accuracy, but the detection speed is slower. The crop pest detection method based on single stage has a slightly lower accuracy, but the detection speed is faster, which is suitable for pest detection tasks with higher real-time requirements. In view of the latter's better detection accuracy and faster detection speed, the single stage detection method is widely used in pest detection.

[0004] Although crop pest detection methods based on deep learning have achieved some results in recent years, since pests in pest dataset images are often distributed in multiple scales and there are more small-target pests, the detection accuracy of large-target pests is relatively high, but the detection accuracy of small and medium-target pests still has a lot of room for improvement. Summary of the invention

[0005] One of the purposes of the present invention is to provide a small target pest detection method for crops to overcome the defect of low detection accuracy of small and medium target pests in the above-mentioned prior art; the second purpose is to provide a small target pest detection system for crops; the third purpose is to provide a computer device.

[0006] In order to solve the above technical problems, the technical solution of the present invention is as follows:

[0007] The present invention provides a method for detecting small target pests of crops, comprising:

[0008] S1: Acquire a crop pest dataset, where the crop pest dataset includes a number of crop pest images with pest annotations;

[0009] S2: preprocessing the crop pest dataset to obtain a preprocessed crop pest dataset;

[0010] S3: Construct a small target pest detection model, including a backbone network, a feature fusion network, and a detection head network connected in sequence;

[0011] S4: inputting the preprocessed crop pest data set into the small target pest detection model, setting the total loss function for training, and obtaining the trained small target pest detection model when the total loss function value is minimum;

[0012] S5: obtaining a crop image to be detected, inputting it into a trained small target pest detection model, and obtaining detection results and positioning results of all pests in the crop image to be detected;

[0013] S6: Perform NMS non-maximum suppression on the detection results and positioning results of all pests to obtain the final pest detection result of the crop image to be detected.

[0014] Preferably, the preprocessing includes any one or more of horizontal flipping, vertical flipping, random rotation, random cropping, deformation scaling, HSV transformation, and mosaic enhancement.

[0015] Preferably, the backbone network comprises a first convolutional layer, a first batch of normalization layers, a first activation function layer, a maximum pooling layer, a first feature extraction unit, a second feature extraction unit, a third feature extraction unit and a fourth feature extraction unit connected in sequence; the output ends of the second feature extraction unit, the third feature extraction unit and the fourth feature extraction unit are all connected to the input end of the feature fusion network;

[0016] The first feature extraction unit, the second feature extraction unit, the third feature extraction unit, and the fourth feature extraction unit each include a plurality of neck subunits connected in sequence;

[0017] The neck subunit includes a first dynamic convolution layer, a second batch normalization layer, a second dynamic convolution layer, a third batch normalization layer, a third dynamic convolution layer, a fourth batch normalization layer, a first summing point and a second activation function layer connected in sequence; the input end of the first dynamic convolution layer is also connected to the input end of the first summing point.

[0018] It should be noted that the backbone network is improved based on the ResNet50 neural network, retaining the first 44 layers of the ResNet50 neural network, and introducing a full-dimensional dynamic convolution layer to replace the traditional convolution layer; the backbone network of the present application trims the ResNet50 neural network according to the characteristics of small target pests, and introduces a full-dimensional dynamic convolution. By trimming the network layer with the largest number of parameters but the least extracted features, the training difficulty of the backbone network is reduced, and the feature extraction capability of the backbone network for small target pests is enhanced.

[0019] Preferably, the feature fusion network includes a first CBS block, a first upsampling layer, a second summing point, a second convolutional layer, a third convolutional layer, a fourth convolutional layer, a second CBS block, a second upsampling layer, a third summing point, a fifth convolutional layer, a sixth convolutional layer, a seventh convolutional layer, a third CBS block, a fourth summing point, an eighth convolutional layer, a ninth convolutional layer, a tenth convolutional layer, a fourth CBS block, a fifth summing point, an eleventh convolutional layer, a twelfth convolutional layer and a thirteenth convolutional layer connected in sequence;

[0020] The input end of the first CBS block is connected to the output end of the fourth feature extraction unit, and the output end of the first CBS block is also connected to the input end of the fifth summing point; the input end of the second summing point is also connected to the output end of the third feature extraction unit; the output end of the second CBS block is also connected to the input end of the fourth summing point; the input end of the third summing point is also connected to the output end of the second feature extraction unit;

[0021] The output ends of the seventh convolutional layer, the tenth convolutional layer, and the thirteenth convolutional layer are all connected to the input end of the detection head network.

[0022] It should be noted that the first CBS block, the first upsampling layer, the second summing point, the second convolutional layer, the third convolutional layer, the fourth convolutional layer, the second CBS block, the second upsampling layer, and the third summing point form a pyramid feature fusion network structure for preliminarily fusing the feature information extracted by the second feature extraction unit, the third feature extraction unit, and the fourth feature extraction unit, and transmitting the fused feature information from top to bottom; the fifth convolutional layer, the sixth convolutional layer, the seventh convolutional layer, the third CBS block, the fourth summing point, the eighth convolutional layer, the ninth convolutional layer, the tenth convolutional layer, the fourth CBS block, the fifth summing point, the eleventh convolutional layer, the twelfth convolutional layer, and the thirteenth convolutional layer form a path aggregation network structure for receiving the fused feature information transmitted by the pyramid feature fusion network structure, and conveying the feature information from bottom to top, and summing and connecting.

[0023] Preferably, the detection head network comprises a first decoupling head unit, a second decoupling head unit and a third decoupling head unit arranged in parallel, and input ends of the first decoupling head unit, the second decoupling head unit and the third decoupling head unit are all connected to output ends of the seventh convolutional layer, the tenth convolutional layer and the thirteenth convolutional layer;

[0024] The first decoupling head unit, the second decoupling head unit and the third decoupling head unit have the same structure, and all include a classification task decoupling head branch unit, a positioning task decoupling head branch unit and a confidence decoupling head branch unit which are arranged in parallel;

[0025] The classification task decoupling head branch unit includes a first reshaping layer, a first fully connected layer, a second fully connected layer, a third fully connected layer, and a second reshaping layer connected in sequence; the input end of the first reshaping layer is connected to the output ends of the seventh convolutional layer, the tenth convolutional layer, and the thirteenth convolutional layer;

[0026] The positioning task decoupling head branch unit includes a fourteenth convolutional layer, a fifteenth convolutional layer and a sixteenth convolutional layer connected in sequence; the input end of the fourteenth convolutional layer is connected to the output ends of the seventh convolutional layer, the tenth convolutional layer and the thirteenth convolutional layer;

[0027] The confidence decoupling head branch unit includes a third reshaping layer, a fourth fully connected layer, a fifth fully connected layer and a fourth reshaping layer connected in sequence; the input end of the third reshaping layer is connected to the output ends of the seventh convolutional layer, the tenth convolutional layer and the thirteenth convolutional layer.

[0028] It should be noted that the classification task decoupling head branch unit is used to obtain the classification results of small target pests in crop images, the localization task decoupling head branch unit is used to obtain the localization results of small target pests in crop images, and the confidence decoupling head branch unit is used to obtain the confidence results. The detection head network adopts three parallel decoupling head structures. By decoupling the classification and localization tasks, it provides better bounding box information and more accurate loss assessment for small target pests, thereby improving the detection accuracy of small target pests; the decoupling head structure reduces the number of parameters and the amount of calculation of the model, greatly speeds up the training and reasoning speed of the model, and improves the model's perception of target features of different scales, thereby improving the robustness and accuracy of the model and reducing the occurrence of overfitting.

[0029] Preferably, the total loss function comprises:

[0030]

[0031] In the formula, Loss represents the total loss function, N represents the number of detection layers, and L cls represents the classification loss function, L obj represents the confidence loss function, L box represents the positioning loss function, λ1,λ2,λ3 represent the first weight, the second weight and the third weight respectively.

[0032] Preferably, the classification loss function includes:

[0033]

[0034] Where, L cls represents the classification loss function, M represents the total number of pest categories, y j represents the probability of predicting the jth category, Represents the true value of the j-th category.

[0035] Preferably, the positioning loss function includes:

[0036] L box =αL NWD +(1-α)L MPDIoU

[0037] Where, L box represents the positioning loss function, L NWD represents the first bounding box similarity loss function, L MPDIoU represents the second bounding box similarity loss function, and α represents the weight; where:

[0038] L NWD =1-NWD

[0039]

[0040] Where NWD represents the normalized Wasserstein distance between the predicted bounding box and the true bounding box, x, y represent the horizontal and vertical coordinates of the center point of the predicted bounding box, w, h represent the width and height of the predicted bounding box, and x gt ,y gt Respectively represent the horizontal and vertical coordinates of the center point of the real bounding box, w gt ,h gt Represent the width and height of the real bounding box respectively, and C represents a constant;

[0041] L MPDIoU =1-MPDIoU

[0042]

[0043] Where MPDIoU means minimizing the distance between the upper left vertex and the lower right vertex between the predicted bounding box and the true bounding box, IoU means finding the intersection over union ratio between the predicted bounding box and the true bounding box, and w p ,h p They represent the width and height of the crop pest image respectively, d1 represents the Euclidean distance between the upper left corner vertex of the predicted bounding box and the upper left corner vertex of the true bounding box, and d2 represents the Euclidean distance between the lower right corner vertex of the predicted bounding box and the lower right corner vertex of the true bounding box.

[0044] It should be noted that this application has improved the positioning loss function, combining NWD loss and MPDIoU loss, reducing the sensitivity of MPDIoU loss to tiny target objects, and is more suitable for small target pest detection tasks. After combining the two, not only factors such as overlapping or non-overlapping areas, center point distance, width and height deviation are taken into account, but also the detection model can be effectively optimized under the same aspect ratio; and with the assistance of Wasserstein distance metric, the similarity of small target distribution is measured, the accuracy of small target pest detection is improved, and the detection accuracy of the detection model is further improved.

[0045] The present invention also provides a small target pest detection system for crops, which is used to implement the above-mentioned small target pest detection method for crops, comprising:

[0046] A data acquisition module, used to acquire a crop pest dataset, wherein the crop pest dataset includes a plurality of crop pest images with pest annotations;

[0047] A data preprocessing module, used to preprocess the crop pest dataset to obtain a preprocessed crop pest dataset;

[0048] A model building module is used to build a small target pest detection model, including a backbone network, a feature fusion network, and a detection head network connected in sequence;

[0049] A model training module, used for inputting the preprocessed crop pest data set into a small target pest detection model, setting a total loss function for training, and obtaining a trained small target pest detection model when the total loss function value is minimum;

[0050] The pest detection unit is used to obtain the crop image to be detected, input it into the trained small target pest detection model, and obtain the detection results and positioning results of all the pests in the crop image to be detected;

[0051] The final detection unit is used to perform NMS non-maximum suppression on the detection results and positioning results of all pests to obtain the final pest detection results of the crop image to be detected.

[0052] The present invention also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above-mentioned small target pest detection method for crops when executing the computer program.

[0053] Compared with the prior art, the technical solution of the present invention has the following beneficial effects:

[0054] The present invention first obtains a number of crop pest images with pest annotations to form a crop pest data set; then the crop pest data set is preprocessed and input into an established small target pest detection model, a total loss function is set for training, and when the total loss function value is the minimum, a trained small target pest detection model is obtained; the established small target pest detection model includes a backbone network, a feature fusion network and a detection head network connected in sequence, which are respectively used for feature extraction, feature fusion and classification positioning of small target pests, and enhances the feature extraction capability of small target pests, fully integrates the multi-scale features of small target pests, and the set total loss function is more suitable for small target pest detection, improves the detection accuracy of small target pests, improves the robustness of the model, and reduces the occurrence of overfitting. Finally, the crop image to be detected is input into the trained small target pest detection model, and the detection results and positioning results of all pests in the crop image to be detected are obtained, and NMS non-maximum suppression is performed to obtain the final pest detection result of the crop image to be detected. The present invention can realize accurate and rapid detection of small target pests in crops. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] Figure 1 This is a flow chart of a method for detecting small target pests for crops described in Example 1;

[0056] Figure 2 This is a schematic diagram of the structure of the small target pest detection model described in Example 2;

[0057] Figure 3 This is a schematic diagram of the structure of the backbone network described in Example 2;

[0058] Figure 4 This is a schematic structural diagram of the neck subunit described in Example 2;

[0059] Figure 5 This is a schematic diagram of the structure of the fusion network described in Example 2;

[0060] Figure 6 This is a schematic diagram of the structure of the detection head network described in Example 2;

[0061] Figure 7 This is a schematic diagram of the structures of the first decoupling head unit, the second decoupling head unit, and the third decoupling head unit described in Example 2;

[0062] Figure 8 This is a schematic diagram of the structure of a small target pest detection system for crops described in Example 3;

[0063] Fig. 9 This is a schematic diagram of the structure of a computer device described in Example 3. DETAILED DESCRIPTION

[0064] The drawings are for illustrative purposes only and should not be construed as limiting the present patent;

[0065] In order to better illustrate the present embodiment, some parts in the drawings may be omitted, enlarged or reduced, and do not represent the size of the actual product;

[0066] It is understandable to those skilled in the art that some well-known structures and their descriptions may be omitted in the drawings.

[0067] The technical solution of the present invention is further described below in conjunction with the accompanying drawings and embodiments.

[0068] Example 1

[0069] This embodiment provides a method for detecting small target pests of crops. Figure 1 As shown, including:

[0070] S1: Acquire a crop pest dataset, where the crop pest dataset includes a number of crop pest images with pest annotations;

[0071] S2: preprocessing the crop pest dataset to obtain a preprocessed crop pest dataset;

[0072] S3: Construct a small target pest detection model, including a backbone network, a feature fusion network, and a detection head network connected in sequence;

[0073] S4: inputting the preprocessed crop pest data set into the small target pest detection model, setting the total loss function for training, and obtaining the trained small target pest detection model when the total loss function value is minimum;

[0074] S5: obtaining a crop image to be detected, inputting it into a trained small target pest detection model, and obtaining detection results and positioning results of all pests in the crop image to be detected;

[0075] S6: Perform NMS non-maximum suppression on the detection results and positioning results of all pests to obtain the final pest detection result of the crop image to be detected.

[0076] In the specific implementation process, this embodiment first obtains a number of crop pest images with pest annotations to form a crop pest data set; then the crop pest data set is preprocessed and input into the established small target pest detection model, and the total loss function is set for training. When the total loss function value is the minimum, the trained small target pest detection model is obtained; the established small target pest detection model includes a backbone network, a feature fusion network and a detection head network connected in sequence, which are respectively used for feature extraction, feature fusion and classification positioning of small target pests, and enhances the feature extraction capability of small target pests, fully integrates the multi-scale features of small target pests, and the set total loss function is more suitable for small target pest detection, improves the detection accuracy of small target pests, improves the robustness of the model, and reduces the occurrence of overfitting. Finally, the crop image to be detected is input into the trained small target pest detection model to obtain the detection results and positioning results of all pests in the crop image to be detected, and NMS non-maximum suppression is performed to obtain the final pest detection result of the crop image to be detected. This embodiment can achieve accurate and rapid detection of small target pests in crops.

[0077] Example 2

[0078] This embodiment provides a method for detecting small target pests of crops, including:

[0079] S1: Acquire a crop pest dataset, where the crop pest dataset includes a number of crop pest images with pest annotations;

[0080] S2: preprocessing the crop pest dataset to obtain a preprocessed crop pest dataset;

[0081] The preprocessing includes any one or more of horizontal flipping, vertical flipping, random rotation, random cropping, deformation scaling, HSV transformation, and mosaic enhancement;

[0082] S3: Construct a small target pest detection model, such as Figure 2 As shown, it includes a backbone network, a feature fusion network and a detection head network connected in sequence;

[0083] like Figure 3 As shown, the backbone network includes a first convolutional layer, a first batch of normalization layers, a first activation function layer, a maximum pooling layer, a first feature extraction unit, a second feature extraction unit, a third feature extraction unit and a fourth feature extraction unit connected in sequence; the output ends of the second feature extraction unit, the third feature extraction unit and the fourth feature extraction unit are all connected to the input end of the feature fusion network;

[0084] The first feature extraction unit, the second feature extraction unit, the third feature extraction unit, and the fourth feature extraction unit all include a number of neck sub-units connected in sequence; in this embodiment, the first feature extraction unit includes 3 neck sub-units connected in sequence, the first feature extraction unit includes 3 neck sub-units connected in sequence, the second feature extraction unit includes 6 neck sub-units connected in sequence, the third feature extraction unit includes 4 neck sub-units connected in sequence, and the fourth feature extraction unit includes 1 neck sub-unit.

[0085] like Figure 4 As shown, the neck subunit includes a first dynamic convolution layer, a second batch normalization layer, a second dynamic convolution layer, a third batch normalization layer, a third dynamic convolution layer, a fourth batch normalization layer, a first summing point and a second activation function layer connected in sequence; the input end of the first dynamic convolution layer is also connected to the input end of the first summing point.

[0086] It should be noted that the backbone network is improved based on the ResNet50 neural network, retaining the first 44 layers of the ResNet50 neural network, and introducing a full-dimensional dynamic convolution layer to replace the traditional convolution layer; among them, the first convolution layer is a 7×7 convolution layer, the first dynamic convolution layer is a 1×1 dynamic convolution layer, the second dynamic convolution layer is a 3×3 dynamic convolution layer, and the third dynamic convolution layer is a 1×1 dynamic convolution layer. The first activation function layer and the second activation function layer are both ReLU activation function layers, and the dynamic convolution layers are all full-dimensional dynamic convolutions. The full-dimensional dynamic convolution can be expressed by the following formula:

[0087] f=(a ω1 ⊙a f1 ⊙a c1 ⊙a s1 ⊙W1+…+a ωn ⊙a fn ⊙a cn ⊙a sn ⊙W n )*f i

[0088] in, and are the input features and output features respectively, C out The i-th convolution kernel composed of filters, is the attention scalar of the convolution kernel, They are the three scalars of interest on the newly introduced spatial dimension, input channel dimension, and output channel dimension, respectively. ⊙ represents the element multiplication operation on the newly introduced three-dimensional space in the kernel space, and * represents the convolution operation. The backbone network of this application prunes the ResNet50 neural network according to the characteristics of small target pests, and introduces full-dimensional dynamic convolution. By pruning the network layer with the most parameters but the least extracted features, the training difficulty of the backbone network is reduced, and the feature extraction capability of the backbone network for small target pests is enhanced.

[0089] like Figure 5 As shown, the feature fusion network includes a first CBS block, a first upsampling layer, a second summing point, a second convolutional layer, a third convolutional layer, a fourth convolutional layer, a second CBS block, a second upsampling layer, a third summing point, a fifth convolutional layer, a sixth convolutional layer, a seventh convolutional layer, a third CBS block, a fourth summing point, an eighth convolutional layer, a ninth convolutional layer, a tenth convolutional layer, a fourth CBS block, a fifth summing point, an eleventh convolutional layer, a twelfth convolutional layer and a thirteenth convolutional layer connected in sequence;

[0090] The input end of the first CBS block is connected to the output end of the fourth feature extraction unit, and the output end of the first CBS block is also connected to the input end of the fifth summing point; the input end of the second summing point is also connected to the output end of the third feature extraction unit; the output end of the second CBS block is also connected to the input end of the fourth summing point; the input end of the third summing point is also connected to the output end of the second feature extraction unit;

[0091] The output ends of the seventh convolutional layer, the tenth convolutional layer, and the thirteenth convolutional layer are all connected to the input end of the detection head network.

[0092] It should be noted that the first CBS block, the first upsampling layer, the second summing point, the second convolutional layer, the third convolutional layer, the fourth convolutional layer, the second CBS block, the second upsampling layer, and the third summing point form a pyramid feature fusion network structure for preliminarily fusing the feature information extracted by the second feature extraction unit, the third feature extraction unit, and the fourth feature extraction unit, and transmitting the fused feature information from top to bottom; the fifth convolutional layer, the sixth convolutional layer, the seventh convolutional layer, the third CBS block, the fourth summing point, the eighth convolutional layer, the ninth convolutional layer, the tenth convolutional layer, the fourth CBS block, the fifth summing point, the eleventh convolutional layer, the twelfth convolutional layer, and the thirteenth convolutional layer form a path aggregation network structure for receiving the fused feature information transmitted by the pyramid feature fusion network structure, and conveying the feature information from bottom to top, and summing and connecting.

[0093] like Figure 6As shown, the detection head network includes a first decoupling head unit, a second decoupling head unit and a third decoupling head unit arranged in parallel, and the input ends of the first decoupling head unit, the second decoupling head unit and the third decoupling head unit are all connected to the output ends of the seventh convolutional layer, the tenth convolutional layer and the thirteenth convolutional layer;

[0094] like Figure 7 As shown, the first decoupling head unit, the second decoupling head unit and the third decoupling head unit have the same structure, and all include a classification task decoupling head branch unit, a positioning task decoupling head branch unit and a confidence decoupling head branch unit arranged in parallel;

[0095] The classification task decoupling head branch unit includes a first reshaping layer, a first fully connected layer, a second fully connected layer, a third fully connected layer, and a second reshaping layer connected in sequence; the input end of the first reshaping layer is connected to the output ends of the seventh convolutional layer, the tenth convolutional layer, and the thirteenth convolutional layer;

[0096] The positioning task decoupling head branch unit includes a fourteenth convolutional layer, a fifteenth convolutional layer and a sixteenth convolutional layer connected in sequence; the input end of the fourteenth convolutional layer is connected to the output ends of the seventh convolutional layer, the tenth convolutional layer and the thirteenth convolutional layer;

[0097] The confidence decoupling head branch unit includes a third reshaping layer, a fourth fully connected layer, a fifth fully connected layer and a fourth reshaping layer connected in sequence; the input end of the third reshaping layer is connected to the output ends of the seventh convolutional layer, the tenth convolutional layer and the thirteenth convolutional layer.

[0098] It should be noted that the classification task decoupling head branch unit is used to obtain the classification results of small target pests in crop images, the localization task decoupling head branch unit is used to obtain the localization results of small target pests in crop images, and the confidence decoupling head branch unit is used to obtain the confidence results. The detection head network adopts three parallel decoupling head structures. By decoupling the classification and localization tasks, it provides better bounding box information and more accurate loss assessment for small target pests, thereby improving the detection accuracy of small target pests; the decoupling head structure reduces the number of parameters and the amount of calculation of the model, greatly speeds up the training and reasoning speed of the model, and improves the model's perception of target features of different scales, thereby improving the robustness and accuracy of the model and reducing the occurrence of overfitting.

[0099] S4: inputting the preprocessed crop pest data set into the small target pest detection model, setting the total loss function for training, and obtaining the trained small target pest detection model when the total loss function value is minimum;

[0100] The total loss function consists of three parts, namely, classification loss function, confidence loss function and positioning loss function, which are expressed as:

[0101]

[0102] Among them, Loss represents the total loss function, N represents the number of detection layers, and L cls represents the classification loss function, L obj represents the confidence loss function, L box represents the positioning loss function, λ1,λ2,λ3 represent the first weight, the second weight and the third weight respectively;

[0103] The classification loss function uses the binary cross entropy loss function, expressed as:

[0104]

[0105] Where, L cls represents the classification loss function, M represents the total number of pest categories, y j represents the probability of predicting the jth category, represents the true value of the jth category, which can be 0 or 1. i Predict a value for the current category;

[0106] The positioning loss function combines the NMIoU function that combines the NWD loss and the MPDIoU loss, expressed as:

[0107] L box =αL NWD +(1-α)L MPDIoU

[0108] L NWD =1-NWD

[0109]

[0110] L MPDIoU =1-MPDIoU

[0111]

[0112] Where, L box represents the positioning loss function, L NWD represents the first bounding box similarity loss function, L MPDIoU represents the similarity loss function of the second bounding box, α represents the weight, NWD represents the normalized Wasserstein distance between the predicted bounding box and the true bounding box, x, y represent the horizontal and vertical coordinates of the center point of the predicted bounding box, w, h represent the width and height of the predicted bounding box, x gt ,y gt Respectively represent the horizontal and vertical coordinates of the center point of the real bounding box, w gt ,h gtRepresent the width and height of the true bounding box respectively, C represents a constant; MPDIoU represents minimizing the distance between the upper left vertex and the lower right vertex between the predicted bounding box and the true bounding box, IoU represents the intersection over union ratio between the predicted bounding box and the true bounding box, w p ,h p Respectively represent the width and height of the crop pest image, d1 represents the Euclidean distance between the upper left corner vertex of the predicted bounding box and the upper left corner vertex of the true bounding box, and d2 represents the Euclidean distance between the lower right corner vertex of the predicted bounding box and the lower right corner vertex of the true bounding box;

[0113] This application improves the positioning loss function, combines NWD loss and MPDIoU loss, reduces the sensitivity of MPDIoU loss to tiny target objects, and is more suitable for small target pest detection tasks. After combining the two, not only factors such as overlapping or non-overlapping areas, center point distance, width and height deviation are taken into account, but also the detection model can be effectively optimized under the same aspect ratio; and with the assistance of Wasserstein distance metric, the similarity of small target distribution is measured to improve the accuracy of small target pest detection, and further improve the detection accuracy of the detection model.

[0114] S5: obtaining a crop image to be detected, inputting it into a trained small target pest detection model, and obtaining detection results and positioning results of all pests in the crop image to be detected;

[0115] S6: Perform NMS non-maximum suppression on the detection results and positioning results of all pests to obtain the final pest detection result of the crop image to be detected.

[0116] In actual use, when training the model, after the preprocessed crop pest dataset is input into the small target pest detection model, N crop pest images are randomly selected and sequentially passed through the backbone network, feature fusion network and detection head network to obtain preliminary prediction results. The prediction results are compared with the pest annotations, the total loss function value is calculated, and the model parameters are updated by back-propagating the gradient according to the total loss function value. The above process is repeated until the total loss function value no longer decreases, and the final model parameters are saved to obtain a trained small target pest detection model; then N crop pest images are randomly selected again and input into the trained small target pest detection model to obtain pest detection results, and the evaluation index mAP of the model is calculated based on the pest detection results and pest annotations. When testing the performance of the model, the evaluation index mAP is used to measure the average accuracy of the model in multi-category target detection. The higher the value, the higher the overall accuracy of the algorithm. mAP is expressed as:

[0117]

[0118] Among them, c represents the number of categories; AP jRepresents the average accuracy of each category, which can be obtained by calculating the area enclosed by the accuracy-recall curve of different categories and the coordinate axis, expressed as:

[0119] AP j =∫0 1 p(r)dr

[0120] Among them, p(r) is the classification precision-recall rate PR curve function, which is controlled by the preset intersection-over-union ratio IoU threshold of the predicted bounding box and the true bounding box; by using different IoU settings, different PR curves can be drawn to calculate the mAP under different IoUs; the mAP when the IoU is set to 0.5 and the average mAP when the IoU is set from 0.5 to 0.95 (with a step size of 0.05) are used as the final evaluation indicators.

[0121] In addition, this embodiment compares the detection results of the method provided in this embodiment with other mainstream models on the main vegetable pest dataset. The main vegetable pest dataset includes crop pest images and corresponding pest annotations. The annotation format is consistent with Pascal VOC. The pest categories include: Category 1: Linnaeus, Category 2: Gennadius, Category 3: Coquillett, Category 4: Fabricius, Category 5: Frankliniella occidentalis Pergande, FPS is the number of images that can be processed per second, and the detection results are shown in the following table:

[0122]

[0123] It can be seen that compared with other mainstream models, the method provided in this embodiment has achieved the highest detection accuracy for pest categories other than the Fabricius category.

[0124] At the same time, this embodiment also conducts verification experiments on the effectiveness of different improvement strategies, where A represents the use of the backbone network described in this embodiment, B represents the use of the detection head network described in this embodiment, and C represents the use of the positioning loss function NMIoU described in this embodiment. The comparison results are shown in the following table:

[0125]

[0126] It can be seen that by improving the backbone network for feature extraction, the detection head network for detection, and the positioning loss function at the same time, the classification and positioning tasks can be more focused on their respective goals. The branches perform calculations independently to avoid mutual interference, thereby improving the accuracy and efficiency of detection. The decoupled head structure reduces the number of parameters and the amount of calculation required to be calculated in the model, greatly speeding up the training and reasoning speed of the model, and improving the model's perception of target features of different scales, thereby improving the robustness and accuracy of the model and reducing the occurrence of overfitting.

[0127] Example 3

[0128] This embodiment provides a small target pest detection system for crops, which is used to implement the small target pest detection method for crops described in Embodiment 1 or 2. Figure 8 As shown, including:

[0129] A data acquisition module, used to acquire a crop pest dataset, wherein the crop pest dataset includes a plurality of crop pest images with pest annotations;

[0130] A data preprocessing module, used to preprocess the crop pest dataset to obtain a preprocessed crop pest dataset;

[0131] A model building module is used to build a small target pest detection model, including a backbone network, a feature fusion network, and a detection head network connected in sequence;

[0132] A model training module, used for inputting the preprocessed crop pest data set into a small target pest detection model, setting a total loss function for training, and obtaining a trained small target pest detection model when the total loss function value is minimum;

[0133] The pest detection unit is used to obtain the crop image to be detected, input it into the trained small target pest detection model, and obtain the detection results and positioning results of all the pests in the crop image to be detected;

[0134] The final detection unit is used to perform NMS non-maximum suppression on the detection results and positioning results of all pests to obtain the final pest detection results of the crop image to be detected.

[0135] This embodiment also provides a computer device, such as Fig. 9 As shown, at least one processor 01 , at least one communication interface 02 , at least one memory 03 and at least one communication bus 04 .

[0136] In the embodiment of the present application, the number of the processor 01 , the communication interface 02 , the memory 03 , and the communication bus 04 is at least one, and the processor 01 , the communication interface 02 , and the memory 03 communicate with each other through the communication bus 04 .

[0137] Processor 01 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. Processor 01 may be implemented in at least one hardware form of a digital signal processor (DSP), a field-programmable gate array (FPGA), and a programmable logic array (PLA). Processor 01 may also include a main processor and a coprocessor. The main processor is a processor for processing data in an awake state, also known as a central processing unit (CPU); the coprocessor is a low-power processor for processing data in a standby state. In some embodiments, processor 01 may be integrated with a graphics processing unit (GPU), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, processor 01 may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.

[0138] The memory 03 may include one or more computer-readable storage media, which may be non-transitory. The memory 03 may also include a high-speed random access memory and a non-volatile memory, such as one or more disk storage devices and flash memory storage devices.

[0139] The memory 03 stores a program, and the processor 01 can call the program stored in the memory 03, and the program is used to execute the steps of the small target pest detection method for crops described in Example 1 or 2.

[0140] The same or similar reference numerals correspond to the same or similar components;

[0141] The terms used in the drawings to describe positional relationships are only used for illustrative purposes and should not be construed as limiting this patent;

[0142] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the embodiments of the present invention. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the embodiments here. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the claims of the present invention.

Claims

1. A method for detecting small target pests of crops, characterized in that: include: S1: Acquire a crop pest dataset, where the crop pest dataset includes a number of crop pest images with pest annotations; S2: preprocessing the crop pest dataset to obtain a preprocessed crop pest dataset; S3: Construct a small target pest detection model, including a backbone network, a feature fusion network, and a detection head network connected in sequence; S4: inputting the preprocessed crop pest data set into the small target pest detection model, setting the total loss function for training, and obtaining the trained small target pest detection model when the total loss function value is minimum; S5: obtaining a crop image to be detected, inputting it into a trained small target pest detection model, and obtaining detection results and positioning results of all pests in the crop image to be detected; S6: Perform NMS non-maximum suppression on the detection results and positioning results of all pests to obtain the final pest detection result of the crop image to be detected.

2. The small target pest detection method for crops according to claim 1, characterized in that: The preprocessing includes any one or more of horizontal flipping, vertical flipping, random rotation, random cropping, deformation scaling, HSV transformation, and mosaic enhancement.

3. The method for detecting small target pests for crops according to claim 1, characterized in that: The backbone network includes a first convolutional layer, a first batch of normalization layers, a first activation function layer, a maximum pooling layer, a first feature extraction unit, a second feature extraction unit, a third feature extraction unit and a fourth feature extraction unit connected in sequence; the output ends of the second feature extraction unit, the third feature extraction unit and the fourth feature extraction unit are all connected to the input end of the feature fusion network; The first feature extraction unit, the second feature extraction unit, the third feature extraction unit, and the fourth feature extraction unit each include a plurality of neck subunits connected in sequence; The neck subunit includes a first dynamic convolution layer, a second batch normalization layer, a second dynamic convolution layer, a third batch normalization layer, a third dynamic convolution layer, a fourth batch normalization layer, a first summing point and a second activation function layer connected in sequence; the input end of the first dynamic convolution layer is also connected to the input end of the first summing point.

4. The method for detecting small target pests for crops according to claim 3, characterized in that: The feature fusion network includes a first CBS block, a first upsampling layer, a second summing point, a second convolutional layer, a third convolutional layer, a fourth convolutional layer, a second CBS block, a second upsampling layer, a third summing point, a fifth convolutional layer, a sixth convolutional layer, a seventh convolutional layer, a third CBS block, a fourth summing point, an eighth convolutional layer, a ninth convolutional layer, a tenth convolutional layer, a fourth CBS block, a fifth summing point, an eleventh convolutional layer, a twelfth convolutional layer and a thirteenth convolutional layer connected in sequence; The input end of the first CBS block is connected to the output end of the fourth feature extraction unit, and the output end of the first CBS block is also connected to the input end of the fifth summing point; the input end of the second summing point is also connected to the output end of the third feature extraction unit; the output end of the second CBS block is also connected to the input end of the fourth summing point; the input end of the third summing point is also connected to the output end of the second feature extraction unit; The output ends of the seventh convolutional layer, the tenth convolutional layer, and the thirteenth convolutional layer are all connected to the input end of the detection head network.

5. The method for detecting small target pests for crops according to claim 4, characterized in that: The detection head network includes a first decoupling head unit, a second decoupling head unit and a third decoupling head unit arranged in parallel; the input ends of the first decoupling head unit, the second decoupling head unit and the third decoupling head unit are all connected to the output ends of the seventh convolutional layer, the tenth convolutional layer and the thirteenth convolutional layer; The first decoupling head unit, the second decoupling head unit and the third decoupling head unit have the same structure, and all include a classification task decoupling head branch unit, a positioning task decoupling head branch unit and a confidence decoupling head branch unit which are arranged in parallel; The classification task decoupling head branch unit includes a first reshaping layer, a first fully connected layer, a second fully connected layer, a third fully connected layer, and a second reshaping layer connected in sequence; the input end of the first reshaping layer is connected to the output ends of the seventh convolutional layer, the tenth convolutional layer, and the thirteenth convolutional layer; The positioning task decoupling head branch unit includes a fourteenth convolutional layer, a fifteenth convolutional layer and a sixteenth convolutional layer connected in sequence; the input end of the fourteenth convolutional layer is connected to the output ends of the seventh convolutional layer, the tenth convolutional layer and the thirteenth convolutional layer; The confidence decoupling head branch unit includes a third reshaping layer, a fourth fully connected layer, a fifth fully connected layer and a fourth reshaping layer connected in sequence; the input end of the third reshaping layer is connected to the output ends of the seventh convolutional layer, the tenth convolutional layer and the thirteenth convolutional layer.

6. The method for detecting small target pests for crops according to claim 1, characterized in that: The total loss function includes: In the formula, Loss represents the total loss function, N represents the number of detection layers, and L cls represents the classification loss function, L obj represents the confidence loss function, L box represents the positioning loss function, λ1,λ2,λ3 represent the first weight, the second weight and the third weight respectively.

7. The method for detecting small target pests for crops according to claim 6, characterized in that: The classification loss function includes: Where, L cls represents the classification loss function, M represents the total number of pest categories, y j represents the probability of predicting the jth category, Represents the true value of the j-th category.

8. The method for detecting small target pests for crops according to claim 6, characterized in that: The positioning loss function includes: L box =αL NWD +(1-α)L MPDIoU Where, L box represents the positioning loss function, L NWD represents the first bounding box similarity loss function, L MPDIoU represents the second bounding box similarity loss function, and α represents the weight; where: L NWD =1-NWD Where NWD represents the normalized Wasserstein distance between the predicted bounding box and the true bounding box, x, y represent the horizontal and vertical coordinates of the center point of the predicted bounding box, w, h represent the width and height of the predicted bounding box, and x gt ,y gt Respectively represent the horizontal and vertical coordinates of the center point of the real bounding box, w gt ,h gt Represent the width and height of the real bounding box respectively, and C represents a constant; L MPDIoU =1-MPDIoU Where MPDIoU means minimizing the distance between the upper left vertex and the lower right vertex between the predicted bounding box and the true bounding box, IoU means finding the intersection over union ratio between the predicted bounding box and the true bounding box, and w p ,h p They represent the width and height of the crop pest image respectively, d1 represents the Euclidean distance between the upper left corner vertex of the predicted bounding box and the upper left corner vertex of the true bounding box, and d2 represents the Euclidean distance between the lower right corner vertex of the predicted bounding box and the lower right corner vertex of the true bounding box.

9. A small target pest detection system for crops, used to implement the small target pest detection method for crops according to any one of claims 1 to 8, characterized in that: include: A data acquisition module, used to acquire a crop pest dataset, wherein the crop pest dataset includes a plurality of crop pest images with pest annotations; A data preprocessing module, used to preprocess the crop pest dataset to obtain a preprocessed crop pest dataset; A model building module is used to build a small target pest detection model, including a backbone network, a feature fusion network, and a detection head network connected in sequence; A model training module, used for inputting the preprocessed crop pest data set into a small target pest detection model, setting a total loss function for training, and obtaining a trained small target pest detection model when the total loss function value is minimum; The pest detection unit is used to obtain the crop image to be detected, input it into the trained small target pest detection model, and obtain the detection results and positioning results of all the pests in the crop image to be detected; The final detection unit is used to perform NMS non-maximum suppression on the detection results and positioning results of all pests to obtain the final pest detection results of the crop image to be detected.

10. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the small target pest detection method for crops described in any one of claims 1 to 8 are implemented.

Citation Information

Patent Citations

  • Three-stage pest image recognition method based on adaptive feature fusion pyramid network

    CN114565048A

  • Apple leaf disease detection method based on improved YOLOX-S algorithm

    CN116363517A

  • Forestry pest detection method and system based on multi-scale feature enhancement and fusion

    CN117671655A

  • Rice pest detection method based on Detr model

    CN118298164A

  • Method for constructing pest detection model

    WO2021203505A1