Peanut disease detection method and system based on improved Yolov8

By introducing the attention mechanism into the Yolov8 model, the problem of peanut leaf spot disease being difficult to identify in complex scenes is solved, efficient and accurate disease detection is achieved, real-time diagnostic support is provided, costs are reduced and efficiency is improved.

CN118608941APending Publication Date: 2024-09-06QINGDAO AGRI UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410638978.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-22
Publication Date
2024-09-06

AI Technical Summary

Technical Problem

It is difficult to effectively diagnose and monitor peanut leaf spot disease early and efficiently with existing technology, especially in accurately identifying the disease in complex scenarios, which affects peanut yield and health.

Method used

Based on the Yolov8 model, the attention mechanism model (EMA attention module) is introduced for peanut disease detection. Through data collection, preprocessing, model training and deployment, real-time detection is achieved by combining the Raspberry Pi and camera to enhance the model's ability to handle complex scenes. .

Benefits of technology

The accuracy and robustness of peanut disease detection are improved, and diseases can be accurately identified in complex peanut fields, providing real-time diagnostic support, reducing costs and improving efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118608941A
    Figure CN118608941A
Patent Text Reader

Abstract

The invention discloses a peanut disease detection method and system based on improved Yolov8, and belongs to the technical field of intelligent agriculture, and the method comprises the steps: data collection: collecting a peanut image; data preprocessing: preprocessing the peanut image; model training: by respectively adding EMA attention modules on feature maps of P3, P4 and P5 branches of YOLOv8, constructing a YOLOv8-EMA model to train the peanut image, and in the training process, using a sick peanut image as a positive sample and a healthy peanut image as a negative sample; model evaluation: evaluating the trained YOLOv8-EMA model by calculating the accuracy, recall rate and precision of the model; and system deployment: transferring the trained weight file into the Raspberry Pi, and connecting the Raspberry Pi with a camera to detect the diseases of the peanuts in real time. According to the invention, diseases can be accurately detected in a complex peanut field, and technical support is provided for prevention and treatment of peanut diseases.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of smart agricultural technology, and in particular to a peanut disease detection method and system based on improved Yolov8. Background Art

[0002] Peanut (scientific name: Arachis hypogaea) is a leguminous plant belonging to the genus Arachis, native to South America. Its fruit is actually an underground pod, and the seed is peanut. Peanut is a nutritious food, rich in protein, fat, vitamins and minerals, and is widely used as one of the oil and food crops. However, peanut leaf spot disease poses a serious threat to the health and yield of peanut plants. Peanut leaf spot disease is a general term for brown spot disease, black spot disease, web spot disease and scorch spot disease, and is one of the most common and most harmful diseases in peanut production. These diseases form lesions on the leaves, causing the leaves to die and fall off, seriously affecting the photosynthesis of the leaves and even infecting the petioles and stems. With the different degrees of disease, the coverage and size of the peanut leaf spot disease will also change significantly. In order to detect the disease of peanut leaf spot disease in real time, it is necessary to identify the characteristics of the size of the lesions at different times. This experiment focuses on the detection of brown spot disease in peanut leaf spot disease, which is also the most rampant disease among leaf spot diseases and often has the greatest impact on peanuts. Brown spot disease usually manifests itself as brown spots of varying sizes distributed on the surface of peanut leaves. Depending on the severity of the disease, the size and area of ​​the spots will also vary significantly.

[0003] The characteristics of peanut brown spot disease are brown spots distributed on the leaves of peanuts. The disease characteristics at different stages are related and different. With the continuous development of artificial intelligence, computer vision technology is widely used in various fields. Classification research through image processing methods has achieved good results. Therefore, in order to diagnose and monitor peanut brown spot disease early and efficiently, it is urgent to design an artificial intelligence method to realize the recognition of peanut brown spot disease. Summary of the invention

[0004] In order to achieve early diagnosis and efficient monitoring of peanut leaf spot, the purpose of the present invention is to propose an improved peanut disease detection technology based on the Yolov8 model. By introducing the attention mechanism model, the long-term dependencies and sequence information in the input data can be better captured, the computational burden can be reduced, and the efficiency of the model can be improved, thereby improving the processing effect of complex scenes, thereby ensuring that the technology can accurately detect diseases in complex peanut fields and provide technical support for the prevention and control of peanut diseases.

