Corn leaf disease detection method, device, equipment and storage medium
Patent Information
- Application Number
- CN202310873747.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-14
- Publication Date
- 2026-09-22
- Estimated Expiration
- 2043-07-14
AI Technical Summary
[0005]本发明的主要目的在于提供了一种玉米叶病害检测方法、装置、设备及存储介质,旨在解决现有的利用病害检测模型应用于玉米叶病害检测时,由于病害目标较小,存在的检测精度不足的技术问题
[0034]本发明首先获取目标玉米叶图像;接着基于预设叶片病害识别模型对所述目标玉米叶图像进行病害叶片检测,确定玉米叶病害图像,所述预设叶片病害识别模型包括替换了原始YOLOv5s模型的特征融合模块中PAN结构的加权融合子模块,所述加权融合子模块与第一融合子模块和输出模块分别连接,所述加权融合子模块用于对经过所述第一融合子模块获得的浅层融合特征图进行双向特征融合,将经过双向特征融合后的特征信息输入至所述输出模块进行分类识别。由于本发明预设叶片病害模型中加权融合子模块能够对浅层融合特征图进行双向特征融合,对现有的采用YOLOv5s构建的病害检测模型进行了改进,能够在保持较快检测速度的同时提升对小目标病害的检测精度。
Smart Images

