Prune leaf disease detection method based on improved YOLOv7 algorithm

By improving the YOLOv7 algorithm, the SCDown module and the Polarized self-attention mechanism were introduced, and the loss function was optimized, which solved the problems of inefficient and insufficient accuracy of plum leaf disease detection, and achieved more efficient disease recognition.

CN120298871AInactive Publication Date: 2025-07-11JIANGSU UNIV OF SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510030608.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-08
Publication Date
2025-07-11
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing plum leaf disease detection methods are inefficient and susceptible to human factors, and the detection accuracy and speed of the YOLOv7 algorithm under complex backgrounds and occlusions need to be improved.

Method used

Improve the YOLOv7 algorithm, replace the MPConv module by introducing the SCDown module to improve feature extraction capabilities, and add a Polarized self-attention mechanism to optimize the loss function, enhance the extraction of deep important features, and expand the data set with data enhancement technology.

Benefits of technology

The accuracy and speed of detection of plum leaf disease is improved, the number of parameters and calculations of the model is reduced, the missed and mis-detection problems of diseased leaf targets is improved, and the classification and positioning accuracy is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120298871A_ABST
    Figure CN120298871A_ABST
Patent Text Reader

Abstract

The invention discloses a prune leaf disease detection method based on a YOLOv7 algorithm, which belongs to the field of computer vision target detection, is characterized by high precision and high accuracy rate, and mainly comprises the following steps: step 1, acquiring a prune diseased leaf image data set, and preprocessing the prune diseased leaf image data set; 2, improving a trunk feature extraction network and a neck network based on YOLOv7, and designing and adopting an SCDown-MPConv module to replace an MPConv module in the network; a third step of dynamically adjusting weight distribution in a backbone network of the YOLOv7 by introducing a Polarized self-attention mechanism; step 4, introducing a new loss function CDIoU; step 5, model training; and step 6, detecting the prune leaves with diseases by using the trained model so as to determine disease types and position information of the prune leaves. Experiments show that compared with an original YOLOv7 model for prune leaf disease detection, the method is high in average precision and can be effectively applied to prune leaf disease detection scenes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of computer vision object detection, and mainly relates to a detection method for plum leaf diseases based on an improved YOLOv7 algorithm, which can be applied to the detection of plum leaf diseases. Background Art

[0002] In terms of the detection of plum leaf diseases, there is relatively little research in China. Traditional disease detection methods mainly rely on manual visual inspection. This method is not only inefficient but also easily affected by human factors, making it difficult to achieve accurate and rapid disease identification. With the rapid development of computer vision and deep learning technologies, using image processing and machine learning algorithms for plant disease detection has become a research hotspot. In particular, object detection algorithms such as the YOLO (You Only Look Once) series of algorithms have been widely used in various scenarios due to their fast and accurate characteristics. However, the automatic recognition technology for plum leaf diseases is still immature and needs further research and improvement.

[0003] As the latest member of the YOLO series, YOLOv7 has made significant improvements in many aspects. First, in terms of the network structure, YOLOv7 introduces a deeper network, enhancing the feature extraction ability. Second, by improving the generation method of anchor boxes, the model becomes more accurate in detecting objects of different sizes. The advent of these algorithms has effectively improved the accuracy, precision, and speed of plant disease detection. Nowadays, the disease detection algorithms for relevant crop leaves generally have low accuracy, and there are problems such as complex models and insufficient robustness. The plum diseased leaf detection and recognition algorithm requires higher accuracy and efficiency, and still needs to be further improved for the detection of diseased leaves in complex backgrounds and occlusion situations. Summary of the Invention

[0004] The purpose of the present invention is to provide a detection method for plum leaf diseases based on an improved YOLOv7 algorithm to overcome the above-mentioned drawbacks and deficiencies, thereby effectively improving the accuracy and speed of plum leaf disease detection.

[0005] The purpose of the present invention is achieved through the following technical solutions:

[0006] A detection method for plum leaf diseases based on the YOLOv7 algorithm, characterized by mainly including the following steps:

