Grape leaf disease detection method based on YOLOv8

By improving the YOLOv8 model structure, combining the FasterNet network and the adaptive learning rate optimization algorithm, the problem of large computing overhead in the existing technology is solved, real-time, accurate and efficient detection of grape leaf disease detection is achieved, and the performance and reliability of the detection system are improved.

CN120259168APending Publication Date: 2025-07-04WUCHANG INST OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510171014.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-17
Publication Date
2025-07-04

AI Technical Summary

Technical Problem

In the prior art, the calculation overhead of grape leaf disease detection method based on YOLOv7 is high, which is not conducive to lightweight deployment, and is not optimized for real-time detection scenarios, lack of consideration of inference speed, resulting in low detection efficiency.

Method used

The YOLOv8 model is adopted, and the Bottleneck structure in the C2f module is replaced with the FasterNet network structure, and combined with the FasterNet network structure, including Pconv and PWConv modules, the model performance is optimized through the adaptive learning rate optimization algorithm and the domain adaptive non-maximum suppression algorithm, and the model performance is optimized and deployed to the detection system based on the PySide6 framework.

Benefits of technology

Real-time disease detection of grape leaf images or video data is realized, the accuracy and practicality of the detection is improved, and the disease category and location annotation can be accurately output, which enhances the generalization ability and robustness of the model, and reduces false detection and missed detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120259168A_ABST
    Figure CN120259168A_ABST
Patent Text Reader

Abstract

The invention relates to the field of grape leaf disease detection, and provides a grape leaf disease detection method based on YOLOv8, which comprises the following steps: acquiring original disease image data of grape leaves, preprocessing the original disease image data to obtain disease image data, and dividing the disease image data into a training set and a verification set; the method comprises the following steps: constructing a YOLOv8 basic model, and replacing a Bottleneck structure in a C2f module of the YOLOv8 basic model with a FasterNet network structure to obtain an initial grape leaf disease detection model; training, testing and optimizing the initial grape leaf disease detection model based on the training set and the verification set to obtain a grape leaf disease detection model; deploying the grape leaf disease detection model to a grape leaf disease detection system, and performing disease detection on the real-time grape leaf image data or the real-time grape leaf video data based on the grape leaf disease detection system to obtain a disease detection result. According to the invention, real-time disease detection of the grape leaf image or video data uploaded by the user is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of grape leaf disease detection, and in particular to a grape leaf disease detection method based on YOLOv8. Background Art

[0002] When grapes are growing, they are often eroded by diseases, which will not only reduce the fruit quality and yield of grapes, but even cause a devastating blow to the vineyard in severe cases. Since grapes have important nutritional, medicinal and economic values, improving the prevention and control efficiency of grape leaf diseases is the key to improving the fruit quality and yield. There are many types of grape leaf diseases, and many of their symptoms are similar, making it difficult to identify them manually. Therefore, how to accurately and efficiently identify the types of grape leaf diseases and give corresponding prevention and control strategies is of great significance to the development of the grape industry.

[0003] Currently, the detection of grape leaf diseases still mainly relies on manual observation. Farmers and researchers need to observe the lesions on the leaves with the naked eye and judge which disease it is according to their own experience. The accuracy of disease types depends on the experience of relevant personnel. In addition, some of the lesion areas on grape leaves are very small, which not only increases the detection difficulty, but also greatly affects the detection ability of personnel.

[0004] In the prior art, a grape leaf disease detection method improved based on YOLOv7 is adopted, which improves the CA attention mechanism, adds max pooling, average pooling and fully connected layers, and detects three diseases: brown spot disease, black rot disease and zonate spot disease. However, this method uses multiple complex attention mechanisms and network structures, resulting in a large computational overhead, which is not conducive to lightweight deployment. It is not optimized for real-time detection scenarios, lacks consideration for inference speed, and is not lightweight enough. Summary of the Invention

[0005] In view of this, the present invention proposes a grape leaf disease detection method based on YOLOv8, which solves the problems of the prior art that it uses multiple complex attention mechanisms and network structures, has a large computational overhead, is not conducive to lightweight deployment, is not optimized for real-time detection scenarios, lacks consideration for inference speed, and is not lightweight enough.

[0006] The technical solution of the present invention is implemented as follows: The present invention provides a grape leaf disease detection method based on YOLOv8, including the following steps:

[0007] Collect the original disease image data of grape leaves, preprocess the original disease image data to obtain disease image data, and divide the disease image data into a training set and a validation set;

[0008] Build the YOLOv8 basic model, where the YOLOv8 basic model includes a backbone network, a feature pyramid, and a detection head. Replace the Bottleneck structure in the C2f module of the YOLOv8 basic model with the FasterNet network structure and adjust the model parameters to obtain an initial grape leaf disease detection model. The FasterNet network structure includes a Pconv module and two PWConv modules;

[0009] Train and test-tune the initial grape leaf disease detection model based on the training set and the validation set to obtain a grape leaf disease detection model;