[0005] In order to achieve the above technical objectives, the present application provides a peanut disease detection method based on improved Yolov8, comprising the following steps:

[0006] Data collection: Collect peanut images, including healthy peanut images and diseased peanut images;

[0007] Data preprocessing: Preprocess peanut images, including image scaling, cropping, and enhancement;

[0008] Model training: By adding EMA attention modules to the feature maps of the P3, P4, and P5 branches of YOLOv8, a YOLOv8-EMA model was constructed to train peanut images. During the training process, diseased peanut images were used as positive samples and healthy peanut images were used as negative samples.

[0009] Model evaluation: Evaluate the trained YOLOv8-EMA model by calculating the model's precision, recall, and AP.

[0010] System deployment: Transfer the trained weight file to the Raspberry Pi, and connect the camera to the Raspberry Pi to perform real-time detection of peanut diseases.

[0011] Preferably, during the data preprocessing process, a computer is used to simulate the human visual attention mechanism to perform visual saliency detection on the peanut image, so as to overcome the situation where the underlying diseases cannot be identified due to severe occlusion of peanut leaf diseases.

[0012] Preferably, in the process of performing visual saliency detection on the peanut image, the attention heat map and focus map of the peanut image are drawn through AttentionInsight, and the peanut virus disease area is identified according to the salient parts in the image and manually labeled through LabelImg.

[0013] Preferably, in the process of performing data preprocessing, the training set is enriched by randomly rotating the original image by 10°, 30°, and 45° and adding Gaussian noise, and is divided into a training set, a validation set, and a test set in a ratio of 8:1:1.

[0014] Preferably, during the model training process, the channel attention weights are learned through the EMA attention module to enhance the perception and attention of the YOLOv8 model to the target features, thereby improving the accuracy and robustness of target detection.

[0015] Preferably, in the process of building the YOLOv8-EMA model, the EMA attention module consists of three parallel paths, two of which are on the 1×1 branch and the third on the 3×3 branch; the 1×1 branch uses two 1D global average pooling operations to encode channel information in the input tensor, and the 3×3 branch uses 3×3 convolution to capture multi-scale feature representation.

[0016] Preferably, in the process of model evaluation, the precision is used to indicate how many of the positive examples predicted by the model are true positive examples, expressed as:

[0017] Precision=TP / (TP+FP)

[0018] In the formula, TP is a true positive example and FP is a false positive example.

[0019] Preferably, in the process of model evaluation, the recall rate Recall is used to indicate how many of the real positive examples are successfully predicted as positive examples by the model, which is expressed as:

[0020]

[0021] Where FN is the false negative example.

[0022] Preferably, in the process of evaluating the model, the performance of the model on different categories is comprehensively evaluated by precision AP, wherein the precision AP is obtained by integrating the Precision-Recall curve and averaging all categories.

[0023] The present invention discloses a peanut disease detection system based on improved Yolov8, comprising:

[0024] A data collection module, used for collecting peanut images, including healthy peanut images and diseased peanut images;

[0025] Data preprocessing module, used to preprocess peanut images, including image scaling, cropping and enhancement;

[0026] The model training module is used to build a YOLOv8-EMA model to train peanut images by adding EMA attention modules to the feature maps of the P3, P4, and P5 branches of YOLOv8. During the training process, diseased peanut images are used as positive samples and healthy peanut images are used as negative samples;

[0027] The model evaluation module is used to evaluate the trained YOLOv8-EMA model by calculating the model's precision, recall, and AP.

[0028] The system deployment module is used to transfer the trained weight file to the Raspberry Pi, and connect the camera to the Raspberry Pi to perform real-time detection of peanut diseases.

[0029] The present invention discloses the following technical effects:

[0030] 1. High accuracy: The data set is personally shot and has high authenticity and reliability;

[0031] 2. Model structure improvement: The improved YOLOV8-EMA model is used, and the training is combined with the characteristics of peanut diseases, which can effectively improve the recognition accuracy. Data enhancement technology is used to expand the data set and enhance the model's robustness to factors such as lighting conditions and image blur;

[0032] 3. Strong practicality: This technology can identify peanut diseases in real time and provide peanut growers with effective disease prevention and control measures.

[0033] This technology has low cost and high efficiency and is easy to promote and apply. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0035] Figure 1 It is a schematic diagram of the EMA structure of the present invention;