[0007] Step 1: Download the public dataset of plum leaf diseases from the Plant Disease Expert dataset, and preprocess and label this dataset;

[0008] Step 2: Based on the YOLOv7 object detection model, but to improve its performance in the detection task of plum disease leaves, we improved the backbone feature extraction network and the neck network of the model. The main function of MPConv in the original model is downsampling, and the feature size can be reduced by quantitative feature loss. Specifically, we designed the SCDown-MPConv structure of the SCDown module to replace the MPConv module in the backbone network and the neck fusion network of the YOLOv7 model. The hourglass module has good local feature extraction ability, can effectively reduce the computational complexity and improve the detection speed;

[0009] Step 3: Based on the YOLOv7 object detection model, the Polarized self-attention mechanism is introduced on the basis of the backbone feature network, which enhances the network's effective extraction ability of deep important features and can better learn the features of plum disease leaves;

[0010] Step 4: Optimize the loss function according to the dataset to achieve higher accuracy;

[0011] Step 5: Model training;

[0012] Step 6: Use the trained model to detect plum leaves with diseases and output the disease types and location information;

[0013] In the above-mentioned Step 1, the specific steps are as follows: First, download the public dataset of plum leaf diseases from the Plant Disease Expert dataset. However, since the number of plum leaf diseases in this dataset is insufficient, the dataset is expanded through data augmentation. Geometric transformation, contrast adjustment, Gaussian noise addition and other methods are used for data augmentation operations, and the final dataset is sorted and labeled. Finally, the dataset is divided into a training set, a test set and a validation set in a ratio of 4:3:3; In the above-mentioned Step 2, the specific steps are as follows: In order to fully extract and utilize the features of the incoming image, use the SCDown-MPConv structure of the SCDown module to replace the MPConv module in the backbone network and the neck fusion network of the YOLOv7 model, further improve the model's feature extraction ability, reduce the loss of small target features and enhance the missed detection ability, thereby increasing the overall performance of the model;

[0014] In the above-mentioned Step 3, the specific steps are as follows: Add the Polarized self-attention mechanism to the backbone of YOLOv7 to enhance the network's effective extraction ability of deep important features. Effectively increase the model's extraction ability for small targets of plum disease leaves and make the model more targeted when identifying plum disease leaves.

[0015] In step 4 described above, the specific steps are as follows: The prediction classification loss, localization loss, and confidence loss constitute the total loss of the YOLOv7 model. The specific improvement measure is to introduce a new loss function CDIoU, enabling the model to better optimize the prediction results of the target bounding boxes during training and improving the classification and localization accuracy of the targets.

[0016] In step 5 described above, the specific steps are as follows:

[0017] 5.1 YOLOv7 Model Selection

[0018] 5.2 YOLOv7 Model Parameter Initialization

[0019] In step 5.1 described above, the specific steps are as follows: By modifying the configuration file, the specific set parameters of YOLOv7 are selected. The network depth value is set to 1.0, and the network width value is set to 1.0.

[0020] 1. In step 5.2 described above, the specific steps are as follows: The initial learning rate of the network is set to 0.0012; The Epoch is set to 300; The weight decay coefficient is 0.0001; The Mosaic augmentation index is set to (0.5, 1.5), and the Mosaic data augmentation is turned off after the last 50 rounds of training.

[0021] In step 6 described above, the specific steps are as follows: After the training of the model is completed, the trained model is used to detect the Prunus domestica leaves with diseases to determine the types of Prunus domestica leaf diseases and the relevant location information.

[0022] Compared with the existing object detection technologies, the improvement effects of the present invention are as follows:

[0023] While improving the detection accuracy of the YOLOv7 model, the present invention also reduces the number of model parameters and the amount of computation: The present invention improves the backbone network and the neck feature fusion network part of the original model, and uses the SCDown-MPConv structure of the SCDown module to replace the MPConv module in the backbone network and the neck fusion network of the YOLOv7 model, further improving the feature extraction ability of the model, reducing the loss of small target features and enhancing the ability to avoid missed detections, thereby increasing the overall performance of the model.

