Ginseng leaf disease identification method based on improved YOLOv8

By creating an expanded ginseng leaf dataset and improving the YOLOv8 model, the problem of low recognition accuracy in ginseng leaf disease detection is solved, and higher recognition accuracy and generalization capabilities are achieved, which is suitable for real-time detection.

CN118941773AInactive Publication Date: 2024-11-12JILIN AGRI SCI & TECH COLLEGE +1

Patent Information

Application Number
CN202410965648.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-18
Publication Date
2024-11-12
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The prior art has low recognition accuracy in ginseng leaf disease detection, single adaptation scenarios, lack of data sets specifically for object detection, and the YOLOv8 model fails to fully consider the particularity of the detection scenario.

Method used

By creating a ginseng leaf dataset, data expansion and annotation are performed, using improved YOLOv8 model, replacing the C2f module with C2faster, adding a CBAM attention mechanism, using SIoU loss function, and introducing a DyHead module in the head network to optimize the model to improve detection performance.

Benefits of technology

It significantly improves the recognition rate and accuracy of different types of pests and diseases, enhances the generalization ability of the model, and realizes the improvement of detection performance while maintaining the size of the small model and the fast detection rate, and is suitable for real-time or near-real-time detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118941773A_ABST
    Figure CN118941773A_ABST
Patent Text Reader

Abstract

The invention discloses an improved YOLOv8-based ginseng leaf disease detection method and system, and relates to the technical field of target detection, and the method comprises the steps: collecting and making a ginseng leaf disease data set, inputting the ginseng leaf disease data set to an improved YOLOv8 target detection model, and obtaining the category information and position information of the ginseng leaf disease; wherein the training process of the model is as follows: training an improved YOLOv8 target detection algorithm based on a ginseng leaf disease data set; according to the algorithm, on the basis of an original algorithm, a Bottleneck block in C2f is replaced with a Fasnet block, an original detection head is replaced with a dyhead detection head, a loss function is replaced with an SIoU loss function, and a CBAM attention mechanism is introduced to obtain the algorithm. According to the invention, based on the improved YOLOv8 target detection algorithm, accurate identification and positioning of disease position and category information can be 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 target detection, and in particular to a ginseng leaf disease detection method based on improved YOLOv8. Technical Background

[0002] Ginseng is regarded as the "golden generation" of traditional Chinese medicinal materials and occupies an extremely important position in the Chinese medicine market. Ginseng has a variety of medicinal effects and health-care effects. It is not only a rare health-care medicinal material, but also an important ingredient in food, nutrition and cosmetics. The fleshy root of ginseng is a strong tonic medicine, suitable for symptoms such as hypotension, heart failure, neurasthenia and physical weakness. It also has the effects of expectoration, stomachic, diuretic and excitement. my country is the largest ginseng producer, accounting for about 50% of the world's cultivated area. However, with the destruction of the wild environment of ginseng and the country's restrictions on the use of forest land, field ginseng cultivation has become the main mode of ginseng cultivation. Ginseng is extremely susceptible to diseases during its long growing season, mainly ginseng diseases, which have a serious impact on ginseng yield and quality. Therefore, it is necessary to strengthen the research on field ginseng cultivation and management technology and prevent ginseng diseases and pests to promote the healthy development of field ginseng cultivation.

[0003] However, there are still a series of challenges in the field of ginseng disease detection. First, there are almost no public datasets on ginseng diseases, and the disease categories are not comprehensive enough, and there is a lack of datasets specifically for target detection. Secondly, although the YOLOv8 model performs well in general target detection tasks, it fails to fully consider the particularity of its detection scenarios in ginseng disease detection, resulting in problems such as low recognition accuracy, single adaptation scenario, and unsatisfactory detection effect.

[0004] Therefore, the present invention proposes a new scheme to detect ginseng leaf diseases. Summary of the invention

[0005] The purpose of the present invention is to provide a ginseng leaf disease recognition method based on improved YOLOv8, which can accurately classify and locate the location information and category information of ginseng leaf diseases.

[0006] To achieve the above object, the present invention provides the following solutions:

[0007] In the first part, the present invention provides a method for preparing a ginseng leaf dataset, comprising:

[0008] Use your mobile phone to go to the ginseng breeding base to take pictures of ginseng leaf diseases and collect some pictures of ginseng leaf diseases on the Internet;

[0009] Augment the dataset by scaling, translating, flipping, rotating, adding noise, and occluding;

[0010] Label different types of diseases in the new data set and divide it into training and test sets for model training and verification respectively;

