Apple leaf disease detection method based on improved YOLOv8

By improving the YOLOv8 network structure, SPD-Conv, Slim-neck and self-attention modules were introduced, the problem of low detection accuracy in apple leaf disease detection was solved, higher detection accuracy and efficiency were achieved, and computing resource requirements were reduced.

CN119888479APending Publication Date: 2025-04-25NANJING FORESTRY UNIV
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411837018.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-13
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

The prior art has low detection accuracy in apple leaf disease detection, making it difficult to accurately identify and locate small target diseases.

Method used

Improve the YOLOv8 network structure, and optimize the model's feature extraction capability for small-objective and low-resolution images by introducing SPD-Conv spatial depth conversion convolution coding technology, Slim-neck architecture and self-attention module.

Benefits of technology

It improves the accuracy and efficiency of apple leaf disease detection, reduces the number of parameters and calculation complexity of the model, making it suitable for edge device environments with limited computing resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure BDA0005186980950000021
    Figure BDA0005186980950000021
  • Figure BDA0005186980950000022
    Figure BDA0005186980950000022
  • Figure BDA0005186980950000043
    Figure BDA0005186980950000043
Patent Text Reader

Abstract

The invention discloses an apple leaf disease detection method based on improved YOLOv8, and the method comprises the following steps: (1), obtaining an apple leaf disease and pest image, and carrying out the preprocessing according to the pathological features; (2) expanding a data set by adopting an image processing method, and dividing the data set into a training set and a test set; (3) constructing an improved YOLOv8 network model, and training the data set by using the improved model to obtain a final apple leaf disease detection model; (4) detecting the image by using the final apple leaf disease detection model to obtain a detection result; according to the invention, the detection precision is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of agricultural plant disease detection, and in particular to an apple leaf disease detection method based on improved YOLOv8. Background Art

[0002] Apple is one of the most commonly consumed fruits in people's daily lives because it is rich in minerals and vitamins. Apple leaves are the main organs for photosynthesis in apple trees, and they undertake the important function of synthesizing nutrients and transporting them to fruits. Therefore, the health of apple leaves is directly related to the normal growth of apple trees and the yield and quality of fruits. However, there are many kinds of apple leaf diseases, which are an important restrictive factor affecting the growth of apple trees. Among them, common diseases include leaf spot disease, brown spot disease, gray spot disease, mosaic disease and rust disease. "Protect the leaves first to protect the fruit", quickly discover and accurately identify apple leaf diseases, and take effective control measures for different diseases, which can significantly reduce production losses and improve apple yield and quality. Therefore, accurate detection and identification of apple leaf diseases is of great significance to ensure the healthy growth of apple trees.

[0003] The target detection method based on deep learning is a current research hotspot in the field of plant disease recognition. The target detection aims to locate the target of interest from the image and mark the target's category, location and size. However, the existing mainstream target detection methods still have shortcomings in the "small target" detection task of apple leaf disease, which is specifically manifested in low detection accuracy. Summary of the invention

[0004] Purpose of the invention: The purpose of the present invention is to provide an apple leaf disease detection method based on improved YOLOv8, improve the network structure of YOLOv8, and solve the problem of low detection accuracy.

[0005] Technical solution: The apple leaf disease detection method based on improved YOLOv8 described in the present invention comprises the following steps:

[0006] (1) Obtain images of apple leaf diseases and insect pests and perform preprocessing based on pathological characteristics;

[0007] (2) Use image processing methods to expand the data set and divide it into training and test sets;

[0008] (3) Build an improved YOLOv8 network model and use the improved model to train the data set to obtain the final apple leaf disease detection model;

[0009] (4) Use the final apple leaf disease detection model to detect the image and obtain the detection results.

[0010] Furthermore, step (1) is specifically as follows: classify and label the images according to the pathological characteristics, namely leaf spot disease, brown spot disease, mosaic disease, gray spot disease, rust disease and mosaic disease.

[0011] Furthermore, step (2) is specifically as follows: the image is processed by affine transformation, filtering, translation, and rotation methods to expand the data set.

[0012] Furthermore, step (3) is as follows: use SPD-Conv spatial depth conversion convolutional coding technology to replace the original Conv of YOLOv8 to convert the image spatial information into depth information; introduce the Slim-neck architecture to build a neural network neck; introduce the YOLOv8 detection head into the self-attention module and the convolution module.

[0013] Furthermore, the convolution implementation process of SPD-Conv spatial depth conversion convolutional coding technology is: replacing the strided convolution and pooling layers in the network with PD-Conv.