[0036] Figure 2 It is a schematic diagram of the YOLOV8-EMA model described in the present invention. Figure 3 It is a schematic diagram of the method flow of the present invention. DETAILED DESCRIPTION

[0037] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

[0038] like Figure 1-3As shown in the figure, in order to identify peanut diseases in real time, this study proposed an improved peanut brown spot disease detection model Yolov8-EMA model based on the Yolov8 model. By introducing the EMA (Efficient Multi-Scale Attention Module with Cross-Spatial Learning) attention mechanism, the channel or spatial attention mechanism has significant effectiveness in generating more recognizable feature representations. The feature expression in YOLOv8 may be insufficient, especially when dealing with complex scenes or small targets. By reconstructing channel and grouping features, richer and more useful feature expressions can be provided, which helps the model to better understand the image content. However, modeling cross-channel relationships through channel dimensionality reduction may have side effects on extracting deep visual representations. The model can better capture long-term dependencies and sequence information in the input data, thereby improving the processing effect of complex scenes. In order to retain the information on each channel and reduce computational overhead, the present invention reconstructs part of the channels into batch dimensions and groups the channel dimensions into multiple sub-features so that the spatial semantic features are evenly distributed in each feature group. This enables the model to accurately detect diseases in complex peanut fields and identify the changing characteristics of peanut leaf spot at different stages, improving the accuracy and timeliness of detection, and enabling real-time detection of peanut diseases, providing effective assistance and data analysis for subsequent peanut disease prevention and control and pesticide spraying.

[0039] In order to achieve early diagnosis and efficient monitoring of peanut leaf spot disease, this paper proposes an improved peanut disease detection model based on the Yolov8 model. By introducing the attention mechanism model, the long-term dependencies and sequence information in the input data can be better captured, the computational burden can be reduced, and the efficiency of the model can be improved, thereby improving the processing effect of complex scenes. This enables the model to accurately detect diseases in complex peanut fields and provide technical support for the prevention and control of peanut diseases, which specifically includes the following contents:

[0040] 1. Data collection: Collect peanut images, including healthy peanut images and diseased peanut images.

[0041] 2. Data preprocessing: Preprocess the collected peanut images, including image scaling, cropping, enhancement, etc.

[0042] 3. Model training: Use the YOLOv8-EMA model to train peanut images. During the training process, diseased peanut images are used as positive samples and healthy peanut images are used as negative samples.

[0043] 4. Model evaluation: Evaluate the trained YOLOv8-EMA model and calculate the model's accuracy, recall, F1 value and other indicators

[0044] 5. System deployment: Transfer the trained weight file to the Raspberry Pi. By connecting the Raspberry Pi to a camera, real-time detection of peanut diseases can be performed.

[0045] Specifically: 1. Collection of data sets:

[0046] The dataset used in the present invention contains 480 images of peanut brown spot disease, including peanut leaves with different degrees of brown spot disease, healthy peanut leaves, and background images. The image pixel size is 3024×4032. In order to ensure the uniformity of the shooting angle, the camera is vertically photographed at 90° to the peanut leaves, and the distance between the camera and the leaves is 15 cm.

[0047] 2. Data processing:

[0048] Peanut leaf diseases are severely occluded, and the underlying diseases in a picture cannot be clearly photographed due to the focal length problem. Here, visual saliency detection is performed on the image. Visual image saliency detection uses computers to simulate the human visual attention mechanism and calculate the importance of each part of the information in the picture. It has been widely used in image segmentation, video compression, target detection, image indexing and other fields, and has important research value.

[0049] Here, the present invention uses Attention Insight (an algorithm for attention prediction) to develop integrated software to draw attention heat maps and focus maps. According to the attention heat maps and focus maps, the peanut virus disease areas in the significant parts of the image are manually labeled using the labeling software LabelImg.

[0050] 3. Model training:

[0051] 3.1 Data Enhancement:

[0052] Given the limited data in the current training set, in order to expand the number of samples, the original image is randomly rotated by 10°, 30°, and 45° as shown in the figure, and Gaussian noise is added to enrich the training set as shown in the figure below. Figure 2 As shown in the figure, the number of images is expanded from 480 to 1443 to improve the generalization ability of the model. It is divided into training set, validation set and test set in a ratio of 8:1:1. When performing deep learning training, if the number of training samples is too small, it is easy to cause overfitting problems, that is, the model over-fits the training set data, thereby reducing the performance on new data.