[0011] Among them, the data set expansion is to use Python language code to randomly scale, translate, flip, rotate, add noise and occlusion to expand the data set exponentially.

[0012] In the second part, the present invention provides a ginseng leaf disease detection method based on improved YOLOv8.

[0013] The YOLOv8 model was used to iteratively train the ginseng leaf disease dataset to obtain the best model file;

[0014] Use the validation set to validate the model and output the test results.

[0015] By deploying the training model to the Android mobile phone, ginseng leaf diseases can be uploaded and identified in real time.

[0016] Preferably, in the steps, the open source software LabelImg is used to label different types of ginseng diseases, and the specific operation steps of labeling are as follows:

[0017] Use rectangular boxes to mark the diseased parts in the image and label each rectangular box;

[0018] Each annotation will generate an annotation file in .XML format, and convert the generated .XML file into .txt format;

[0019] The dataset images and the corresponding txt format annotation files are divided into training sets and test sets in a ratio of 8:2, which are used for subsequent model training and verification respectively.

[0020] Preferably, in the step, the improved YOLOv8 model uses YOLOv8 as the initial model, replaces the C2f module of the backbone part of the original network with the C2faster module and adds the CBAM attention mechanism, replaces the loss function of the original model with SIoU, and introduces the DyHead module in the head network.

[0021] Preferably, the Split operation in the original C2f structure is removed and redundant jump-layer connections are deleted, and then the Bottelneck block in C2f is replaced by the Fasternet block, and a new C2faster module is formed by integrating the C2f backbone network module with the Fasternet network.

[0022] Preferably, the CBAM attention mechanism in the step is added to the fourth and seventh layers of the original backbone network, combining the channel attention mechanism with the spatial attention mechanism to form a new convolutional block structure, thereby better performing feature fusion;

[0023] Preferably, the formula of the loss function is:

[0024]

[0025]

[0026] Where Λ is the angle loss, Δ is the distance loss, Ω is the shape loss, B is the predicted box, B GT It is a real frame;

[0027] The positional relationship between the predicted box and the real box of the SIoU loss function is shown in the figure.

[0028] Preferably, the DyHead module is introduced into the YOLOv8 head network. The DyHead module unifies scale-aware attention, space-aware attention, and task-aware attention by utilizing the self-attention mechanism.

[0029] The attention calculation formula is:

[0030] W(F)=π C (π S (π L (F)·F)·F)·F

[0031] Among them, F represents an input three-dimensional tensor L×S×C, π L , π S and π C They are scale-aware attention module, space-aware attention module and task-aware attention module.

[0032] Preferably, in step S4, a GPU is used to input the training set data into the improved YOLOv8 model for training.

[0033] Preferably, the improved model is deployed to an Android phone to upload and identify ginseng leaf diseases in real time.

[0034] Through the above technical solution, the beneficial effects of the present invention are:

[0035] 1. Compared with the original YOLOv8 model, the improved model of the present invention significantly improves the average precision mean while maintaining similar parameter detection rate and model size, and effectively improves the recognition rate and accuracy of different types of pests and diseases;

[0036] 2. The present invention expands the data set through data enhancement, improves the diversity and quality of the data, introduces the Fasternet network for lightweight processing, introduces the CBAM attention mechanism, and adopts the SIoU loss function. The DyHead detection head is introduced in the head network to more accurately measure the similarity between the predicted box and the real target box, thereby improving the detection performance of the model;

[0037] 3. The generalization ability of the improved YOLOv8 model has been enhanced, and it can maintain high detection performance when facing new and unseen data. As the model is continuously optimized during the training process, the recognition rate and accuracy of different types of ginseng leaf diseases have been improved, making the model better able to adapt to diverse data distributions. While maintaining a small model size and a fast detection rate, the performance has been improved, which is particularly important for application scenarios that require real-time or near-real-time detection.

[0038] 4. Deploy the improved model to Android phones to upload ginseng leaves in real time and identify the types of ginseng leaf diseases. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention, and the embodiments in the drawings do not constitute any limitation to the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0040] Figure 1 A schematic diagram of a flow chart of a ginseng leaf disease identification method provided by an embodiment of the present invention;

[0041] Figure 2 It is the position relationship diagram of SIoU loss function.

[0042] Figure 3 This is the structural diagram of the DyHead detection head.

[0043] Figure 4 This is the structure diagram of the improved YOLOv8 model.

[0044] Figure 5 It is a schematic diagram of the effect of identifying ginseng leaf diseases provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0045] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0046] like Figure 1 As shown, a ginseng leaf disease detection method based on an improved YOLOv8 model includes the following steps:

[0047] S1, obtaining a ginseng leaf disease dataset and preprocessing the dataset;

[0048] S2, expanding the ginseng leaf disease dataset to form a new dataset;

[0049] S3. Label different types of pests and diseases in the new data set and divide them into training sets and test sets for model training and verification respectively;

[0050] S4, input the training set into the improved YOLOv8 model for training iteration to obtain the best model file;

[0051] S5. Use the validation set to verify the model and output the test results.

[0052] S6. Deploy the training model to an Android phone, which can upload and identify ginseng leaf diseases in real time.

[0053] In the above, the ginseng leaf disease dataset in step S1 comes from some public datasets collected by Zuojia Campus of Jilin Agricultural Science and Technology College and searched on the Internet. Four types of ginseng leaves are selected by sorting multiple datasets, including black spot, damping-off, gray mold and health. After acquiring the data, data cleaning is performed to ensure image quality and remove incomplete or damaged images to ensure the quality of training data.

[0054] In step S2, data expansion is performed by translating and reversing the data set through Python language code. , adding noise, cropping and adding shadows to the dataset.

[0055] After expansion, the expanded dataset is combined with the initial dataset to form a new dataset.

[0056] In step S3, the open source software LabelImg is used to label different types of pests and diseases. The specific steps of labeling are as follows:

[0057] S31, using a rectangular box tool to mark the diseased part in the image, and labeling each rectangular box, the label corresponding to the type of the disease;

[0058] S32, each time annotation is performed, an annotation file in .XML format is generated, and the generated .XML file is converted into .txt format;

[0059] S33. Divide the dataset images and the corresponding txt format annotation files into training sets and test sets in a ratio of 8:2, which are used for subsequent model training and verification respectively.

[0060] In step S4, the improved YOLOv8 model uses YOLOv8 as the initial model, replaces the C2f module in the backbone of the original network with the C2faster lightweight module, adds the CBAM attention mechanism to the backbone, replaces the loss function of the original model with SIoU, and introduces the DyHead module in the head network.

[0061] Specifically, the C2f module in the original YOLOv8 backbone network consists of a standard convolution Conv and multiple Bottelneck blocks. The multiple Bottelneck blocks perform a large number of skip-layer connections and additional Split operations, which makes the network structure more complex and computationally intensive, making it unsuitable for the real-time detection of ginseng leaf diseases. To address this problem, the Split operation in the original C2f structure is removed and the redundant skip-layer connections are deleted. The Bottelneck block in C2f is then replaced with the Fasternet block. The C2f backbone network module is integrated with the Fasternet network to form a new C2faster module. Compared with the original C2f module, the improved C2faster module optimizes the detection speed and computational complexity without losing detection accuracy.

[0062] By adding the CBAM attention mechanism, the detection network can enhance the feature extraction capability of ginseng leaf diseases and reduce the impact of complex background on target feature extraction. CBAM is a lightweight convolutional attention module, including a channel attention module and a spatial attention module, which focus on channels and spaces respectively. It not only saves parameters and computing power, but also ensures that it can be integrated into the existing network architecture as a plug-and-play module. The channel attention module maintains the channel dimension, compresses the spatial dimension, and focuses on the significant feature information in the input image. The spatial attention module has a fixed spatial dimension, a compressed channel dimension, and focuses on the detection of target position information. The algorithm pays attention to both channel and spatial features at the same time, and has better performance.

[0063] If the input feature map of the network is: F∈R C×H×W , where F is the input feature map, R is a feature map with C channels, H height, and W width. This module will be based on the channel dimension ω c ∈R 1×1×C and the space dimension M S ∈R 1×H×W Infer the attention map, then multiply the attention map with the input feature map to adaptively refine the features. The calculation formula is: In the formula is element-wise multiplication, and F" is the final feature output.

[0064] The original loss function CIoU of YOLOv8 is replaced by SIoU loss function. YOLOv8 adopts anchor-free detection mechanism, and the loss function mainly includes two parts: target position regression loss CIoU Loss+DFL Loss and target category classification loss VFLLoss. However, since the intersection and intersection of CIoU only describes the relative relationship between the width or height of the predicted box and the true box, there is a certain ambiguity, and the balance problem of difficult and easy samples is not considered, which will lead to slow convergence speed and low model detection efficiency. This study introduces SIoU to replace CIoU as the regression loss function of the detection box. SIoU considers the vector angle between the true box and the predicted box and redefines the penalty index.