[0014] Furthermore, the Slim-neck architecture constructs the neural network neck implementation process as follows: Slim-Neck design is introduced into the Neck part of YOLOv8, and the convolution GSConv and VoV-GSCSP replace the original Conv and C2f modules of the Neck part respectively.

[0015] Furthermore, the self-attention module is used to capture contextual information, including: multi-head self-attention layer MHSA, 1x1 convolution layer, batch normalization layer BN, residual connection and ReLu activation function; the convolution module obtains local information through downsampling and upsampling operations, and reduces the computational complexity through downsampling and feature conversion.

[0016] Furthermore, in step (3), the network is optimized by a multi-objective search method based on a genetic algorithm, and the formula is as follows:

[0017]

[0018] Among them, L train is the training loss and N(A,W) is the hypernetwork.

[0019] Search Target:

[0020]

[0021] Among them, α is the candidate network architecture, A is the architecture search space, which contains all possible network architecture combinations, and f k (α) is the kth optimization objective.

[0022] An electronic device described in the present invention includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is loaded into the processor, any one of the methods for detecting apple leaf diseases based on improved YOLOv8 is implemented.

[0023] A storage medium described in the present invention stores a computer program, and when the computer program is executed by a processor, it implements any one of the methods for detecting apple leaf diseases based on improved YOLOv8.

[0024] Beneficial effects: Compared with the prior art, the present invention has the following significant advantages: by introducing the SPD-Conv spatial depth conversion convolution coding technology, the model's feature extraction capability for small targets and low-resolution images is effectively optimized, thereby improving the accuracy of apple leaf disease detection; the Slim-neck architecture is used to design and optimize the Neck part of the YOLOv8 network, and a lightweight convolution module (GSConv) and an efficient fusion module (VoV-GSCSP) are introduced, which significantly reduces the number of parameters and computational complexity of the model while maintaining high detection accuracy, making it suitable for edge device environments with limited computing resources; the self-attention module is used to optimize the detection head, thereby enhancing the model's adaptability to complex backgrounds and diverse scenes. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0026] Figure 2 This is the improved YOLOv8 network model diagram of the present invention;

[0027] Figure 3 This is a diagram showing the results of the apple leaf spot and leaf fall disease detection of the present invention;

[0028] Figure 4 This is a diagram showing the results of the apple leaf brown spot disease detection of the present invention;

[0029] Figure 5 This is a diagram showing the results of the apple leaf mosaic disease detection of the present invention;

[0030] Figure 6 This is a diagram showing the results of apple leaf gray spot disease detection according to the present invention;

[0031] Figure 7 This is a diagram of the apple leaf rust disease detection results of the present invention. DETAILED DESCRIPTION

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

[0033] like Figure 1 As shown, the embodiment of the present invention provides an apple leaf disease detection method based on improved YOLOv8, comprising the following steps:

[0034] S1. Obtain images of apple leaf diseases and insect pests, label them according to their pathological characteristics, and establish an initial apple leaf disease dataset;

[0035] Common diseases of apple leaves include leaf spot, brown spot, mosaic, gray spot and rust. The Labelme open source tool is used to manually annotate the leaf disease images in the dataset and generate the corresponding txt label files.

[0036] S2. Use image processing methods to expand the data set to obtain the final data set; the initial data set uses image processing methods, including affine transformation, filtering, translation, and rotation methods, to expand the data set to increase the richness of the data set, prevent model overfitting, and improve the generalization ability of the model. The data set is divided into a training set and a test set in a ratio of 8:2 to obtain the final data set.

[0037] S3, introduce the YOLOv8 network structure and improve it. Figure 2 As shown in the figure, the SPD-Conv spatial depth conversion convolution coding technology is introduced to effectively optimize the model's feature extraction capabilities for small targets and low-resolution images, and improve the accuracy of apple leaf disease detection. The Slim-neck architecture is used to design and optimize the Neck part of the YOLOv8 network, and a lightweight convolution module (GSConv) and an efficient fusion module (VoV-GSCSP) are introduced to reduce the number of model parameters and computational complexity while maintaining high detection accuracy, making it suitable for edge device environments with limited computing resources. The self-attention module is used to optimize the detection head, which enhances the model's adaptability to complex backgrounds and diverse scenes; the following steps are included:

[0038] S31, introduce SPD-Conv space depth conversion convolution coding technology, optimize the model's feature extraction ability for small targets and low-resolution images. SPD-Conv module implementation process: Space-to-Depth (SPD) conversion, input feature map X (size is S×S×C1) is divided into multiple sub-feature maps f x,y Each sub-feature map is generated by extracting elements of the input feature map at a certain interval scale, and the formula is as follows:

[0039] f x,y =X[x:S:scale,y:S:scale]

[0040] Where x,y∈{0,1,…,scale-1}. When scale=2, 4 sub-feature graphs f will be generated 0,0 ,f 1,0 ,f 0,1 ,f 1,1 .

[0041] Then all sub-feature maps are concatenated along the channel dimension to obtain a new feature map X′, whose spatial dimension is reduced to 1 / scale of the original one and the number of channels is increased to the original scale. 2 Times:

[0042] X′(S / scale,S / scale,C1·scale 2 )

[0043] The feature map X′ after non-strided convolution is processed in a normal convolution layer (stride = 1). This convolution layer changes the number of channels from C1·scale 2 Reduced to C2, while the spatial resolution remains the same:

[0044] X′(S / scale,S / scale,C1·scale 2 )→X″(s / scale,S / scale,C2)

[0045] S32, the Slim-neck architecture is used to design and optimize the Neck part of the YOLOv8 network, and a lightweight convolution module (GSConv) and an efficient fusion module (VoV-GSCSP) are introduced. The implementation process of the Slim-neck architecture is as follows: First, the standard convolution is replaced by the lightweight convolution GSConv. Due to the partial loss of semantic information caused by the gradual transmission of spatial information to the channel, GSConv retains the implicit link between each channel to the maximum extent by mixing standard convolution (Conv) and depthwise separable convolution (DWConv). On the basis of GSConv, the GS bottleneck is further introduced. At the same time, the module element is the basic part of the Slim-neck architecture. VoV-GSCSP uses a cross-stage partial network module designed by a one-time aggregation method to effectively fuse information between feature maps at different stages.

[0046] S33. Use the Self-Attention Module to optimize the detection head and enhance the model's adaptability to complex backgrounds and diverse scenes. Self-Attention Module optimization detection head implementation process: For the optimization module design, a streamlined multi-head self-attention operation is used to capture only global context information, without using a feedforward network (FFN) to reduce redundant calculations. Use 1×1 convolution for dimensionality reduction and dimensionality increase operations, limit the number of channels to the bottleneck of input and output, and reduce memory consumption. Add bypass 1×1 convolution to retain uncompressed residual features. Input features Through dimensionality reduction convolution Get Q, K, V:

[0047] Q=XW reduce ,K=XW reduce ,V=XW reduce

[0048] Calculate the self-attention weight:

[0049]

[0050] After weighting, map back to the original dimension:

[0051] Y=AVW expand

[0052] The final output contains residual connections:

[0053] O=Y+X

[0054] For the optimization and fusion design of the detection head, the architecture search allows the module to flexibly embed multiple resolution branches. The detection head performs channel adjustment through 1×1 Slimmable Convolution to ensure that all branch feature sizes are consistent, and then aligns through bilinear interpolation. Finally, all features are fused through 3×3 convolution to generate the final high-resolution representation. Input branch features Adjust the number of channels:

[0055] F i ′=F i *W 1×1

[0056] If F i If the resolution is inconsistent with the maximum resolution, upsampling is performed:

[0057] F i = Upsample(F i ′)

[0058] Multi-resolution features i Fusion:

[0059] F final =Concat(F1″,F2″,...,F N ″)*W 3×3

[0060] Finally, we designed architecture search and optimization, and optimized performance and speed through a multi-objective search method based on genetic algorithms.

[0061]

[0062] Among them, L train is the training loss and N(A,W) is the hypernetwork.

[0063] Search Target:

[0064]

[0065] Combine lightweight convolution modules and self-attention modules to optimize the network architecture.

[0066] S4. Use the improved YOLOv8 network model to train the data set to obtain the final apple leaf disease detection model;

[0067] The training data set and the test data set are passed into the improved YOLOv8 network model, and the following parameters are set: the input image size is set to 640*640, the batch_size is set to 32, the number of training epochs is set to 250, and then the model is trained. The present invention verifies the performance of the improved YOLOv8 model and the original YOLOv8 network model. The experimental environment is: CPU: 12th Gen Intel(R)Core(TM)i5-12100F, memory 32GB, graphics card NVIDIA GeForce RTX2080Ti, Cuda version 11.8, and framework Pytorch. The experimental results are as follows.