[0010] Deploy the grape leaf disease detection model to a grape leaf disease detection system, and perform disease detection on the real-time grape leaf image data or real-time grape leaf video data uploaded by the user based on the grape leaf disease detection system to obtain a disease detection result. The grape leaf disease detection system is developed based on the PySide6 framework, and the disease detection result includes the disease category and disease location annotation.

[0011] Based on the above technical solutions, preferably, the steps of collecting the original disease image data of grape leaves, preprocessing the original disease image data to obtain disease image data, and dividing the disease image data into a training set and a validation set include:

[0012] Collect the original disease image data of the grape leaves, where the original disease image data includes the diseased leaf images of black rot, black measles, and leaf spot, and healthy leaf images;

[0013] Perform annotation and data augmentation processing on the original disease image data to obtain disease image data, divide the disease image data into an original training set and an original validation set, and perform resolution unification processing on the original training set and the original validation set to obtain a training set and a validation set.

[0014] Based on the above technical solutions, preferably, the data augmentation processing includes geometric transformation and pixel transformation. The geometric transformation includes rotation, translation, and cropping, and the pixel transformation includes brightness adjustment and contrast adjustment;

[0015] The resolution unification processing uses bilinear interpolation to adjust the images of the original training set and the original validation set to a size of 640×640 pixels.

[0016] Based on the above technical solutions, preferably, the YOLOv8 basic model is constructed. The YOLOv8 basic model includes a backbone network, a feature pyramid, and a detection head. Replace the Bottleneck structure in the C2f module of the YOLOv8 basic model with the FasterNet network structure and adjust the model parameters to obtain an initial grape leaf disease detection model. The FasterNet network structure includes a Pconv module and two PWConv modules, including:

[0017] The backbone network adopts the CSPDarknet architecture to extract image features through a multi-layer convolutional network and a cross-stage local network. The feature pyramid network adopts a bottom-up and top-down feature fusion method to enhance the model's detection ability for targets of different scales. The detection head adopts a decoupled head design to output the position and disease category information of the disease target respectively.

[0018] Based on the above technical solutions, preferably, the FasterNet network structure includes a Pconv module and two PWConv modules. The Pconv module is connected to the two PWConv modules in sequence, where

[0019] The Pconv module is a partial convolution module used to reduce the computational complexity;

[0020] The PWConv module is a pointwise convolution module used for feature fusion and channel information interaction.

[0021] Based on the above technical solutions, preferably, training and testing optimization are performed on the initial grape leaf disease detection model based on the training set and the validation set to obtain a grape leaf disease detection model, including:

[0022] An adaptive learning rate optimization algorithm is used to train the initial grape leaf disease detection model through a comprehensive loss function that fuses disease domain information. When the comprehensive loss function that fuses disease domain information is minimized, the trained initial grape leaf disease detection model is obtained;

[0023] The calculation formula of the comprehensive loss function that fuses disease domain information is:

[0024]

[0025] where, L disease is the value of the comprehensive loss function that fuses disease domain information, α1 is the weight coefficient of the localization loss term, β1 is the weight coefficient of the classification loss term, γ is the weight coefficient of the regularization loss term, δ1 is the weight coefficient of the disease difference loss term, Smooth L1(·) is the Smooth L1 loss function, b is the predicted bounding box, b* is the ground truth bounding box, Smooth L1 (b, b*) is the positional error between the predicted bounding box and the ground truth bounding box, FocalLoss(·) is the focal loss function, p is, p true is, L2Regularization(·) is the L2 regularization term, W is the model parameter, LeafDiff(·) is the disease difference loss term, I is the predicted image, I * is the ground truth image, ΔC(u, v) is the color difference between I and I * at the pixel point (u, v), ΔA(u, v) is the area contribution of the diseased patch at the pixel point (u, v), and Ω is the set of all pixel points within the diseased leaf region.

[0026] Based on the above technical solutions, preferably, training and testing and tuning the initial grape leaf disease detection model based on the training set and the validation set to obtain the grape leaf disease detection model further includes:

[0027] Screen the prediction results output by the initial grape leaf disease detection model through the domain adaptive non-maximum suppression algorithm to remove duplicate detection results;

[0028] Calculate the performance metrics of the initial grape leaf disease detection model based on the validation set, including accuracy, recall, F1 score, and calculate the mean average precision of various diseases;

[0029] Calculate the confusion matrix of various diseases, analyze the distribution of prediction errors between different disease categories, analyze the feature differences between easily confused disease categories, and calculate the inter-class distance based on the disease feature vectors;

[0030] Dynamically adjust the influence adjustment parameters in the domain adaptive non-maximum suppression algorithm based on the performance metrics;

[0031] Based on the feedback of the validation set, perform incremental training on the initial grape leaf disease detection model, update the model parameters, adopt an early stopping strategy to prevent overfitting, and monitor the loss change on the validation set.

