Citrus leaf disease and insect pest identification method based on improved YOLOv8s model
By improving the YOLOv8s model, combining the ECAM attention mechanism and the C2f-Faster module, replacing the loss function, the problems of low pest detection accuracy and high computational complexity of citrus leaf diseases and diseases are solved, and more efficient pest identification is achieved.
Patent Information
- Application Number
- CN202411278815.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-12
- Publication Date
- 2025-01-03
AI Technical Summary
The existing citrus leaf pest detection algorithm has problems such as low detection accuracy, high calculation complexity and large model parameters.
Using the improved YOLOv8s model, an efficient ECAM attention mechanism and C2f-Faster module are designed, and the CIoU loss function is replaced as the Focal-EIoU loss function is improved to improve the detection accuracy of the model and reduce the computational complexity.
It achieves higher detection accuracy, less model parameters and reduces calculation complexity, improving the recognition efficiency of citrus leaf pests and diseases.
Smart Images

Figure CN119251814A_ABST
Abstract
Description
Technical Field
[0001] The invention provides a citrus leaf disease and insect pest identification method based on an improved YOLOv8s model, belonging to the technical field of disease and insect pest prevention and control. Background Art
[0002] Citrus is one of the most important economic products in the world. It is widely distributed all over the world and is currently the largest fruit tree in my country. Its output accounts for a quarter of the world's total fruit output. In recent years, my country's citrus production has continued to increase, bringing great economic benefits to fruit farmers, but also putting forward new requirements for the prevention and control of citrus diseases and pests.
[0003] In recent years, more and more inventors have studied the target detection methods of citrus pests and diseases. For example, Yu Yannan et al. (CN202410085480.X) invented a citrus pest classification method based on improved ShuffleNetV2, which provides a method for quickly and accurately identifying citrus pests in complex environments, and can improve the prevention and control efficiency of citrus pests and diseases; Sun Yaqi et al. (CN202210457915.X) invented a citrus fine-grained disease intelligent recognition method based on a dual-branch network with an attention mechanism, which achieves accurate segmentation and recognition of tiny lesions of citrus pests and diseases. However, these methods still have the problems of low detection accuracy, high computational complexity, and large number of model parameters for the fine features of pests and diseases. Summary of the invention
[0004] In view of the problems that the existing citrus leaf disease and pest detection algorithms have low detection accuracy, high computational complexity and large number of model parameters for small features of leaf diseases and pests, the present invention proposes a new citrus leaf disease and pest detection algorithm based on the YOLOv8s model. Compared with the existing algorithms, the proposed algorithm has higher detection accuracy, fewer parameters and reduces the computational complexity of the model.
[0005] This paper first designs an efficient ECAM (Efficient Channel Attention Module) attention mechanism to enhance the extraction of fine features of citrus leaf diseases and pests; secondly, it designs the C2f-Faster module to reduce the number of model parameters and model calculation complexity added by embedding the ECAM attention mechanism; finally, the Focal-EIoU loss function is used to replace the original CIoU loss function, which accelerates the model convergence and improves the recognition accuracy.
[0006] The specific technical solution is:
[0007] A method for identifying citrus leaf diseases and insect pests based on an improved YOLOv8s model comprises the following steps:
[0008] S1. Preprocess and enhance the data of citrus leaf pests and diseases images collected on site, and annotate them to create corresponding data sets. The specific steps are as follows:
[0009] S1.1. Collect pictures of typical citrus leaf diseases and insect pests on site, mainly collecting citrus leaves with anthracnose, bud and branch spot, ulcer and leaf miner;
[0010] S1.2, preprocessing mainly removes duplicate, blurred, similar images;
[0011] S1.3, data enhancement processing is performed on the collected original images by adding noise, changing brightness, cropping, translation, rotation, and mirroring to expand the number of original images;
[0012] S1.4. Use labelImg to label the processed images and create corresponding datasets based on the labeled images and label files.
[0013] S1.5. Divide the prepared data set into training set, validation set, and test set in a ratio of 8:1:1.
[0014] S2. Build an improved network model based on the YOLOv8s model. The model mainly includes the backbone part and the head part. The backbone part converts the raw data of the input training set into feature maps with different semantic features through downsampling. This part mainly includes the Conv module, C2f-Faster module and SPPF module. The head part processes the feature map information output by the backbone part through upsampling and feature fusion, outputs feature information, and finally uses the detection head to detect the output feature information. This part mainly includes the Upsample module and the ECAM module. The specific network model structure diagram is shown in the figure below. Figure 1 shown.
[0015] Furthermore, the backbone part uses the C2f-Faster module to replace the original C2f module; in addition to using the C2f-Faster module to replace the original C2f module, the head part also embeds the ECAM attention mechanism.
[0016] The ECAM attention mechanism is formed by connecting the ECA (Efficient Channel Attention) attention mechanism and the SAM (Spatial Attention Module) attention mechanism in series, and embedding the attention mechanism into the head network of YOLOv8s.
[0017] The C2f-Faster module replaces the Bottleneck module in the C2f module with a FasterBlock module.
[0018] The CIoU loss function in the original YOLOv8s model is replaced by the Focal-EIoU loss function, which explicitly measures the differences in three geometric factors in the bounding box, namely the overlapping area, the center point, and the side length. The calculation formula is as follows:
[0019] L Focal-EIoU =IoU γ L EIoU
[0020] Where γ is a hyperparameter for controlling outliers, L EIoU is the effective intersection-combination ratio loss. EIoU The calculation formula is as follows:
[0021]
[0022] The loss function is divided into three categories: IoU loss, distance loss L dis and azimuth loss L asp , where b, b gt is the center point of the predicted box and the real box, w,w gt is the width of the predicted box and the real box, h,h gt is the height of the predicted box and the real box, c is the diagonal distance of the minimum enclosing rectangle of the predicted box and the real box, c w ,c h Contains the width and height of the minimum bounding box of the predicted box and the true box, and ρ is the Euclidean distance.
[0023] S3. Combining the data set obtained in step S1 and step S2 and the constructed network model, set the corresponding hyperparameters and then perform training. The specific training steps are as follows:
[0024] S3.1. Use the training set as the input of the model and obtain the corresponding weight file by training the model;
[0025] S3.2. Use the obtained weight file to predict the validation set and obtain preliminary performance indicators;
[0026] S3.3, adjust the training hyperparameters according to the obtained indicators, and repeat the above steps until the optimal weight file is obtained;
[0027] S3.4. Use the optimal weight file to test and evaluate the model performance to verify the feasibility and effectiveness of the model.
[0028] S4. Use the trained network model to detect citrus leaf diseases and pests. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 This is a structural diagram of the improved YOLOv8s network model of the present invention;
[0030] Figure 2 The ECAM attention mechanism of the present invention;
[0031] Figure 3 This is a C2f-Faster module diagram of the present invention;
[0032] Figure 4 Implementation plan flow chart. DETAILED DESCRIPTION
[0033] The specific technical solution of the present invention is described in conjunction with the accompanying drawings.
[0034] The present invention proposes an improved model based on YOLOv8s. The overall network structure diagram of the improved model is as follows: Figure 1 As shown in the figure, the network structure mainly includes two parts: backbone and head, which are improved by C2f-Faster and ECAM modules. The backbone network uses C2f-Faster module to replace the original C2f module, which reduces the number of model parameters and speeds up the image information processing. In addition to using C2f-Faster module to replace the original C2f module, the head network also embeds the ECAM attention mechanism to enhance the model's ability to extract small features.
[0035] The present invention designs an efficient ECAM attention mechanism, which is a series connection of the ECA (Efficient Channel Attention) attention mechanism and the SAM (Spatial Attention Module) attention mechanism. Figure 2 As shown in the figure, embedding the attention mechanism into the head network of YOLOv8s can effectively extract the subtle features of citrus leaf diseases and pests, thereby improving the recognition accuracy.
[0036] The present invention designs a C2f-Faster module, such as Figure 3 This module replaces the Bottleneck module in the C2f module with the FasterBlock module. This module has smaller model parameters and computational complexity than the original module, and can also improve the computational speed of the model.
[0037] The CIoU loss function in the original model is replaced by the Focal-EIoU loss function, which explicitly measures the differences in three geometric factors in the bounding box, namely the overlapping area, the center point, and the side length. The calculation formula is as follows:
[0038] LFocal-EIoU =IoU γ L EIoU
[0039] Where γ is a hyperparameter for controlling outliers, L EIoU is the effective intersection-combination ratio loss. EIoU The calculation formula is as follows:
[0040]
[0041] The loss function is divided into three categories: IoU loss, distance loss L dis and azimuth loss L asp , where b, b gt is the center point of the predicted box and the real box, w,w gt is the width of the predicted box and the real box, h,h gt is the height of the predicted box and the real box, c is the diagonal distance of the minimum enclosing rectangle of the predicted box and the real box, c w ,c h Contains the width and height of the minimum bounding box of the predicted box and the true box, and ρ is the Euclidean distance. Focal-EIoU loss optimizes bounding box regression, making the regression process more focused on high-quality anchor boxes, improving the bounding box convergence speed, and optimizing the model detection performance.
[0042] First, the citrus leaf pest and disease images collected in the field were preprocessed and data augmented. Then, the processed images were annotated using labelImg annotation software. Then, the annotated training set images were input into the improved network model for training. Finally, the validation set was used to evaluate the model performance and verify the effectiveness and feasibility of the model. The overall experimental scheme flow chart is shown below: Figure 4 The specific experimental steps are as follows:
[0043] S1. Preprocess and enhance the data of the citrus leaf pests and diseases images collected on site, and annotate them to create the corresponding data set. The specific steps are as follows:
[0044] a) Collecting pictures of typical citrus leaf diseases and insect pests on site, mainly collecting citrus leaves with anthracnose, bud and branch spot disease, ulcer disease, and leaf miner disease;
[0045] b) Preprocessing mainly involves removing duplicate, blurred, and similar images;
[0046] c) Perform data enhancement processing on the collected original images by adding noise, changing brightness, cropping, translating, rotating, and mirroring to expand the number of original images;
[0047] d) Use the labelImg annotation tool to annotate the processed images and create corresponding data sets based on the annotated images and label files;
[0048] e) Divide the prepared data set into training set, validation set, and test set in a ratio of 8:1:1.
[0049] S2. Build an improved network model. The model mainly includes the backbone part and the head part. The backbone part converts the raw data of the input training set into feature maps with different semantic features through downsampling. This part mainly includes the Conv module, C2f-Faster module and SPPF module. The head part processes the feature map information output by the backbone part through upsampling and feature fusion, outputs feature information, and finally uses the detection head to detect the output feature information. This part mainly includes the Upsample module and the ECAM module. The specific network model structure diagram is shown in the figure. Figure 1 shown.
[0050] S3. Combining the data set obtained in step S1 and step S2 and the constructed network model, set the corresponding hyperparameters and then perform training. The specific training steps are as follows:
[0051] a) Take the training set as the input of the model and obtain the corresponding weight file by training the model;
[0052] b) Use the obtained weight file to predict the validation set and obtain preliminary performance indicators;
[0053] c) Adjust the training hyperparameters according to the obtained indicators, and repeat the above steps until the optimal weight file is obtained; d) Use the optimal weight file to test and evaluate the model performance to verify the feasibility and effectiveness of the model. S4. Use the trained network model to detect citrus leaf diseases and insect pests.
Claims
1. A method for identifying citrus leaf diseases and insect pests based on an improved YOLOv8s model, characterized in that: The following steps are involved: S1. Preprocess and enhance the data of citrus leaf pests and diseases images collected on site, and annotate them to create corresponding data sets; S2. Build an improved network model based on the YOLOv8s model; the model includes a backbone part and a head part; The backbone part converts the raw data of the input training set into feature maps with different semantic features through downsampling. This part includes the Conv module, C2f-Faster module, and SPPF module. The head part processes the feature map information output by the backbone part through upsampling and feature fusion, outputs feature information, and finally uses the detection head to detect the output feature information. This part includes the Upsample module and the ECAM module; S3, combining the data set obtained in step S1 and step S2 and the constructed network model, setting corresponding hyperparameters and then performing training; S4. Use the trained network model to detect citrus leaf diseases and pests.
2. According to claim 1, a method for identifying citrus leaf diseases and insect pests based on an improved YOLOv8s model, characterized in that: S1 specifically includes the following sub-steps: S1.
1. Collect pictures of typical citrus leaf diseases and insect pests on site, and collect citrus leaves infected with anthracnose, bud and branch spot, canker, and leaf miner; S1.2, preprocessing, elimination of repeated, blurred, and similar images; S1.3, perform data enhancement processing on the collected original images by adding noise, changing brightness, cropping, translating, rotating, and mirroring to expand the number of original images; S1.
4. Use labelImg to label the processed images and create corresponding datasets based on the labeled images and label files. S1.
5. Divide the prepared data set into training set, validation set, and test set in a ratio of 8:1:
1.
3. The method for identifying citrus leaf diseases and insect pests based on the improved YOLOv8s model according to claim 1, characterized in that: In S2, an improved network model is constructed, and the backbone part uses the C2f-Faster module to replace the original C2f module; In addition to using the C2f-Faster module to replace the original C2f module, the head part also embeds the ECAM attention mechanism; The ECAM attention mechanism is formed by connecting the ECA attention mechanism and the SAM attention mechanism in series, and the attention mechanism is embedded into the head network of YOLOv8s; The C2f-Faster module is to replace the Bottleneck module in the C2f module with the FasterBlock module; The CIoU loss function in the original YOLOv8s model is replaced by the Focal-EIoU loss function, which explicitly measures the differences in three geometric factors in the bounding box, namely the overlapping area, the center point, and the side length. The calculation formula is as follows: L Focal-EIoU =IoU γ L EIoU Where γ is a hyperparameter for controlling outliers, L EIoU is the effective intersection-combination ratio loss; L EIoU The calculation formula is as follows: The loss function is divided into three categories: IoU loss, distance loss L dis and azimuth loss L asp , where b, b gt is the center point of the predicted box and the real box, w,w gt is the width of the predicted box and the real box, h,h gt is the height of the predicted box and the real box, c is the diagonal distance of the minimum enclosing rectangle of the predicted box and the real box, c w ,c h Contains the width and height of the minimum bounding box of the predicted box and the true box, and ρ is the Euclidean distance.
4. The method for identifying citrus leaf diseases and insect pests based on the improved YOLOv8s model according to claim 1, characterized in that: The specific training steps in S3 are as follows: S3.
1. Use the training set as the input of the model and obtain the corresponding weight file by training the model; S3.
2. Use the obtained weight file to predict the validation set and obtain preliminary performance indicators; S3.3, adjust the training hyperparameters according to the obtained indicators, and repeat the above steps until the optimal weight file is obtained; S3.
4. Use the optimal weight file to test and evaluate the model performance to verify the feasibility and effectiveness of the model.
Citation Information
Cited By
Tea garden intelligent precise pesticide spraying system and pesticide spraying method based on machine vision
CN120266828A
Tea garden intelligent precision spraying system and spraying method based on machine vision
CN120266828B
Bee identification method and system based on improved YOLOv8 model
CN121281100A