[0065] The angle loss considers the angle between the vectors of the predicted box and the real box, the distance loss considers the distance between the predicted box and the real box, the shape loss considers the shape difference between the predicted box and the real box, and the intersection loss calculates the intersection between the predicted box and the real box to evaluate the accuracy of the predicted box. Through these four loss functions, the robustness and accuracy of target detection can be effectively improved while avoiding overfitting.

[0066] The SIoU loss function is composed of four parts: angle loss Λ, distance loss Δ, shape loss Ω, and IoU loss. The SIoU loss function calculation formula is: Λ is the angle loss, Δ is the distance loss, Ω is the shape loss, B is the prediction box, B GT It’s a real frame.

[0067] The original detection head of YOLOv8 adopts the traditional single-scale prediction structure, which cannot handle multi-scale targets well, does not consider contextual information and lacks global vision. The prediction head has few parameters and limited expression ability. Here, the detection head is replaced with the DyHead detection head. The DyHead module unifies the scale-aware attention, space-aware attention and task-aware attention by using the self-attention mechanism. Among them, the three-dimensional feature tensor F∈R is given on the detection layer L×S×C, The attention calculation formula is: W(F)=π C (π S (π L (F)·F)·F)·F

[0068] Among them, F represents an input three-dimensional tensor L×S×C, π L , π S and πC They are scale-aware attention module, space-aware attention module and task-aware attention module, respectively. They only act on the L, S and C dimensions of the three-dimensional tensor F.

[0069] In step S4, the training set is input into the improved YOLOv8 model using GPU for training. Stochastic gradient descent is used as the optimizer. The learning rate is gradually reduced during the training process. The initial learning rate is set to 0.01 and the optimizer momentum is set to 0.937, which helps to maintain stable convergence during the optimization process. In order to allow the model enough time to adapt to the training data and improve performance, a total of 300 rounds of training iterations are performed. During the training process, the validation set can be used for performance evaluation to select the model with the best performance on the validation set.

[0070] For ginseng leaf diseases, the average precision (AP), recall (R), and mean average precision (mAP) values ​​were used to evaluate the model, and the mAP when the IoU was 0.5 was selected as the performance evaluation index for ginseng leaf disease recognition. The higher the value, the better the recognition effect of the improved model. The calculation formulas of AP, R, and mAP are as follows:

[0071] Where represents a positive sample and is correctly predicted, represents a positive sample but is incorrectly predicted, and represents a negative sample but is incorrectly predicted.

[0072] The trained improved model and the original model are verified using the validation set, and the accuracy, recall, average accuracy, model size, and computational complexity indicators are used to evaluate the detection effect of the improved model.

[0073] The comparison results of the improved YOLOv8 model and the original YOLOv8 model are shown in the following table:

[0074]

[0075] As shown in the above table, compared with the original YOLOv8 model, the improved YOLOv8 model has greatly improved accuracy, recall rate, average accuracy, etc., while the number of parameters and calculation amount are not much different, which effectively improves the recognition rate and accuracy of the target detection model.

[0076] In summary, the present invention not only increases the amount of data through data expansion, but also improves the diversity and quality of data. The model is lightweighted by replacing the C2f module, the backbone of the original network, with C2faster. By adding the CBAM attention mechanism, the detection network can increase the feature extraction ability of ginseng leaf diseases, replace the original loss function with the SIoU loss function, consider the vector angle between the real frame and the prediction frame, redefine the penalty index, and introduce the DyHead detection head to further improve the model's performance in identifying ginseng leaf diseases in different scales and complex backgrounds. Because the model is continuously optimized during the training process, the improvement of its recognition rate and accuracy of wheat diseases of different categories enables the model to better adapt to diversified data distribution, while maintaining a small model size and a faster detection rate, achieving performance improvement, which is particularly important for application scenarios that require real-time or near real-time detection.

[0077] Step S6 deploys the improved model to an Android phone, and the ginseng leaf disease picture can be uploaded directly through the Android phone in real time to identify the ginseng disease type and specific location.

[0078] Any matters not described in the present invention are applicable to the prior art.

[0079] It should be emphasized that the embodiments described in the present invention are illustrative rather than restrictive. Therefore, the present invention includes but is not limited to the embodiments described in the specific implementation manner. Any other implementation manners derived by those skilled in the art based on the technical solution of the present invention also fall within the scope of protection of the present invention.

Claims