[0032] Based on the above technical solutions, preferably, the calculation formula of the domain adaptive non-maximum suppression algorithm is:

[0033] Score final =Score original ×exp(-λ×IoU 2 -μ×(1 - DSI));

[0034] where, Score final is the screening score of the prediction result, Score originalConfidence score of the original prediction box, IoU is the intersection over union, DSI is the disease similarity index, λ is the influence adjustment parameter of the intersection over union error on the screening score, μ is the influence adjustment parameter of the disease similarity index on the screening score, and exp(·) is the exponential function.

[0035] Based on the above technical solutions, preferably, the grape leaf disease detection model is deployed to the grape leaf disease detection system, and the grape leaf disease detection system performs disease detection on the real-time grape leaf image data or real-time grape leaf video data uploaded by the user to obtain the disease detection result. The grape leaf disease detection system is developed based on the PySide6 framework. The disease detection result includes the disease category and the disease location annotation, and includes:

[0036] The grape leaf disease detection system includes a data input module, a model loading module, and a data processing and visualization module. The data input module, the model loading module, and the data processing and visualization module are connected in sequence. Among them,

[0037] The data input module is used to upload real-time grape leaf image data or real-time grape leaf video data. The model loading module is used to load and call the grape leaf disease detection model. The data processing and visualization module is used to display the disease detection result. The disease detection result includes the disease category and the disease location annotation.

[0038] Based on the above technical solutions, preferably, when the grape leaf disease detection system performs frame processing on video data, it uses the frame difference algorithm or the optical flow method to extract key frames, and applies the time series consistency analysis method to correct the detection results of the disease areas in consecutive frames;

[0039] When the grape leaf disease detection system outputs the disease detection result, the disease category includes a confidence score, which is used to indicate the reliability of the detection result;

[0040] The disease location annotation marks the disease area in the form of a bounding box or a segmentation contour.

[0041] A grape leaf disease detection method based on YOLOv8 of the present invention has the following beneficial effects compared with the prior art:

[0042] (1) By improving the YOLOv8 model structure, using the FasterNet network structure to optimize the model performance, and using the training set and the validation set to train and tune the model, the optimized model is deployed to the detection system developed based on the PySide6 framework, realizing real-time disease detection of the grape leaf image or video data uploaded by the user, and being able to accurately output the disease category and the disease location annotation, improving the accuracy and practicability of grape leaf disease detection;

[0043] (2) By introducing a comprehensive loss function that integrates information in the field of disease, including localization loss, classification loss, regularization loss, and disease difference loss, and specifically considering the color difference and area contribution of lesions based on the disease difference loss term, the model can better learn and identify the characteristics of grape leaf diseases during the training process. At the same time, an adaptive learning rate optimization algorithm is adopted to optimize the model parameters by minimizing the comprehensive loss function, which not only improves the recognition accuracy of the model for different types of diseases but also enhances the generalization ability of the model;

[0044] (3) Through the domain adaptive non-maximum suppression algorithm, the prediction results of the initial grape leaf disease detection model are screened, comprehensively considering the confidence level, intersection over union (IoU), and disease similarity index of the prediction boxes, effectively removing duplicate detection results and low-quality prediction boxes;

[0045] (4) By dynamically adjusting the influence weights of the IoU error and disease similarity index on the screening score, the screening process is further optimized, enabling the model to more accurately locate the disease area and identify the disease category. In cases where the disease area features are complex or the disease categories are easily confused, it can effectively reduce false detections and missed detections, improving the accuracy and reliability of the detection results. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.

[0047] Figure 1 It is a flowchart of a grape leaf disease detection method based on YOLOv8 according to the present invention;

[0048] Figure 2 It is a technical roadmap of an embodiment of the present invention;

[0049] Figure 3 It is a network structure diagram of the YOLOv8 model of an embodiment of the present invention;

[0050] Figure 4 It is a comparison diagram of the C3 module and the C2f module of an embodiment of the present invention;

[0051] Figure 5 It is an improved schematic diagram of the C2f module based on FasterNet of an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0052] Next, in combination with the embodiments of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0053] Please refer to Figure 1 , the present invention provides a grape leaf disease detection method based on YOLOv8, including the following steps:

[0054] Collect the original disease image data of grape leaves, preprocess the original disease image data to obtain disease image data, and divide the disease image data into a training set and a validation set;

[0055] Construct a YOLOv8 basic model. The YOLOv8 basic model includes a backbone network, a feature pyramid, and a detection head. Replace the Bottleneck structure in the C2f module of the YOLOv8 basic model with a FasterNet network structure and adjust the model parameters to obtain an initial grape leaf disease detection model. The FasterNet network structure includes a Pconv module and two PWConv modules;

[0056] Train and test-optimize the initial grape leaf disease detection model based on the training set and the validation set to obtain a grape leaf disease detection model;