[0024] The present invention also improves the problems of missed detections and false detections of diseased leaf targets: The Polarized self-attention mechanism is added to the backbone of YOLOv7 to enhance the effective extraction ability of the network for deep important features. It effectively improves the feature extraction ability of the model for small targets of Prunus domestica diseased leaves and makes the model more targeted when identifying Prunus domestica diseased leaves.

[0025] The present invention also improves the classification and positioning accuracy of the target to a certain extent: by introducing a new loss function CDIoU, the present invention can effectively improve the classification and positioning accuracy of diseased leaf targets.

[0026] In the same dataset of Prunus domestica leaf diseases, a series of comparative experiments are carried out between the present invention and other object detection algorithms. By comparison, the present invention has a higher detection effect. Brief Description of the Drawings

[0027] Figure 1 is a schematic flow chart of the present invention;

[0028] Figure 2 is a schematic structural diagram of the YOLOv7 structure of the present invention;

[0029] Figure 3 are schematic diagrams of the principles of the SCDown module and the improved SCDown-MPConv;

[0030] Figure 4 is a schematic structural diagram of the principle of the Polarized self-attention mechanism. Detailed Embodiment

[0031] To deepen the understanding of the present invention, the present invention will be further described in detail in combination with the drawings and embodiments. The embodiments are only used to explain the present invention and do not limit the protection scope of the present invention.

[0032] Embodiment: A method for detecting Prunus domestica leaf diseases based on the YOLOv7 algorithm, as Figure 1 shown, the steps are as follows:

[0033] Step 1: Currently, the Plant Disease Expert dataset is mainly used in the research on the detection of Prunus domestica leaf diseases. In this paper, several main diseases such as powdery mildew, anthracnose, leaf spot (including black spot, brown spot, etc.), and plum pox virus disease of Prunus domestica leaves are selected as the main research objects. After several rounds of screening, redundant images are excluded, and finally 3000 relevant diseased leaf images are obtained. The Labelimg tool is used to annotate all the collected Prunus domestica leaf disease pictures respectively to generate corresponding XML format files, which contain the position and category information of the diseased leaves in the images, and the dataset is divided into three sets. The dataset is divided according to the ratio of training set: test set: validation set = 4:3:3. However, the number of the dataset is significantly insufficient. The present invention performs data augmentation operations on the dataset by means of geometric transformation, contrast adjustment, Gaussian noise addition, etc., and continuously expands the number of pictures of each disease to 5 times, and the total number is expanded to 15000. Finally, the dataset is divided into a training set, a test set, and a validation set according to the ratio of 4:3:3.

[0034] Step 2: For the YOLOv7 object detection model, the main function of MPConv in YOLOv7 is downsampling. In deep learning, downsampling is one of the important operations in convolutional neural networks, which is used to reduce the spatial size of data, lower the computational complexity, and improve the robustness of the model. The two down branches of the MPConv module in the YOLOv7 network model generally use 3×3 convolutional kernels for convolution operations. Through downsampling, the size of the feature map can be gradually reduced without losing too much important information, making subsequent calculations more efficient.

[0035] The main body of the YOLOv7 model consists of four parts, including the input layer (Input Layer), the backbone feature extraction network (Backbone), the neck network (Neck), and the prediction layer (Head), as Figure 2 shown, Figure 2 which includes the basic composition structure of each part. The present invention proposes a lightweight hourglass module (Light-Hourglass Module) to replace the MPConv module in the backbone network and the neck fusion network of the YOLOv7 model, further improving the feature extraction ability of the model, reducing the loss of small target features, and enhancing the ability to detect missed detections, thereby increasing the overall performance of the model.

[0036] The structure of MPConv may have problems of spatial information loss and insufficient feature channel information fusion. During the max pooling process of MPConv, the feature map is downsampled, inevitably losing some spatial detail information. In related image object detection tasks, due to the loss of spatial information or the max pooling operation destroying the spatial structure of the original feature map to a certain extent, the detection accuracy will decrease, and the features of small targets may become difficult to distinguish and locate after multiple downsamplings. To address the shortcomings of the MPConv structure, we made the following improvements to MPConv: introducing the SCDown-MPConv convolutional module of the SCDown module to replace the MPConv module, reducing the computational complexity and the number of parameters. And introducing residual connections to improve the training stability of the network. The SCDown module is as Figure 3 shown, and the improved SCDown-MPConv is as Figure 3 .