Figure CN116994131B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of plant disease detection technology, and in particular to a method, apparatus, equipment and storage medium for detecting diseases in maize leaves. Background Technology
[0002] Corn is a very important food crop and raw material in my country. However, in recent years, with the expansion of planting area and the lack of sound plant health care measures, the impact of corn diseases on corn yield has gradually increased. Therefore, the detection of corn diseases plays an important role in early prevention and control and ensuring normal corn growth.
[0003] Traditional disease detection methods rely entirely on personal experience and visual observation, resulting in slow speed, high subjectivity, low accuracy, and poor real-time performance, thus presenting certain limitations. Therefore, with the development of deep learning and continuous advancements in image acquisition technology, crop disease detection is gradually shifting towards the deep learning domain. However, existing model-based disease detection methods still have limitations. When applied to crop leaf detection, due to the small size of crop disease targets and the influence of background factors, small targets may be missed, leading to a lack of accuracy in the final detection results.
[0004] The above content is only used to help understand the technical solution of the present invention and does not represent an admission that the above content is related technology. Summary of the Invention
[0005] The main objective of this invention is to provide a method, apparatus, equipment, and storage medium for detecting corn leaf diseases, aiming to solve the technical problem of insufficient detection accuracy when using existing disease detection models for corn leaf disease detection due to the small size of the disease targets.
[0006] To achieve the above objectives, the present invention provides a method for detecting diseases in maize leaves, the method comprising the following steps:
[0007] Acquire the target corn leaf image;
[0008] Based on a preset leaf disease identification model, diseased leaves are detected in the target corn leaf image to identify diseased corn leaves. The preset leaf disease identification model includes a weighted fusion submodule that replaces the PAN structure in the feature fusion module of the original YOLOv5s model. The weighted fusion submodule is connected to the first fusion submodule and the output module, respectively. The weighted fusion submodule is used to perform bidirectional feature fusion on the shallow fusion feature map obtained by the first fusion submodule, and input the feature information after bidirectional feature fusion to the output module for classification and identification.
[0009] Optionally, the preset leaf disease identification model further includes an input module and a feature extraction module, wherein the feature extraction module is connected to the input module and the shallow feature fusion submodule, respectively;
[0010] The step of detecting diseased leaves in the target corn leaf image based on a preset leaf disease identification model to determine the corn leaf disease image includes:
[0011] The input module performs data augmentation preprocessing on the target corn leaf image to obtain the processed corn leaf image to be detected.
[0012] The feature extraction module extracts features from the corn leaf image to be detected to obtain an initial feature map.
[0013] The initial feature map is fused using the first fusion submodule to obtain a shallow fused feature map.
[0014] The weighted fusion submodule performs weighted bidirectional feature fusion on the shallow fusion feature map to obtain the feature map to be tested.
[0015] The output module detects diseased leaves in the feature map to be tested, and identifies diseased corn leaf images.
[0016] Optionally, the step of performing weighted bidirectional feature fusion on the shallow fusion feature map through the weighted fusion submodule to obtain the feature map to be tested includes:
[0017] The shallow feature fusion map is received through the weighted fusion submodule. Weights are set based on the shallow positioning information, and multi-scale feature fusion is performed in combination with the weights to obtain the test feature map after weighted scale fusion. The multi-scale feature fusion adopts a bidirectional fusion method of top-down and bottom-up.
[0018] Optionally, before the step of detecting diseased leaves in the target corn leaf image based on a preset leaf disease identification model to determine the corn leaf disease image, the following steps are included:
[0019] A set of maize leaf images is obtained, and leaf diseases in the maize leaf disease images in the set are selected and labeled. The set of maize leaf images includes maize leaf disease images and maize leaf healthy images.
[0020] The labeled corn leaf images are divided into a training set, a validation set, and a test set according to a preset ratio.
[0021] The initial disease identification model is trained and optimized using the training set, the validation set, and the test set to obtain a preset leaf disease identification model.
[0022] Optionally, the step of training and optimizing the initial disease identification model using the training set, the validation set, and the test set to obtain a preset leaf disease identification model includes:
[0023] The training set is detected by the initial disease identification model to be trained to obtain prediction boxes;
[0024] The overlap value of the prediction box and the labeled box in the maize leaf disease image is calculated;
[0025] Based on the overlap value calculation results, the initial disease identification model is optimized by combining the overlap value calculation results of the validation set and the test set, and a preset leaf disease identification model is obtained based on the preset loss function.
[0026] Optionally, the preset loss function includes an EIOU function added to the loss function of the original YOLOv5s model, and the added EIOU function includes a pre-set positive sample influence factor.
[0027] Optionally, before the step of dividing the labeled corn leaf image set into a training set, a validation set, and a test set according to a preset ratio, the following steps are included:
[0028] The labeled corn leaf image set is subjected to data augmentation processing, including image flipping, image scaling, random cropping, and random stitching, to obtain the processed labeled corn leaf image set.
[0029] Furthermore, to achieve the above objectives, the present invention also proposes a corn leaf disease detection device, the device comprising:
[0030] The image acquisition module is used to acquire images of the target corn leaves;
[0031] The disease detection module is used to detect diseased leaves in the target corn leaf image based on a preset leaf disease identification model, and to determine the corn leaf disease image. The preset leaf disease identification model includes a weighted feature fusion submodule that replaces the PAN structure in the feature fusion module of the original YOLOv5s model. The weighted fusion submodule is connected to the first fusion submodule and the output module respectively. The weighted fusion submodule is used to perform bidirectional feature fusion on the shallow fusion feature map obtained by the first fusion submodule, and input the feature information after bidirectional feature fusion to the output module for classification and recognition.
[0032] In addition, to achieve the above objectives, the present invention also proposes a corn leaf disease detection device, the device comprising: a memory, a processor, and a corn leaf disease detection program stored in the memory and executable on the processor, the corn leaf disease detection program being configured to implement the steps of the corn leaf disease detection method described above.
[0033] In addition, to achieve the above objectives, the present invention also proposes a storage medium storing a corn leaf disease detection program, wherein when the corn leaf disease detection program is executed by a processor, it implements the steps of the corn leaf disease detection method described above.
[0034] This invention first acquires an image of a target corn leaf; then, based on a preset leaf disease identification model, it detects diseased leaves in the target corn leaf image to determine the corn leaf disease image. The preset leaf disease identification model includes a weighted fusion submodule that replaces the PAN structure in the feature fusion module of the original YOLOv5s model. This weighted fusion submodule is connected to a first fusion submodule and an output module, respectively. The weighted fusion submodule performs bidirectional feature fusion on the shallow fusion feature map obtained by the first fusion submodule, and inputs the feature information after bidirectional feature fusion to the output module for classification and recognition. Because the weighted fusion submodule in the preset leaf disease model of this invention can perform bidirectional feature fusion on the shallow fusion feature map, it improves the existing disease detection model built using YOLOv5s, and can improve the detection accuracy of small target diseases while maintaining a faster detection speed. Attached Figure Description
[0035] Figure 1 This is a schematic diagram of the structure of a corn leaf disease detection device in the hardware operating environment involved in an embodiment of the present invention;
[0036] Figure 2 This is a flowchart illustrating the first embodiment of the corn leaf disease detection method of the present invention;
[0037] Figure 3 This is a schematic diagram of the feature fusion module in the preset leaf disease identification model of the present invention;
[0038] Figure 4 This is a schematic diagram of the annotation box in the corn leaf disease image in the first embodiment of the corn leaf disease detection method of the present invention;
[0039] Figure 5 This is a flowchart illustrating the second embodiment of the corn leaf disease detection method of the present invention;
[0040] Figure 6 This is a flowchart illustrating the third embodiment of the corn leaf disease detection method of the present invention;
[0041] Figure 7 This is a structural block diagram of the first embodiment of the corn leaf disease detection device of the present invention.
[0042] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0043] It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the invention.
[0044] Reference Figure 1 , Figure 1 This is a schematic diagram of the structure of a corn leaf disease detection device in the hardware operating environment of an embodiment of the present invention.
[0045] like Figure 1 As shown, the corn leaf disease detection device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to enable communication between these components. The user interface 1003 may include a display screen and an input unit such as a keyboard; optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wireless-Fidelity (Wi-Fi) interface). The memory 1005 may be high-speed random access memory (RAM) or stable non-volatile memory (NVM), such as a disk drive. The memory 1005 may also optionally be a storage device independent of the aforementioned processor 1001.
[0046] Those skilled in the art will understand that Figure 1 The structure shown does not constitute a limitation on maize leaf disease detection equipment and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0047] like Figure 1 As shown, the memory 1005, which serves as a storage medium, may include an operating system, a network communication module, a user interface module, and a corn leaf disease detection program.
[0048] exist Figure 1In the maize leaf disease detection device shown, the network interface 1004 is mainly used for data communication with the network server; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and the memory 1005 in the maize leaf disease detection device of the present invention can be set in the maize leaf disease detection device, and the maize leaf disease detection device calls the maize leaf disease detection program stored in the memory 1005 through the processor 1001 and executes the maize leaf disease detection method provided in the embodiment of the present invention.
[0049] This invention provides a method for detecting corn leaf diseases, referring to... Figure 2 , Figure 2 This is a flowchart illustrating the first embodiment of the corn leaf disease detection method of the present invention.
[0050] In this embodiment, the method for detecting corn leaf diseases includes the following steps:
[0051] Step S10: Obtain the target corn leaf image.
[0052] It should be noted that the execution subject of the method in this embodiment can be a computing service device with image acquisition, data processing, model calling, network communication, and program execution functions, such as a mobile phone, personal computer, intelligent agricultural machinery device, diseased leaf analyzer, etc. It can also be other electronic devices that can achieve the same or similar functions and perform real-time corn leaf disease detection. This embodiment does not limit this. Here, a corn leaf disease detection device (hereinafter referred to as the detection device) is selected as an example to illustrate various embodiments of the corn leaf disease detection method of the present invention.
[0053] Understandably, the target corn leaf image can be a real-time image of corn leaves that needs to be detected for disease, or a historical image obtained from the internet or a historical database that needs to be detected for leaf disease.
[0054] Step S20: Based on the preset leaf disease identification model, the target corn leaf image is subjected to disease leaf detection to determine the corn leaf disease image. The preset leaf disease identification model includes a weighted fusion submodule that replaces the PAN structure in the feature fusion module of the original YOLOv5s model. The weighted fusion submodule is connected to the first fusion submodule and the output module respectively. The weighted fusion submodule is used to perform bidirectional feature fusion on the shallow fusion feature map obtained by the first fusion submodule, and input the feature information after bidirectional feature fusion to the output module for classification and recognition.
[0055] It should be noted that this preset leaf disease identification model is built on the YOLOv5s model. The YOLO model is an object detection model. YOLOv5s is a single-stage object detection algorithm. It adds Misac data augmentation to the previous version of the YOLO model, which can use an adaptive anchor box strategy to obtain the best value for different datasets, and continuously optimize the network through a reverse update method.
[0056] Understandably, the original YOLOv5s model includes an input module (Input), a feature extraction module (Backbone), a feature fusion module (Neck), and an output module (Output). The Neck module is primarily responsible for multi-scale feature fusion of feature maps and transmitting these features to subsequent modules for prediction output. The Neck uses a feature pyramid network (FPN) and a path aggregation network (PAN). FPN transmits the generated features to shallow layers, achieving the fusion of more features, but it is time-consuming. PAN, on the other hand, transmits the localization information from shallow layers to higher layers, increasing multi-scale localization capabilities and effectively shortening the fusion path between features at different layers.
[0057] It should be understood that, considering the inconsistency of feature information at different scales in multi-scale fusion, the present invention uses a weighted fusion submodule instead of the PAN structure in Neck in the preset leaf disease identification model.
[0058] It should be noted that this weighted fusion submodule employs a weighted bidirectional feature pyramid network (BiFPN), which replaces PAN with BiFPN. The difference between BiFPN and FPN is that FPN can only propagate features from bottom to top, while BiFPN can learn the importance of different input features through learnable weights, and repeatedly apply top-down and bottom-up out-of-scale feature fusion. This bidirectional weighted feature network can better extract feature information and better fuse features to achieve higher detection accuracy.
[0059] Understandably, the feature fusion module in this preset leaf disease identification model adopts the Neck structure from the original YOLOv5s model, and the first fusion submodule adopts the FPN structure from the original YOLOv5s model. (Reference) Figure 3 , Figure 3This is a schematic diagram of the feature fusion module in the preset leaf disease identification model of the present invention. P1-P4 are multi-scale hierarchical feature images. FPN transmits deep features to shallow layers, realizing preliminary shallow feature fusion. Then, BiPAN transmits shallow positioning information to higher layers while repeatedly using top-down and bottom-up multi-scale feature fusion. This bidirectional weighted feature network can better extract feature information and obtain better fused features.
[0060] It should be noted that, in order to obtain a preset leaf disease identification model with better detection performance, the disease identification model can be initialized based on the YOLOv5s model first, and the model can be trained using a large amount of training data. Therefore, before step S20, the following steps are also included:
[0061] Step S021: Obtain a set of corn leaf images, and select and label the leaf diseases in the corn leaf disease images in the set. The corn leaf image set includes corn leaf disease images and corn leaf healthy images.
[0062] Understandably, this collection of maize leaf images can be obtained from open-source plant datasets such as PlantVilliage, or from other internet search channels and actual photographs. The collection includes images of diseased maize leaves and healthy maize leaves, with the number of diseased images potentially exceeding the number of healthy images. For example, over 4,000 maize leaf images were collected, including 3,000 images of diseased maize leaves and 1,000 images of healthy maize leaves.
[0063] It should be understood that after obtaining the set of maize leaf images, the specific locations of leaf diseases in the maize leaf disease images can be labeled. For example, LablImg software can be used to label the locations of leaf diseases, referring to... Figure 4 , Figure 4 This is a schematic diagram of the annotation boxes in the corn leaf disease images in this embodiment. Leaf diseases can be manually marked in each corn leaf disease image using the annotation box, resulting in the following: Figure 4 The image shown contains a labeled box indicating a diseased corn leaf.
[0064] Step S022: Divide the labeled corn leaf image set into a training set, a validation set, and a test set according to a preset ratio.
[0065] It should be noted that after obtaining the labeled corn leaf image set, the image set can be divided into a training set, a validation set, and a test set based on a preset ratio. The training set is used to train and debug the initial disease identification model, the validation set is used to view the training effect, and the test set is used to evaluate the generalization ability of the final model. Dividing the image set into three datasets can prevent the model from overfitting. The preset ratio can be a conventional dataset division ratio: 6:2:2, or it can be set to, for example, 4:4:2 or other ratios according to the user's personalized choice; this embodiment does not impose any restrictions on this.
[0066] Step S023: Train and optimize the initial disease identification model using the training set, the validation set, and the test set to obtain a preset leaf disease identification model.
[0067] In the specific implementation, after obtaining the training set, validation set and test set of the image set divided according to the proportion, the disease identification model constructed by the initialization is trained, validated and adjusted and tested and evaluated in sequence through the above sets to obtain the preset leaf disease identification model after preliminary optimization.
[0068] This embodiment first acquires a target corn leaf image; then, based on a preset leaf disease identification model, it detects diseased leaves in the target corn leaf image to determine the corn leaf disease image. The preset leaf disease identification model includes a weighted fusion submodule that replaces the PAN structure in the feature fusion module of the original YOLOv5s model. The weighted fusion submodule is connected to a first fusion submodule and an output module, respectively. The weighted fusion submodule is used to perform bidirectional feature fusion on the shallow fusion feature map obtained by the first fusion submodule, and the feature information after bidirectional feature fusion is input to the output module for classification and recognition. Because the weighted fusion submodule in the preset leaf disease model of this embodiment can perform bidirectional feature fusion on the shallow fusion feature map, it improves the existing disease detection model built using YOLOv5s, and can improve the detection accuracy of small target diseases while maintaining a fast detection speed.
[0069] refer to Figure 5 , Figure 5 This is a flowchart illustrating the second embodiment of the corn leaf disease detection method of the present invention.
[0070] Based on the first embodiment described above, in order to obtain feature information from the target corn image through a preset leaf disease identification model for image feature fusion, the preset leaf disease identification model further includes: an input module and a feature extraction module, wherein the feature extraction module is connected to the input module and the shallow feature fusion submodule, respectively. Step S20 includes:
[0071] Step S201: Perform data augmentation preprocessing on the target corn leaf image through the input module to obtain the processed corn leaf image to be detected.
[0072] Understandably, since the input module adopts the Input structure in the original YOLOv5s model, it can perform data augmentation on the target corn leaf image of the input model. It can use an adaptive anchor box strategy to obtain the optimal value for different target corn leaf images, thereby obtaining the processed corn leaf image to be detected.
[0073] Step S202: The feature extraction module extracts features from the corn leaf image to be detected to obtain an initial feature map.
[0074] Understandably, this feature extraction module uses the Backbone structure from the original YOLOv5s model. The Backbone is primarily responsible for feature extraction and is a convolutional neural network used to aggregate images of different fine-grained sizes and form feature maps. The first layer of the Backbone is a Focus structure, mainly used for image feature slicing. For example, an original 608*608*3 image input to the Focus structure is sliced into a 304*304*12 feature map, then convolved with 32 kernels to become a final 304*304*32 feature map. Next, a channel increase (Concat) operation is performed on the feature map, increasing the number of features (channels) describing the image itself, resulting in the convolutional output. Finally, the result is input into the Conv structure to obtain an initial feature map containing multi-channel feature information after feature extraction.
[0075] Step S203: Perform shallow feature fusion on the initial feature map through the first fusion submodule to obtain a shallow fused feature map.
[0076] Understandably, the feature extraction module in this preset leaf disease identification model is still based on the Neck structure of the feature extraction module in the original YOLOv5 model. The Neck is mainly responsible for multi-scale feature fusion of the feature maps extracted by the Backbone, thereby improving the accuracy of identification, and transmitting the fused features to subsequent modules for prediction and classification.
[0077] It should be noted that the first fusion submodule is the FPN structure of the Neck structure in the original YOLOv5s model. This module can transfer deep features to shallow layers to achieve preliminary feature fusion and obtain a shallow feature fusion map.
[0078] Step S204: Perform weighted bidirectional feature fusion on the shallow fusion feature map through the weighted fusion submodule to obtain the feature map to be tested.
[0079] Understandably, this weighted fusion submodule is a BiFPN that replaces the PAN structure in the Neck structure of the original YOLOv5s model. BiFPN can learn the importance of different input features through learnable weights, and repeatedly apply top-down and bottom-up out-scale feature fusion. This bidirectional weighted feature network can better extract feature information and better fuse features to achieve higher detection accuracy.
[0080] In the specific implementation, the shallow feature fusion map is received through the weighted fusion submodule, weights are set based on the shallow positioning information, and multi-scale feature fusion is performed in combination with the weights to obtain the test feature map after weighted scale fusion. The multi-scale feature fusion adopts a bidirectional fusion method of top-down and bottom-up.
[0081] Step S205: The output module is used to detect diseased leaves in the feature map to be tested, and the image of diseased corn leaves is determined.
[0082] It is understandable that this output module can be constructed using the Output module from the original YOLOv5s module. This Output structure mainly contains convolutional layers, normalization layers, and activation functions. Through this output module, diseased leaves can be detected and classified based on the test feature map containing fused features, thus obtaining images of corn leaf diseases.
[0083] In this embodiment, the target corn leaf image input to the model is processed by various modules in the preset leaf disease identification model to extract feature information, and diseased leaves are detected based on the feature information to obtain a corn leaf disease image. Specifically, the weighted fusion submodule receives the shallow feature fusion map, sets weights based on shallow positioning information, and performs multi-scale feature fusion based on the weights to obtain a weighted scale fusion feature map. The multi-scale feature fusion adopts a bidirectional fusion method of top-down and bottom-up. Since BiFPN is introduced in this embodiment to replace PAN in the original network structure, it can learn the importance of different input features through learnable weights and repeatedly apply top-down and bottom-up multi-scale feature fusion to improve the accuracy of feature information extraction, obtain better fused features, and thus achieve higher detection accuracy.
[0084] refer to Figure 6 , Figure 6 This is a flowchart illustrating the third embodiment of the corn leaf disease detection method of the present invention.
[0085] Based on the above embodiments, in order to further improve the detection accuracy of small target diseases while maintaining a fast detection speed, the preset leaf disease identification model obtained by training the initial disease identification model can be further optimized. Step S023 includes:
[0086] Step S0231: Detect the training set using the initial disease identification model to be trained to obtain prediction boxes.
[0087] In the specific implementation, the training set is input into the initial disease model for training, and the predicted bounding boxes in each corn leaf image in the training set are obtained by the detection of the model. The predicted bounding box is the location of the leaf disease detected by the initial model.
[0088] Step S0232: Calculate the overlap value between the prediction box and the annotation box in the corn leaf disease image.
[0089] In practice, a two-dimensional Gaussian model can be performed on the predicted bounding box and the labeled bounding box. Based on the modeling results, the Gaussian distribution distance between the predicted bounding box and the labeled bounding box can be obtained. The Gaussian distribution distance can then be normalized to obtain the calculation result.
[0090] Step S0233: Based on the overlap value calculation results, and combined with the overlap value calculation results in the validation set and the test set, optimize the initial disease identification model, and obtain a preset leaf disease identification model based on a preset loss function.
[0091] It should be noted that the preset loss function may include the newly added Efficient Intersection over Union (EIOU) function in the original YOLOv5s model loss function. The newly added EIOU function may include a pre-set positive sample influence factor.
[0092] Understandably, EIOU can be added to the loss function of YOLOv5s to calculate the overlap between predicted and ground truth bounding boxes. Traditional loss functions determine the accuracy of target localization by calculating the Intersection over Union (IOU) value between predicted and ground truth bounding boxes. However, IOU cannot accurately and effectively calculate bounding box regression loss functions, such as in cases where two boxes overlap or contain each other, leading to slow convergence and inaccurate regression results. The introduced EIOU loss function is more accurate, measuring the overlap area, center point, and differences in width and height between predicted and ground truth bounding boxes. This variant of IOU can better handle issues such as class imbalance and irregular object shapes, thereby improving the accuracy and robustness of the detection algorithm.
[0093] It should be noted that the specific formula for calculating EIOU is as follows:
[0094]
[0095] Among them, L IOU L represents the overlapping area. dis For the difference between the center points, L asp The difference between the width and height sides; b and b gt These are the center positions of the prediction box and the label box, respectively; w and w gt These represent the widths of the prediction bounding box and the label bounding box, respectively; h, and h... gt ρ is the height of the prediction box and the label box; ρ is the Euclidean distance between the two center points; c is the diagonal distance of the smallest closure region that can simultaneously contain the prediction box and the label box; and and are the width and height of the smallest bounding box that covers both boxes, respectively.
[0096] Furthermore, considering that the algorithm of the original YOLOv5s model exacerbates the imbalance between positive and negative samples when performing maize leaf disease detection, an α parameter can be introduced into the EIOU loss function to make the model training process pay more attention to positive samples. This is called Focal-EIOU, and the formula for calculating Focal-EIOU is as follows:
[0097] L Focal-EIOU =IOU α L EIOU
[0098] Understandably, the α parameter can be set based on user-specific settings or historical data. Experimental data shows that the model performs best when α = 0.5, exhibiting significant advantages in convergence speed and positioning accuracy. Therefore, the default loss function for this model can be Focal-EIOU with α set to 0.5.
[0099] Furthermore, in order to expand the sample size of the training set, validation set, and test set, the following steps are included before step S023:
[0100] Step S0023: Perform image flipping, image scaling, random cropping, and random stitching data augmentation on the labeled corn leaf image set to obtain the processed labeled corn leaf image set.
[0101] This embodiment uses an initial disease identification model to detect the training set and obtain predicted bounding boxes. The overlap value between the predicted bounding boxes and the labeled bounding boxes in the corn leaf disease image is calculated. Based on the overlap value calculation results, combined with the overlap value calculation results in the validation set and the test set, the initial disease identification model is optimized. A preset leaf disease identification model is obtained based on a preset loss function. Specifically, an EIOU loss function is introduced, which makes the model training focus more on positive samples. Optimizing the model loss function improves the accuracy and robustness of the model's detection algorithm, further enhancing the model's ability to detect small targets, resulting in higher accuracy of the final corn leaf disease image.
[0102] Furthermore, this embodiment of the invention also proposes a storage medium storing a corn leaf disease detection program, which, when executed by a processor, implements the steps of the corn leaf disease detection method described above.
[0103] refer to Figure 7 , Figure 7 This is a structural block diagram of the first embodiment of the corn leaf disease detection device of the present invention.
[0104] like Figure 7 As shown, the corn leaf disease detection device of the present invention includes:
[0105] Image acquisition module 701 is used to acquire target corn leaf images;
[0106] The disease detection module 702 is used to detect diseased leaves in the target corn leaf image based on a preset leaf disease identification model, and to determine the corn leaf disease image. The preset leaf disease identification model includes a weighted feature fusion submodule that replaces the PAN structure in the feature fusion module of the original YOLOv5s model. The weighted fusion submodule is connected to the first fusion submodule and the output module respectively. The weighted fusion submodule is used to perform bidirectional feature fusion on the shallow fusion feature map obtained by the first fusion submodule, and input the feature information after bidirectional feature fusion to the output module for classification and recognition.
[0107] The disease detection module 702 is further configured to acquire a set of corn leaf images, and to select and label leaf diseases in the corn leaf disease images in the set. The corn leaf image set includes corn leaf disease images and corn leaf healthy images. The labeled corn leaf image set is divided into a training set, a validation set, and a test set according to a preset ratio. The initial disease identification model is trained and optimized using the training set, the validation set, and the test set to obtain a preset leaf disease identification model.
[0108] This embodiment first acquires a target corn leaf image; then, based on a preset leaf disease identification model, it detects diseased leaves in the target corn leaf image to determine the corn leaf disease image. The preset leaf disease identification model includes a weighted fusion submodule that replaces the PAN structure in the feature fusion module of the original YOLOv5s model. The weighted fusion submodule is connected to a first fusion submodule and an output module, respectively. The weighted fusion submodule is used to perform bidirectional feature fusion on the shallow fusion feature map obtained by the first fusion submodule, and the feature information after bidirectional feature fusion is input to the output module for classification and recognition. Because the weighted fusion submodule in the preset leaf disease model of this embodiment can perform bidirectional feature fusion on the shallow fusion feature map, it improves the existing disease detection model built using YOLOv5s, and can improve the detection accuracy of small target diseases while maintaining a fast detection speed.
[0109] Based on the first embodiment of the corn leaf disease detection device of the present invention, a second embodiment of the corn leaf disease detection device of the present invention is proposed.
[0110] In this embodiment, the disease detection module 702 further includes an input module and a feature extraction module, wherein the feature extraction module is connected to the input module and the shallow feature fusion submodule, respectively.
[0111] The disease detection module 702 is used to perform data augmentation preprocessing on the target corn leaf image through the input module to obtain a processed corn leaf image to be detected; to extract features from the corn leaf image to be detected through the feature extraction module to obtain an initial feature map; to perform shallow feature fusion on the initial feature map through the first fusion submodule to obtain a shallow fused feature map; to perform weighted bidirectional feature fusion on the shallow fused feature map through the weighted fusion submodule to obtain a feature map to be tested; and to detect diseased leaves on the feature map to be tested through the output module to determine the corn leaf disease image.
[0112] Furthermore, the disease detection module 702 is also used to receive the shallow feature fusion map through the weighted fusion submodule, set weights based on shallow positioning information, and perform multi-scale feature fusion in combination with the weights to obtain the test feature map after weighted scale fusion, wherein the multi-scale feature fusion adopts a bidirectional fusion method of top-down and bottom-up.
[0113] Furthermore, the disease detection module 702 is also used to detect the training set using the initial disease recognition model to be trained, and obtain prediction boxes; calculate the overlap value between the prediction boxes and the labeled boxes in the corn leaf disease image; optimize the initial disease recognition model based on the overlap value calculation results and the overlap value calculation results in the validation set and the test set, and obtain a preset leaf disease recognition model based on a preset loss function; wherein the preset loss function includes an EIOU function added to the loss function of the original YOLOv5s model, and the added EIOU function contains a pre-set positive sample influence factor.
[0114] Furthermore, the disease detection module 702 is also used to perform data augmentation processing on the labeled corn leaf image set, including image flipping, image scaling, random cropping, and random splicing, to obtain the processed labeled corn leaf image set.
[0115] Other embodiments or specific implementations of the corn leaf disease detection device of the present invention can be referred to the above-described method embodiments, and will not be repeated here.
[0116] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0117] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0118] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as read-only memory / random access memory, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0119] The above are merely preferred embodiments of the present invention and do not limit the patent scope of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.
Claims
1. A method for detecting corn leaf diseases, characterized in that, The method includes: Acquire the target corn leaf image; Based on a preset leaf disease identification model, diseased leaves are detected in the target corn leaf image to identify diseased corn leaves. The preset leaf disease identification model includes a weighted fusion submodule that replaces the PAN structure in the feature fusion module of the original YOLOv5s model. The weighted fusion submodule is constructed based on the BiFPN structure. The weighted fusion submodule is connected to the first fusion submodule and the output module respectively. The weighted fusion submodule is used to perform bidirectional feature fusion on the shallow fusion feature map obtained by the first fusion submodule. The feature information after bidirectional feature fusion is input to the output module for classification and identification. The preset leaf disease identification model is also trained based on the loss function and EIOU function of the original YOLOv5s model. The preset leaf disease identification model further includes an input module and a feature extraction module, wherein the feature extraction module is connected to the input module and the shallow feature fusion submodule, respectively. The step of detecting diseased leaves in the target corn leaf image based on a preset leaf disease identification model to determine the corn leaf disease image includes: The input module performs data augmentation preprocessing on the target corn leaf image to obtain the processed corn leaf image to be detected. The feature extraction module extracts features from the corn leaf image to be detected to obtain an initial feature map. The initial feature map is fused using the first fusion submodule to obtain a shallow fused feature map. The weighted fusion submodule performs weighted bidirectional feature fusion on the shallow fused feature map to obtain a test feature map, including: receiving the shallow feature fused map through the weighted fusion submodule, setting weights based on shallow positioning information, and performing multi-scale feature fusion based on the weights to obtain a test feature map after weighted scale fusion, wherein the multi-scale feature fusion adopts a bidirectional fusion method from top to bottom and from bottom to top, and the weighted fusion submodule is configured to repeatedly apply the bidirectional fusion method; The output module is used to detect diseased leaves in the feature map to be tested, thereby determining the image of diseased corn leaves. The EIOU function mentioned here is the Focal-EIOU function, and its corresponding expression is: In the formula, For pre-set parameters, This is the original EIOU loss function.
2. The method for detecting maize leaf diseases as described in claim 1, characterized in that, Before the step of detecting diseased leaves in the target corn leaf image based on a preset leaf disease identification model to determine the corn leaf disease image, the following steps are included: A set of maize leaf images is obtained, and leaf diseases in the maize leaf disease images in the set are selected and labeled. The set of maize leaf images includes maize leaf disease images and maize leaf healthy images. The labeled corn leaf images are divided into a training set, a validation set, and a test set according to a preset ratio. The initial disease identification model is trained and optimized using the training set, the validation set, and the test set to obtain a preset leaf disease identification model.
3. The method for detecting maize leaf diseases as described in claim 2, characterized in that, The step of training and optimizing the initial disease identification model using the training set, the validation set, and the test set to obtain a preset leaf disease identification model includes: The training set is detected by the initial disease identification model to be trained to obtain prediction boxes; The overlap value of the prediction box and the labeled box in the maize leaf disease image is calculated; Based on the overlap value calculation results, the initial disease identification model is optimized by combining the overlap value calculation results of the validation set and the test set, and a preset leaf disease identification model is obtained based on the preset loss function.
4. The method for detecting maize leaf diseases as described in claim 3, characterized in that, The preset loss function includes an EIOU function added to the loss function of the original YOLOv5s model, and the newly added EIOU function includes a pre-set positive sample influence factor.
5. The method for detecting maize leaf diseases as described in claim 3, characterized in that, Before the step of dividing the labeled corn leaf image set into a training set, a validation set, and a test set according to a preset ratio, the following steps are included: The labeled corn leaf image set is subjected to data augmentation processing, including image flipping, image scaling, random cropping, and random stitching, to obtain the processed labeled corn leaf image set.
6. A corn leaf disease detection device, characterized in that, The device includes: The image acquisition module is used to acquire images of the target corn leaves; The disease detection module is used to detect diseased leaves in the target corn leaf image based on a preset leaf disease identification model, and to determine the corn leaf disease image. The preset leaf disease identification model includes a weighted feature fusion submodule that replaces the PAN structure in the feature fusion module of the original YOLOv5s model. The weighted fusion submodule is constructed based on the BiFPN structure. The weighted fusion submodule is connected to the first fusion submodule and the output module respectively. The weighted fusion submodule is used to perform bidirectional feature fusion on the shallow fusion feature map obtained by the first fusion submodule, and input the feature information after bidirectional feature fusion to the output module for classification and recognition. The preset leaf disease identification model is also trained based on the loss function and EIOU function of the original YOLOv5s model. The preset leaf disease identification model further includes an input module and a feature extraction module, wherein the feature extraction module is connected to the input module and the shallow feature fusion submodule, respectively. The disease detection module is further configured to: perform data augmentation preprocessing on the target corn leaf image through the input module to obtain a processed corn leaf image to be detected; extract features from the corn leaf image to be detected through the feature extraction module to obtain an initial feature map; perform shallow feature fusion on the initial feature map through the first fusion submodule to obtain a shallow fused feature map; perform weighted bidirectional feature fusion on the shallow fused feature map through the weighted fusion submodule to obtain a feature map to be tested; and perform diseased leaf detection on the feature map to be tested through the output module to determine the corn leaf disease image. The disease detection module is also used to receive the shallow feature fusion map through the weighted fusion submodule, set weights based on shallow positioning information, and perform multi-scale feature fusion in combination with the weights to obtain the test feature map after weighted scale fusion. The multi-scale feature fusion adopts a bidirectional fusion method from top to bottom and from bottom to top, and the weighted fusion submodule is configured to repeatedly apply the bidirectional fusion method. The EIOU function mentioned here is the Focal-EIOU function, and its corresponding expression is: In the formula, For pre-set parameters, This is the original EIOU loss function.
7. A corn leaf disease detection device, characterized in that, The device includes: a memory, a processor, and a corn leaf disease detection program stored in the memory and executable on the processor, the corn leaf disease detection program being configured to implement the steps of the corn leaf disease detection method as described in any one of claims 1 to 5.
8. A storage medium, characterized in that, The storage medium stores a corn leaf disease detection program, which, when executed by a processor, implements the steps of the corn leaf disease detection method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Target detection method and system based on bidirectional adaptive feature pyramid
CN113011442A
Real-time multifunctional pest and disease damage intelligent identification and early warning system
CN115187868A
Improved corn leaf disease and insect pest automatic detection method based on YOLO model
CN116310836A
Method, apparatus, and device for fusing features applied to small target detection, and storage medium
US20210224581A1