[0057] Deploy the grape leaf disease detection model to a grape leaf disease detection system, and perform disease detection on the real-time grape leaf image data or real-time grape leaf video data uploaded by the user based on the grape leaf disease detection system to obtain a disease detection result. The grape leaf disease detection system is developed based on the PySide6 framework, and the disease detection result includes disease category and disease location annotation.

[0058] Specifically, in this embodiment, by improving the YOLOv8 model structure, using the FasterNet network structure to optimize the model performance, and using the training set and the validation set to train and optimize the model, the optimized model is deployed to a detection system developed based on the PySide6 framework, realizing real-time disease detection of the grape leaf image or video data uploaded by the user, and being able to accurately output the disease category and disease location annotation, improving the accuracy and practicability of grape leaf disease detection.

[0059] The step of collecting the original disease image data of grape leaves, preprocessing the original disease image data to obtain disease image data, and dividing the disease image data into a training set and a validation set includes:

[0060] Collect the original disease image data of the grape leaves, where the original disease image data includes the diseased leaf images and healthy leaf images of black rot, black measles, and leaf spot diseases;

[0061] Perform annotation and data augmentation processing on the original disease image data to obtain disease image data. Divide the disease image data into an original training set and an original validation set, and perform resolution unification processing on the original training set and the original validation set to obtain a training set and a validation set.

[0062] The data augmentation processing includes geometric transformation and pixel transformation. The geometric transformation includes rotation, translation, and cropping, and the pixel transformation includes brightness adjustment and contrast adjustment;

[0063] The resolution unification processing uses the bilinear interpolation method to adjust the images of the original training set and the original validation set to a size of 640×640 pixels.

[0064] Specifically, in this embodiment, by collecting leaf images of various disease types including black rot, black measles, leaf spot diseases, etc., and combining data augmentation processing of geometric transformation (rotation, translation, cropping) and pixel transformation (brightness, contrast adjustment), the diversity of training data is significantly expanded, and the model's recognition ability for disease characteristics under different angles and lighting conditions is enhanced. Using the bilinear interpolation method to uniformly adjust the images to a size of 640×640 pixels not only ensures the image quality but also improves the standardization and computational efficiency of model training.

[0065] Build the YOLOv8 basic model, where the YOLOv8 basic model includes a backbone network, a feature pyramid, and a detection head. Replace the Bottleneck structure in the C2f module of the YOLOv8 basic model with the FasterNet network structure and adjust the model parameters to obtain an initial grape leaf disease detection model. The FasterNet network structure includes a Pconv module and two PWConv modules, including:

[0066] The backbone network adopts the CSPDarknet architecture to extract image features through a multi-layer convolutional network and a cross-stage local network. The feature pyramid network uses a bottom-up and top-down feature fusion method to enhance the model's detection ability for targets of different scales. The detection head adopts a decoupled head design to output the disease target position and disease category information respectively.

[0067] The FasterNet network structure includes a Pconv module and two PWConv modules. The Pconv module is sequentially connected to the two PWConv modules, where,

[0068] The Pconv module is a partial convolution module used to reduce computational complexity;

[0069] The PWConv module is a pointwise convolution module used for feature fusion and channel information interaction.

[0070] Specifically, in this embodiment, by improving the YOLOv8 basic model and replacing the traditional Bottleneck structure with the FasterNet network structure containing the Pconv and PWConv modules, lightweight optimization of the model is achieved. Among them,

[0071] The Pconv module (partial convolution) effectively reduces computational complexity, while the PWConv module (pointwise convolution) enhances the feature fusion ability; at the same time, the backbone network adopting the CSPDarknet architecture provides strong feature extraction ability, and with the bidirectional feature fusion mechanism and decoupled head design of the feature pyramid network, the detection accuracy of the model for grape leaf diseases of different scales is significantly improved.

[0072] Training and testing optimization are performed on the initial grape leaf disease detection model based on the training set and the validation set to obtain a grape leaf disease detection model, including:

[0073] An adaptive learning rate optimization algorithm is used to train the initial grape leaf disease detection model through a comprehensive loss function that fuses disease domain information. When the comprehensive loss function that fuses disease domain information is minimized, the trained initial grape leaf disease detection model is obtained;

[0074] The calculation formula of the comprehensive loss function that fuses disease domain information is:

[0075]

[0076] where L disease is the value of the comprehensive loss function that fuses disease domain information, α1 is the weight coefficient of the localization loss term, β1 is the weight coefficient of the classification loss term, γ is the weight coefficient of the regularization loss term, δ1 is the weight coefficient of the disease difference loss term, is the smooth L1 loss function, b is the predicted bounding box, b * is the ground truth bounding box, is the position error between the predicted bounding box and the ground truth bounding box, FocalLoss(·) is the focal loss function, p is, p true is, L2Regularization(·) is the L2 regularization term, W is the model parameter, LeafDiff(·) is the disease difference loss term, I is the predicted image, I * is the ground truth image, ΔC(u,v) is the difference between I and I *The color difference at pixel point (u, v), ΔA(u, v) is the area contribution of the lesion at pixel point (u, v), and Ω is the set of all pixel points within the diseased leaf area.