1. A ginseng leaf disease identification method based on improved YOLOv8, characterized in that: The following steps are involved: S1, obtaining a ginseng leaf disease dataset and preprocessing the dataset; S2, using Python language code to expand the ginseng leaf disease dataset; S3. Label the human leaf disease dataset and divide it into a training set and a test set for model training and verification respectively; S4, putting the training set into the improved YOLOv8 model for iterative training to obtain the best model file; S5. Use the validation set to verify the model and output the test results. S6. Deploy the training model to an Android phone, which can upload and identify ginseng leaf diseases in real time.

2. According to claim 1, a ginseng leaf disease detection method based on an improved YOLOv8 model is used to prepare a ginseng leaf disease dataset, comprising the following steps: S21. Collect pictures of ginseng with different diseases. S22. Expand the dataset by scaling, translating, flipping, rotating, adding noise, and occluding. S23. Use the dataset annotation software LabelImg to annotate the dataset. S24. Divide the annotated data set and labels into training set and test set according to the required ratio.

3. According to claim 1, a ginseng leaf disease detection method based on an improved YOLOv8 model is characterized in that: In step S3, the open source software LabelImg is used to label different types of diseases. The specific steps of labeling are as follows: S31, using a rectangular box tool to mark the diseased part in the image, and labeling each rectangular box; S32, each time annotation is performed, an annotation file in .XML format is generated, and the generated .XML file is converted into .txt format; S33. The dataset images and the corresponding txt format annotation files are divided into training set and test set in a ratio of 8:2, which are used for subsequent model training and verification respectively.

4. According to claim 1, a ginseng leaf disease detection method based on an improved YOLOv8 model is characterized in that: In the step S4, the improved YOLOv8 model uses YOLOv8 as the initial model, replaces the C2f module of the backbone part of the original network with the C2faster module and adds the CBAM attention mechanism, replaces the loss function of the original model with SIoU, and introduces the DyHead module in the head network.

5. According to claim 4, a ginseng leaf disease detection method based on an improved YOLOv8 model is characterized in that: In step S4, all the original C2f modules are replaced with C2faster modules for lightweight processing, the Split operation in the original C2f structure is removed and redundant jump layer connections are deleted, and then the Bottelneck block in C2f is replaced with the Fasternet block, and the new C2faster module is formed by integrating the C2f backbone network module with the Fasternet network.

6. According to claim 5, a ginseng leaf disease detection method based on an improved YOLOv8 model is characterized in that: In the step S4, a CBAM attention mechanism is added to the backbone network part of the YOLOv8 model. The CBAM attention mechanism is added to the fourth and seventh layers of the original backbone network, combining the channel attention mechanism with the spatial attention mechanism to form a new convolutional block structure, thereby better performing feature fusion.

7. According to claim 6, a ginseng leaf disease detection method based on an improved YOLOv8 model is characterized in that: In step S4, the loss function in YOLOv8 is replaced by the SIoU loss function, and the loss function formula is: Where Λ is the angle loss, Δ is the distance loss, Ω is the shape loss, B is the predicted box, B GT It’s a real frame.

8. According to claim 7, a ginseng leaf disease detection method based on an improved YOLOv8 model is characterized in that: The step S4 introduces the DyHead detection head in the YOLOv8 head network. The DyHead module unifies the scale-aware attention, space-aware attention, and task-aware attention by utilizing the self-attention mechanism. The attention calculation formula is: W(F)=π C (p S (p L (F)·F)·F)·F Among them, F represents an input three-dimensional tensor L×S×C, π L , π S and π C They are scale-aware attention module, space-aware attention module and task-aware attention module.

9. The ginseng leaf disease detection method based on the improved YOLOv8 model according to claim 8, characterized in that: The improved YOLOv8 model is deployed on Android phones, which can upload ginseng leaf diseases in real time and identify and locate them.

Citation Information

Patent Citations

  • YOLOv8 target detection method based on attention mechanism and multi-scale feature fusion

    CN116883801A

  • Lightweight multi-environment tomato detection method based on improved yolov8

    CN117557787A

  • Wheat scab spore detection method based on YOLOv8 and CBAM attention mechanism

    CN117557995A

  • Rice disease and pest detection method and system based on improved YOLOv8

    CN117710820A

  • Bus driver driving behavior monitoring and early warning method, system and device

    CN118314560A

Cited By

  • Plant disease detection method based on deep learning

    CN119516282A

  • Offshore wind power blade defect detection method

    CN119722632A

  • A method for detecting defects in offshore wind turbine blades

    CN119722632B

  • Escherichia coli counting method and system based on YOLOv8-MCMCS architecture

    CN120318821A

  • A method and system for counting Escherichia coli based on YOLOv8-MCMCS architecture

    CN120318821B