[0037] The structural feature of the SCDown module is to perform downsampling in the spatial dimension through a 3x3 convolutional layer with a default stride of 2. And while maintaining the spatial information of the feature map after downsampling, the number of channels of the input feature map is reduced through 1x1 convolution. These two steps of spatial dimension reduction and channel dimension reduction are carried out separately, avoiding the loss of information in the traditional downsampling process.

[0038] Step 3: Application of the YOLOv7 object detection model in the detection of relevant Prunus domestica leaf diseases. In the backbone network of YOLOv7, the Polarized self-attention mechanism is added to enhance the network's ability to effectively extract important deep features. This can effectively increase the model's ability to extract small targets of diseased Prunus domestica leaves and make the model more targeted when identifying diseased Prunus domestica leaves.

[0039] The Polarized self-attention mechanism is a more refined dual attention mechanism. It retains the highest attention resolution in both the channel (C / 2) and spatial ([W, H]) dimensions, reducing information loss caused by dimensionality reduction while ensuring a low number of parameters. The Polarized self-attention mechanism more specifically allocates attention weights by introducing the concept of polarization (Polarization). By using a non-linear function for the fine-grained regression output distribution, the fitted output is more realistic and delicate.

[0040] The Polarized self-attention mechanism has two branches. One branch is called the self-attention mechanism in the channel dimension, and the other branch is called the self-attention mechanism in the spatial dimension. The results of these two branches are fused by connecting them, and finally, the output content of the polarized self-attention structure is obtained. Its diagram is as Figure 4 shown.

[0041] Step 5: Model training:

[0042] The initialization of model parameters specifically includes the following parts: The initialization of YOLOv7 model parameters specifically includes the following parts: The initial learning rate of the network is set to 0.0012; Epoch is set to 300; The weight decay coefficient is 0.0001; The Mosaic enhancement index is set to (0.5, 1.5), and Mosaic data augmentation is turned off after the last 50 rounds of training; Batch-size is set to 8.

[0043] This model uses the mean average precision (mAP), a commonly used performance evaluation metric in object detection algorithms, to evaluate its performance.

[0044] The experimental environment of the present invention is as follows: System: Ubuntu 24.04.1 LTS; Processor: Intel(R) Core(TM) i7-8550U CPU@1.80GHz 2.00GHz; Graphics card: NVIDIA Tesla A100 40G; Memory: 16GB; Compilation language: Python version 3.8.1; Deep learning framework: Pytorch version 1.7.0; Cudnn version: 8.0.6; Cuda version: 12.1;

[0045] Step 6: After completing the training of the model, use the trained model to detect the diseased plum leaves to determine the disease type and location information.

[0046] Using the improved YOLOv7 model designed by the present invention, the user only needs to provide an image of a plum leaf, and the system can detect the disease information on the leaf according to the trained model in a very short time.

[0047] This application is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present application. It should be understood that each process and / or block in the flowcharts and / or block diagrams can be implemented by computer program instructions, and the combination of the processes and / or blocks in the flowcharts and / or block diagrams can also be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for implementing the specified functions in one process Figure 1 one process or multiple processes and / or blocks Figure 1 or multiple blocks.

[0048] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing relevant hardware through a program, and this program can be stored in a computer-readable storage medium. The storage medium includes read-only memory (ROM), random access memory (RAM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), one-time programmable read-only memory (OTPROM), electrically-erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc memories, magnetic disk memories, tape memories, or any other medium that can be used to carry or store data and is computer-readable.

[0049] It should also be noted that the term "including", "comprising" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, commodity or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, commodity or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, commodity or device comprising the element.

Claims