[0077] Specifically, in this embodiment, by introducing a comprehensive loss function that integrates disease domain information, including localization loss, classification loss, regularization loss, and disease difference loss, and particularly considering the color difference and area contribution of the lesions based on the disease difference loss term, the model can better learn and identify the characteristics of grape leaf diseases during the training process. At the same time, an adaptive learning rate optimization algorithm is adopted to optimize the model parameters by minimizing the comprehensive loss function, which not only improves the recognition accuracy of the model for different types of diseases but also enhances the generalization ability of the model.

[0078] Training and testing optimization of the initial grape leaf disease detection model based on the training set and the validation set to obtain a grape leaf disease detection model further includes:

[0079] Screen the prediction results output by the initial grape leaf disease detection model through a domain adaptive non-maximum suppression algorithm to remove duplicate detection results;

[0080] Calculate the performance metrics of the initial grape leaf disease detection model based on the validation set, including accuracy, recall rate, and F1 score, and calculate the mean average precision of various diseases;

[0081] Calculate the confusion matrix of various diseases, analyze the distribution of prediction errors between different disease categories, analyze the feature differences between easily confused disease categories, and calculate the inter-class distance based on the disease feature vectors;

[0082] Dynamically adjust the influence adjustment parameters in the domain adaptive non-maximum suppression algorithm based on the performance metrics;

[0083] Based on the feedback from the validation set, perform incremental training on the initial grape leaf disease detection model, update the model parameters, adopt an early stopping strategy to prevent overfitting, and monitor the loss change on the validation set.

[0084] Specifically, in this embodiment, by introducing a domain adaptive non-maximum suppression algorithm and an incremental training strategy, the performance and robustness of the grape leaf disease detection model are significantly improved. The domain adaptive non-maximum suppression algorithm effectively removes duplicate detection results and low-quality prediction boxes by comprehensively considering the confidence, intersection over union, and disease similarity index of the prediction boxes, and dynamically adjusts the adjustment parameters to adapt to different disease characteristics, improving the accuracy and reliability of the detection results.

[0085] By calculating the confusion matrix and the distance between classes, the characteristic differences between easily confused disease categories were analyzed, further optimizing the model's ability to distinguish different disease categories; incremental training combined with the early stopping strategy effectively prevented overfitting, and the model parameters were dynamically updated through the feedback of the validation set to ensure the generalization ability of the model under different data distributions. Overall, this embodiment enhanced the adaptability of the model to complex disease scenarios, improved the detection accuracy, recall rate, and F1 score, providing more stable and efficient technical support for practical applications.

[0086] The calculation formula of the domain adaptive non-maximum suppression algorithm is as follows:

[0087] Score final = Score original × exp(-λ × IoU 2 - μ × (1 - DSI));

[0088] Among them, Score final is the screening score of the prediction result, Score original is the confidence score of the original prediction box, IoU is the intersection over union, DSI is the disease similarity index, λ is the influence adjustment parameter of the intersection over union error on the screening score, μ is the influence adjustment parameter of the disease similarity index on the screening score, and exp(·) is the exponential function.

[0089] Specifically, in this embodiment, the prediction results of the initial grape leaf disease detection model are screened through the domain adaptive non-maximum suppression algorithm, comprehensively considering the confidence of the prediction box, the intersection over union, and the disease similarity index, effectively removing duplicate detection results and low-quality prediction boxes;

[0090] By dynamically adjusting the influence weights of the intersection over union error and the disease similarity index on the screening score, the screening process is further optimized, enabling the model to more accurately locate the disease area and identify the disease category. In the case of complex disease area characteristics or easily confused disease categories, it can effectively reduce false detections and missed detections, improving the accuracy and reliability of the detection results.

[0091] Deploying the grape leaf disease detection model to the grape leaf disease detection system, and performing disease detection on the real-time grape leaf image data or real-time grape leaf video data uploaded by the user based on the grape leaf disease detection system to obtain disease detection results. The grape leaf disease detection system is developed based on the PySide6 framework, and the disease detection results include disease categories and disease location annotations, including:

[0092] The grape leaf disease detection system includes a data input module, a model loading module, and a data processing and visualization module. The data input module, the model loading module, and the data processing and visualization module are connected in sequence. Among them,

[0093] The data input module is used to upload real-time grape leaf image data or real-time grape leaf video data. The model loading module is used to load and call the grape leaf disease detection model. The data processing and visualization module is used to display the disease detection results, and the disease detection results include disease categories and disease location annotations.

[0094] Specifically, in this embodiment, by designing a modular grape leaf disease detection system architecture, which includes three core components: a data input module, a model loading module, and a data processing and visualization module, the efficient decoupling and collaborative work of the system functions are realized.