[0068] The mAP value of the improved YOLOv8 model is 96.5%, and the mAP value of the original YOLOv8 is 95.5%, which is an increase of 1.0 percentage points; the accuracy of the improved YOLOv8 model is 93.0%, and the accuracy of the original YOLOv8 model is 91.1%, which is an increase of 1.9 percentage points; the recall rate of the improved YOLOv8 model is 92.3%, and the recall rate of the original YOLOv8 model is 92.1%, which is an increase of 0.2 percentage points. The model size of the improved YOLOv8 model is 5.2MB, and the model size of the original YOLOv8 is 6.3MB, which is reduced by 1.1MB, and the computational complexity is reduced from 8.9GFLOPs / G to 5.7GFLOPs / G. In summary, the improved YOLOv8 model is superior to the original YOLOv8 model in multiple performance evaluation indicators.

[0069] The present invention puts the preprocessed image into the apple leaf disease detection model and outputs the detection result. The detection result is shown in the figure Figure 3-7 As shown, the detection results of spot disease, brown spot disease, mosaic disease, grey spot and rust are shown respectively. It can be seen that the apple leaf disease detection model of the present invention can accurately identify apple leaf diseases.

Claims

1. A method for detecting apple leaf diseases based on improved YOLOv8, characterized in that: The following steps are involved: (1) Obtain images of apple leaf diseases and insect pests and perform preprocessing based on pathological characteristics; (2) Use image processing methods to expand the data set and divide it into training and test sets; (3) Build an improved YOLOv8 network model and use the improved model to train the data set to obtain the final apple leaf disease detection model; (4) Use the final apple leaf disease detection model to detect the image and obtain the detection results.

2. The apple leaf disease detection method based on improved YOLOv8 according to claim 1, characterized in that: Step (1) is as follows: classify and label the images according to the pathological characteristics, namely leaf spot disease, brown spot disease, mosaic disease, gray spot disease, rust disease and mosaic disease.

3. The apple leaf disease detection method based on improved YOLOv8 according to claim 1, characterized in that: Step (2) is as follows: the image is processed by affine transformation, filtering, translation, and rotation methods to expand the data set.

4. The apple leaf disease detection method based on improved YOLOv8 according to claim 1, characterized in that: Step (3) is as follows: Use SPD-Conv spatial depth conversion convolutional coding technology to replace the original Conv of YOLOv8 to convert the image spatial information into depth information; introduce the Slim-neck architecture to build a neural network neck; introduce the YOLOv8 detection head into the self-attention module and convolution module.

5. The apple leaf disease detection method based on improved YOLOv8 according to claim 3, characterized in that: The convolution implementation process of SPD-Conv spatial depth conversion convolution coding technology is as follows: replace the strided convolution and pooling layers in the network with PD-Conv.

6. The apple leaf disease detection method based on improved YOLOv8 according to claim 3, characterized in that: The implementation process of the Slim-neck architecture to build the neural network neck is as follows: Slim-Neck design is introduced into the Neck part of YOLOv8, and the convolution GSConv and VoV-GSCSP replace the original Conv and C2f modules in the Neck part respectively.

7. The apple leaf disease detection method based on improved YOLOv8 according to claim 3, characterized in that: The self-attention module is used to capture contextual information, including: multi-head self-attention layer MHSA, 1x1 convolution layer, batch normalization layer BN, residual connection and ReLu activation function; the convolution module obtains local information through downsampling and upsampling operations, and reduces computational complexity through downsampling and feature conversion.

8. The apple leaf disease detection method based on improved YOLOv8 according to claim 3, characterized in that: In step (3), the network is optimized by a multi-objective search method based on a genetic algorithm, and the formula is as follows: Among them, L train is the training loss and N(A,W) is the hypernetwork. Search Target: Among them, α is the candidate network architecture, A is the architecture search space, which contains all possible network architecture combinations, and f k (α) is the kth optimization objective.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the computer program is loaded into the processor, an apple leaf disease detection method based on improved YOLOv8 is implemented according to any one of claims 1 to 8.

10. A storage medium storing a computer program, characterized in that: When the computer program is executed by the processor, an apple leaf disease detection method based on improved YOLOv8 is implemented according to any one of claims 1 to 8.

Citation Information

Cited By

  • Grape leaf disease detection method, equipment and program product

    CN120472218A

  • Tea insect pest quadrat intelligent statistical method based on improved instance segmentation network

    CN122368777A