[0053] 3.2 Model structure adjustment:

[0054] This experiment selects YOLOv8n as the baseline model. The YOLOv8n model has low parameters and fast detection speed. Considering the demand for real-time monitoring in agricultural production practice, especially in the field of crop disease detection, a balance must be struck between detection accuracy and speed. Combined with the actual needs of agricultural production, the YOLOv8n version has become a wise choice. It can maintain an acceptable detection time while ensuring a relatively satisfactory detection accuracy, making it very suitable for real-time monitoring of crop diseases. In order to improve the target detection accuracy of the YOLOv8 model, the present invention adopts an improved algorithm based on EMA attention. The algorithm adds EMA attention modules to the feature maps of the P3, P4 and P5 branches of YOLOv8 respectively.

[0055] The EMA attention module can learn channel attention weights, enhance the model's perception and attention to target features, and thus improve the accuracy and robustness of target detection. Experimental results show that this method improves the mAP of the YOLOv8 model by 4% on the COCO2017 dataset.

[0056] Specifically, the EMA attention module consists of three parallel paths, two of which are on the 1×1 branch and the third on the 3×3 branch. The 1×1 branch uses two 1D global average pooling operations to encode channel information in the input tensor, and the 3×3 branch uses 3×3 convolutions to capture multi-scale feature representations.

[0057] The channel attention mechanism can learn the dependencies between different channels and give higher weights to important channels. The EMA attention module can effectively aggregate the interaction features between different channels through the channel attention mechanism, while improving the model efficiency and maintaining good object detection performance.

[0058] In addition, the EMA attention module adopts feature grouping and multi-scale structure, which can extract richer feature information and enhance the robustness of the model to the target. Experimental results show that this method has achieved significant improvement in small target detection.

[0059] In summary, the YOLOv8 target detection algorithm based on EMA attention proposed in this paper can effectively improve the target detection accuracy and has good robustness.

[0060] The initial learning rate of the model of the present invention is set to 0.01, the number of training rounds is 500, the batch-size is 8, the weight decay coefficient is 0.005, and the size of the image input is 640 pixels × 640 pixels.

[0061] 4. Model evaluation:

[0062] The indicators for evaluating model performance usually include the following:

[0063] Precision: Precision indicates how many of the positive examples predicted by the model are true positive examples. It is calculated by dividing the number of true positives (TP) by the sum of true positives and false positives (FP).

[0064] Precision = TP / (TP+FP).

[0065] Recall: Recall indicates how many true positive examples are successfully predicted as positive by the model. It is calculated by dividing the true positive examples by the sum of the true positive examples and the false negative examples (FN).

[0066]

[0067] mAP: reflects the average recognition accuracy of all categories. mAP@0.5 represents the average accuracy at an IoU threshold of 0.5.

[0068]

[0069]

[0070] C is the total number of image categories, where i is the number of detections. AP is the average recognition accuracy AP@0.5 of a single category, which represents the area under the PR curve of that category. The average recognition accuracy AP@0.5 of all categories is added together and the average is taken to get mAP@0.5

[0071] 5. System deployment:

[0072] The trained data is stored in the pt weight file. The weight file is converted into a file format supported by the onnx Raspberry Pi Linux system. The file is stored in the Raspberry Pi and connected to a camera to perform real-time detection of peanut leaf spot disease.

[0073] It has been verified through experiments that the disease images of peanut leaf spot can be effectively identified, and the identified results can be used to effectively identify peanut leaf spot for spraying and management of pesticides. In addition, the present invention can also expand the data set to identify images of various diseases, with different disease characteristics as the main distinguishing points, and the present invention can also combine the Internet of Things, cloud computing and other technologies to establish a real-time monitoring and early warning system, and seamlessly integrate with intelligent devices such as robots and drones to automatically realize monitoring and processing.