[0095] The data input module supports the flexible upload of real-time image and video data. The model loading module realizes the rapid call and loading of the disease detection model. The data processing and visualization module provides an intuitive display of the disease detection results, including the visual presentation of disease categories and location annotations.

[0096] When the grape leaf disease detection system processes video data for frame processing, it uses the inter-frame difference algorithm or the optical flow method to extract key frames, thereby reducing redundant data, and applies the time series consistency analysis method to correct the detection results of disease regions in consecutive frames to improve stability;

[0097] When the grape leaf disease detection system outputs the disease detection results, the disease categories include confidence scores, which are used to indicate the reliability of the detection results;

[0098] The disease location annotation marks the disease region in the form of a bounding box or a segmentation contour, and supports export as an annotation file in JSON or XML format for subsequent analysis or archiving.

[0099] Specifically, in this embodiment, for video data processing, the inter-frame difference algorithm or the optical flow method is introduced to extract key frames, effectively reducing the amount of redundant data processing and improving the system efficiency; the time series consistency analysis method is used to correct the disease detection results in consecutive frames, enhancing the stability and coherence of the detection; confidence scores are added to the output results to provide users with a quantitative reference for detection reliability; it supports marking the disease region in the form of a bounding box or a segmentation contour and can be exported as a standard JSON or XML format file, facilitating data storage, sharing, and subsequent analysis, greatly enhancing the practical value and data management ability of the system in actual application scenarios.

[0100] In a specific embodiment, the technical roadmap of a grape leaf disease detection method based on YOLOv8 of the present invention is as Figure 2As shown in the figure, in this embodiment, the YOLOv8 deep learning object detection model is utilized, combined with data augmentation techniques and network structure improvements, to enhance the accuracy and efficiency of grape leaf disease detection. By optimizing the traditional YOLOv8, introducing the FasterNet structure, reducing the model complexity and improving its inference speed, while maintaining the high precision of the model, an automatic grape leaf disease detection system suitable for the agricultural production environment is constructed.

[0101] In this embodiment, the structure of the YOLOv8 model is optimized. The FasterNet structure is adopted to replace the Bottleneck part in the C2f module, thereby reducing the computational amount and accelerating the inference speed. The grape leaf data is augmented by methods such as geometric transformation (such as rotation, translation, mirroring, etc.) and pixel transformation to improve the generalization ability of the model. Using the augmented dataset, through comparative experiments of different models (such as YOLOv3-tiny, YOLOv5, etc.), the performance of YOLOv8 and its improved version is verified. Experiments show that the improved YOLOv8 reduces the computational amount by about 20% while maintaining the accuracy. A set of grape leaf disease detection system is developed based on the PySide6 framework to realize the actual deployment of the model and the graphical operation of users.

[0102] The network structure diagram of the YOLOv8 model is as Figure 3 shown. Among them, in the backbone network Backbone, the idea of the CSPDarkNet network structure is also borrowed as in YOLOv5. However, different from YOLOv5, all C3 modules in YOLOv5 are replaced with C2f modules, and the size of the first convolutional layer also changes from... to..., with more skip connections and additional Split operations. This not only strengthens the feature fusion ability of the network, but also improves the inference speed of the model, making the whole model more lightweight.

[0103] The comparison between the C3 module and the C2f module is as Figure 4 shown. Different from C3, the C2f module cancels the first two Conv convolutions, instead using one Conv convolution and performing a Split operation before inputting into the Bottleneck. And there are also some changes in the Bottleneck, making the number of channels of the input tensor of each Bottleneck module only 0.5 times that of the previous level. Therefore, the computational amount can be significantly reduced. From another perspective, with the increase of this gradient flow, the convergence speed and effect can also be significantly improved.

[0104] In the Neck layer, YOLOv8 refers to the ELAN design concept of YOLOv7, replaces all C3 structures with C2f structures, and adjusts the number of channels for models of different scales. Different from blindly applying the same parameters to all models in the past, in this embodiment, the model structure is carefully fine-tuned.

[0105] The Head part has a relatively large change compared to YOLOv5. It directly changes the coupled head to a decoupled head structure similar to YOLOX (Decoupled-Head), separates the regression branch and the prediction branch, and uses the integral form representation method proposed in the Distribution Focal Loss strategy for the regression branch. Previous object detection networks predicted the regression coordinates as a deterministic single value. Further, the design of the loss function in YOLOv8 has also been improved to a certain extent. The CloU loss is used to more accurately measure the overlap between the predicted bounding box and the ground truth bounding box, enabling the model to pay more attention to the geometric attributes of the object during training. Similar to the previous design of YOLOv5, YOLOv8 provides several model specifications such as n / s / m / l / x, and the parameters are shown in Table 1.

[0106] Table 1 Comparison chart of YOLOv5 and YOLOv8 parameters

[0107]

[0108] As can be seen from the data in Table 1:

[0109] The complexity and the number of parameters of YOLOv8 are generally higher than those of YOLOv5: The number of parameters and the number of floating-point operations (FLOPs) of the YOLOv8 model are larger than those of YOLOv5 for each model scale. For example, the number of parameters of YOLOv8-n is 3.2M, while that of YOLOv5-n is 1.9M; the FLOPs are 8.7B and 4.5B respectively.

[0110] The YOLOv8 model increases the computational complexity while improving the performance: The YOLOv8 model improves the performance by introducing more parameters and higher computational complexity. For models of the same scale, the computational amount of YOLOv8 is about 2 to 3 times that of YOLOv5. For example, the FLOPs of YOLOv8-x is 257.8B, while that of YOLOv5-x is 205.7B.

[0111] Higher accuracy and functionality require a greater computational cost: While improving the detection accuracy and functionality, the complexity and computational cost of the YOLOv8 model increase accordingly, and higher hardware resources are required for training and inference.

[0112] In a specific embodiment, this embodiment first collects data through a public dataset and actual grape leaf images taken, focusing on four classifications: black rot, black measles, leaf spot, and healthy leaves. In the data preprocessing stage, this embodiment performs a variety of data augmentation methods, including geometric transformations (such as rotation, translation, cropping, etc.) and pixel transformations (such as brightness adjustment, contrast adjustment, etc.), to ensure the diversity of training data and the generalization ability of the model. The finally constructed training set contains 7,764 pictures, and the validation set contains 1,497 pictures. The resolution of all images is uniformly 640×640 pixels to ensure the consistency of model input.

[0113] As Figure 5 shown, in terms of model improvement, this embodiment uses the FasterNet network structure to optimize the YOLOv8 model, especially improving the Bottleneck part in the C2f module, successfully reducing the computational complexity of the model. Through multiple experimental optimizations, this embodiment verifies that the computational efficiency of the model has been significantly improved without sacrificing detection accuracy. This improvement scheme effectively reduces the FLOPs of the model, enabling it to run stably in resource-constrained environments.

[0114] Due to the high computational complexity of the YOLO series models, this embodiment selects a cloud server platform for model training, configures a high-performance GPU (such as RTX 4090D) and the PyTorch framework to support large-scale deep learning experiments. To further improve the experimental efficiency, this embodiment simplifies the management and maintenance of the experimental environment through remote operation, ensuring the smooth progress of the model training and testing processes, and guaranteeing the stability and repeatability of the experiments.

[0115] The above are only the preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A grape leaf disease detection method based on YOLOv8, characterized in that, It includes the following steps: Collect the original disease image data of grape leaves, preprocess the original disease image data to obtain disease image data, and divide the disease image data into a training set and a validation set; Construct a YOLOv8 basic model, the YOLOv8 basic model includes a backbone network, a feature pyramid, and a detection head, replace the Bottleneck structure in the C2f module of the YOLOv8 basic model with a FasterNet network structure, and adjust the model parameters to obtain an initial grape leaf disease detection model, the FasterNet network structure includes a Pconv module and two PWConv modules; Train and test-tune the initial grape leaf disease detection model based on the training set and the validation set to obtain a grape leaf disease detection model; Deploy the grape leaf disease detection model to a grape leaf disease detection system, and perform disease detection on the real-time grape leaf image data or real-time grape leaf video data uploaded by the user based on the grape leaf disease detection system to obtain a disease detection result. The grape leaf disease detection system is developed based on the PySide6 framework, and the disease detection result includes disease category and disease location annotation.

2. The grape leaf disease detection method based on YOLOv8 according to claim 1, characterized in that, The step of collecting the original disease image data of grape leaves, preprocessing the original disease image data to obtain disease image data, and dividing the disease image data into a training set and a validation set includes: Collect the original disease image data of the grape leaves, and the original disease image data includes diseased leaf images and healthy leaf images of black rot, black measles, and leaf spot; Perform annotation and data augmentation processing on the original disease image data to obtain disease image data, divide the disease image data into an original training set and an original validation set, and perform resolution unification processing on the original training set and the original validation set to obtain a training set and a validation set.

3. The grape leaf disease detection method based on YOLOv8 according to claim 2, wherein, The data augmentation processing includes geometric transformation and pixel transformation. The geometric transformation includes rotation, translation, and cropping, and the pixel transformation includes brightness adjustment and contrast adjustment; The resolution unification processing uses bilinear interpolation to adjust the images of the original training set and the original validation set to a size of 640×640 pixels.

4. The grape leaf disease detection method based on YOLOv8 according to claim 1, characterized in that, The step of constructing a YOLOv8 basic model, the YOLOv8 basic model includes a backbone network, a feature pyramid, and a detection head, replace the Bottleneck structure in the C2f module of the YOLOv8 basic model with a FasterNet network structure, and adjust the model parameters to obtain an initial grape leaf disease detection model, the FasterNet network structure includes a Pconv module and two PWConv modules, includes: The backbone network adopts the CSPDarknet architecture, extracts image features through multiple convolutional networks and cross-stage local networks. The feature pyramid network adopts a bottom-up and top-down feature fusion method to enhance the model's detection ability for targets of different scales. The detection head adopts a decoupled head design, and outputs the disease target position and disease category information respectively.