1. A detection method for Prunus salicina Lindl. leaf diseases based on the YOLOv7 algorithm, characterized in that It mainly includes the following steps: Step 1: Download the public dataset of Prunus salicina leaf diseases from the Plant Disease Expert dataset and preprocess the dataset; Step 2: Based on the YOLOv7 object detection model, but in order to improve its performance in the detection task of Prunus salicina diseased leaves, the backbone feature extraction network and the neck network of the model are improved. The main function of MPConv in the original model is downsampling, and the feature size can be reduced through quantitative feature loss. Specifically, the SCDown-MPConv module is designed to replace the MPConv module in the original model. The SCDown-MPConv module has better local feature extraction ability, can effectively reduce the computational complexity, and improve the detection speed; Step 3: Based on the YOLOv7 object detection model, the Polarized self-attention mechanism is added to the backbone feature network, which enhances the network's ability to effectively extract important deep features and can better learn the features of Prunus salicina diseased leaves; Step 4: Optimize the loss function according to the dataset to achieve higher accuracy; Step 5: Model training; Step 6: Use the trained model to detect Prunus salicina leaves with diseases and output the disease types and location information.

2. The method for detecting diseases of plum leaves based on the YOLOv7 algorithm according to claim 1, wherein In Step 1, the public dataset of Prunus salicina leaf diseases is downloaded from the Plant Disease Expert dataset. However, since the number of Prunus salicina leaf diseases in this dataset is insufficient, the dataset is augmented through data augmentation. Geometric transformation, contrast adjustment, Gaussian noise addition and other methods are used for data augmentation operations, and the final dataset is sorted and annotated. Finally, the dataset is divided into a training set, a test set and a validation set in a ratio of 4:3:

3.

3. The method for detecting diseases of plum leaves based on the YOLOv7 algorithm according to claim 1, characterized in that, In Step 2, the main body of the YOLOv7 model consists of four parts, including the input layer (Input Layer), the backbone feature extraction network (Backbone), the neck network (Neck), and the prediction layer (Head). The present invention proposes to use the SCDown-MPConv structure with the SCDown module to replace the MPConv module in the backbone network and the neck fusion network of the YOLOv7 model, further improving the model's feature extraction ability, reducing the loss of small target features and enhancing the missed detection ability, thus increasing the overall performance of the model.

4. The method for detecting diseases of plum leaves based on the YOLOv7 algorithm according to claim 1, wherein In the said Step 3, the Polarized self-attention mechanism is added to the backbone of YOLOv7 to enhance the network's ability to effectively extract important deep features, effectively improving the model's feature extraction ability for small targets of Prunus salicina diseased leaves, and making the model more targeted when identifying Prunus salicina diseased leaves.

5. The method for detecting diseases of plum leaves based on the YOLOv7 algorithm according to claim 1, characterized in that, In Step 4, the prediction classification loss, the localization loss, and the confidence loss constitute the total loss of the YOLOv7 model. The specific improvement measure is to introduce a new loss function CDIoU, so that the model can better optimize the prediction results of the target box during the training process and improve the classification and localization accuracy of the target.

6. The method for detecting diseases of plum leaves based on the YOLOv7 algorithm according to claim 1, characterized in that, In Step 5, the specific training process includes the following steps: Step 1: Selection of the YOLOv7 model; Step 2: Initialize the parameters of the YOLOv7 model.

7. The method for detecting diseases of plum leaves based on the YOLOv7 algorithm according to claim 6, characterized in that, In Step 1, the specific method of selecting the YOLOv7 model is to modify the configuration file and set the network depth value to 1.0 and the network width value to 1.

0.

8. The method for detecting diseases of plum leaves based on the YOLOv7 algorithm according to claim 6, characterized in that, In Step 2, the initialization of the YOLOv7 model parameters specifically includes the following parts: the initial learning rate of the network is set to 0.0012; the Epoch is set to 300; the weight decay coefficient is 0.0001; the Mosaic augmentation index is set to (0.5, 1.5), and the Mosaic data augmentation is turned off after the last 50 rounds of training. The method for detecting diseases of Prunus salicina Lindl. leaves based on the YOLOv7 algorithm according to claim 1, wherein, In Step 6, after the training of the model is completed, the trained model is used to detect the diseased plum leaves to determine the types of plum leaf diseases and the relevant location information.