[0074] The YOLOv8-EMA algorithm proposed in the present invention has significant effectiveness in generating more recognizable feature representations in various computer vision tasks through channel or spatial attention mechanisms. It can effectively capture the correlation between multi-scale features and introduce cross-space learning, which helps to improve the accuracy of target detection. By introducing more contextual information, the model can better understand the objects in the image and reduce missed detections and false detections. In the comparative ablation experiment, YOLOv8, YOLOv8-GAM and YOLOv8-EMA were used to train the model on the dataset of peanut brown spot disease. The experiment showed that the mAP0.5 and mAP0.5:0.95 of YOLOv8-EMA were significantly improved.

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

[0076] In the description of the present invention, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.

[0077] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. A peanut disease detection method based on improved Yolov8, characterized in that: The following steps are involved: Data collection: Collect peanut images, including healthy peanut images and diseased peanut images; Data preprocessing: preprocessing the peanut image, including image scaling, cropping and enhancement; Model training: By adding EMA attention modules to the feature maps of the P3, P4, and P5 branches of YOLOv8, a YOLOv8-EMA model was constructed to train peanut images. During the training process, diseased peanut images were used as positive samples and healthy peanut images were used as negative samples. Model evaluation: Evaluate the trained YOLOv8-EMA model by calculating the model's precision, recall, and AP. System deployment: Transfer the trained weight file to the Raspberry Pi, and connect the camera to the Raspberry Pi to perform real-time detection of peanut diseases.

2. A peanut disease detection method based on improved Yolov8 according to claim 1, characterized in that: In the process of data preprocessing, computers are used to simulate the human visual attention mechanism and perform visual saliency detection on peanut images to overcome the situation where the underlying diseases cannot be identified due to severe occlusion of peanut leaf diseases.

3. A peanut disease detection method based on improved Yolov8 according to claim 2, characterized in that: In the process of visual saliency detection of peanut images, the attention heat map and focus map of the peanut image are drawn through AttentionInsight, and the peanut virus disease area is identified according to the salient parts in the image and manually labeled through LabelImg.

4. A peanut disease detection method based on improved Yolov8 according to claim 3, characterized in that: In the process of data preprocessing, the original image is randomly rotated by 10°, 30°, and 45° and Gaussian noise is added to enrich the training set, and then divided into training set, validation set, and test set in a ratio of 8:1:

1.

5. A peanut disease detection method based on improved Yolov8 according to claim 4, characterized in that: During the model training process, the channel attention weights are learned through the EMA attention module to enhance the YOLOv8 model's perception and attention to target features, thereby improving the accuracy and robustness of target detection.

6. A peanut disease detection method based on improved Yolov8 according to claim 5, characterized in that: In the process of building the YOLOv8-EMA model, the EMA attention module consists of three parallel paths, two of which are on the 1×1 branch and the third on the 3×3 branch; the 1×1 branch uses two 1D global average pooling operations to encode the channel information in the input tensor, and the 3×3 branch uses 3×3 convolution to capture multi-scale feature representation.

7. A peanut disease detection method based on improved Yolov8 according to claim 6, characterized in that: In the process of model evaluation, the precision is used to indicate how many of the positive examples predicted by the model are true positive examples, expressed as: Precision=TP / (TP+FP) In the formula, TP is a true positive example and FP is a false positive example.

8. A peanut disease detection method based on improved Yolov8 according to claim 7, characterized in that: In the process of model evaluation, the recall rate Recall indicates how many of the real positive examples are successfully predicted as positive examples by the model, expressed as: Where FN is the false negative example.

9. A peanut disease detection method based on improved Yolov8 according to claim 8, characterized in that: During the model evaluation process, the performance of the model in different categories is comprehensively evaluated through precision AP, where precision AP is obtained by integrating the Precision-Recall curve and averaging all categories.

10. A peanut disease detection system based on improved Yolov8, characterized in that: include: A data collection module, used for collecting peanut images, including healthy peanut images and diseased peanut images; A data preprocessing module, used for preprocessing the peanut image, including image scaling, cropping and enhancement; The model training module is used to build a YOLOv8-EMA model to train peanut images by adding EMA attention modules to the feature maps of the P3, P4, and P5 branches of YOLOv8. During the training process, diseased peanut images are used as positive samples and healthy peanut images are used as negative samples. The model evaluation module is used to evaluate the trained YOLOv8-EMA model by calculating the model's precision, recall, and AP. The system deployment module is used to transfer the trained weight file to the Raspberry Pi, and connect the camera to the Raspberry Pi to perform real-time detection of peanut diseases.