5. The grape leaf disease detection method based on YOLOv8 according to claim 4, wherein, The FasterNet network structure includes a Pconv module and two PWConv modules, and the Pconv module is sequentially connected to the two PWConv modules, where the Pconv module is a partial convolution module, which is used to reduce the computational complexity; the PWConv module is a pointwise convolution module, which is used for feature fusion and channel information interaction.

6. The grape leaf disease detection method based on YOLOv8 according to claim 5, characterized in that, Training and testing optimization of the initial grape leaf disease detection model based on the training set and the validation set to obtain a grape leaf disease detection model, including: Adopting an adaptive learning rate optimization algorithm, training the initial grape leaf disease detection model through a comprehensive loss function that integrates disease domain information. When the comprehensive loss function that integrates disease domain information is minimized, the trained initial grape leaf disease detection model is obtained; The calculation formula of the comprehensive loss function that integrates disease domain information is: Among them, L disease is the comprehensive loss function value integrating the information in the disease field, α1 is the weight coefficient of the localization loss term, β1 is the weight coefficient of the classification loss term, γ is the weight coefficient of the regularization loss term, δ1 is the weight coefficient of the disease difference loss term, Smooth L1 (·) is the Smooth L1 loss function, b is the predicted bounding box, b* is the ground truth bounding box, Smooth L1 (b, b*) is the position error between the predicted bounding box and the ground truth bounding box, FocalLoss(·) is the focal loss function, p is, p true is, L2Regularization(·) is the L2 regularization term, W is the model parameter, LeafDiff(·) is the disease difference loss term, I is the predicted image, I * is the ground truth image, ΔC(u, v) is the color difference between I and I * at the pixel point (u, v), ΔA(u, v) is the area contribution of the lesion at the pixel point (u, v), and Ω is the set of all pixel points in the diseased leaf area.

7. The grape leaf disease detection method based on YOLOv8 according to claim 6, wherein Training and testing optimization of the initial grape leaf disease detection model based on the training set and the validation set to obtain a grape leaf disease detection model, further including: Screening the prediction results output by the initial grape leaf disease detection model through a domain adaptive non-maximum suppression algorithm to remove duplicate detection results; Calculating the performance indicators of the initial grape leaf disease detection model based on the validation set, including accuracy, recall rate, and F1 score, and calculating the mean average precision of various diseases; Calculating the confusion matrix of various diseases, analyzing the prediction error distribution between different disease categories, analyzing the feature differences between easily confused disease categories, and calculating the inter-class distance based on the disease feature vector; Dynamically adjusting the influence adjustment parameters in the domain adaptive non-maximum suppression algorithm based on the performance indicators; Based on the feedback of the validation set, performing incremental training on the initial grape leaf disease detection model, updating the model parameters, adopting an early stopping strategy to prevent overfitting, and monitoring the loss change on the validation set.

8. The grape leaf disease detection method based on YOLOv8 according to claim 7, characterized in that, The calculation formula of the domain adaptive non-maximum suppression algorithm is: Score final = Score original × exp(-λ × IoU 2 - μ × (1 - DSI)); Among them, Score final is the screening score of the prediction result, Score original is the confidence score of the original prediction box, IoU is the intersection over union, DSI is the disease similarity index, λ is the influence adjustment parameter of the intersection over union error on the screening score, μ is the influence adjustment parameter of the disease similarity index on the screening score, and exp(·) is the exponential function.

9. The grape leaf disease detection method based on YOLOv8 according to claim 8, wherein, Deploying the grape leaf disease detection model to a grape leaf disease detection system, and performing disease detection on the real-time grape leaf image data or real-time grape leaf video data uploaded by the user based on the grape leaf disease detection system to obtain a disease detection result. The grape leaf disease detection system is developed based on the PySide6 framework. The disease detection result includes disease category and disease position annotation, including: The grape leaf disease detection system includes a data input module, a model loading module, and a data processing and visualization module. The data input module, the model loading module, and the data processing and visualization module are sequentially connected, where The data input module is used to upload real-time grape leaf image data or real-time grape leaf video data. The model loading module is used to load and call the grape leaf disease detection model. The data processing and visualization module is used to display the disease detection results, and the disease detection results include disease categories and disease location annotations.

10. A grape leaf disease detection method based on YOLOv8 according to claim 9, characterized in that, When the grape leaf disease detection system performs frame processing on video data, it uses the inter-frame difference algorithm or the optical flow method to extract key frames, and applies the time series consistency analysis method to correct the detection results of disease regions in consecutive frames. When the grape leaf disease detection system outputs the disease detection results, the disease categories include confidence scores, which are used to indicate the reliability of the detection results. The disease location annotation marks the disease region in the form of a bounding box or a segmentation contour.