Precision detection of crop diseases based on improved YOLOv5 model

Yun Zhao, Yuan Yang, Xing Xu, Cheng SunFrontiers in Plant Science 2023 · DOI

TL;DR

Researchers have developed an enhanced version of the YOLOv5s object detection model specifically optimized for the "small, dense, and similar" nature of crop diseases. By redesigning feature fusion structures and loss functions, the team achieved a 95.92% mAP at 40 FPS, significantly outperforming standard architectures in both accuracy and robustness.

What Problem Does This Paper Address?

Identifying crop diseases early is vital for global food security, but it’s a nightmare for standard computer vision models. Crop diseases often manifest as tiny spots (small targets), appear in clusters (dense numbers), or are hidden behind leaves (occlusions). Furthermore, different diseases often look remarkably similar to the untrained eye—and to standard algorithms.

While models like YOLOv5 are fast, they often struggle with these nuances. The authors identified that the standard feature fusion and bounding box prediction methods in YOLOv5s weren't precise enough for the high-stakes environment of precision agriculture, where a missed diagnosis or a false positive can lead to significant yield loss.

Methods

The authors introduced four primary architectural and mathematical improvements to the YOLOv5s baseline:

  1. Improved CSP Structure: They redesigned the Cross Stage Partial (CSP) structure in the "neck" of the network. By incorporating Ghost modules and inverted residuals, they created a more lightweight structure that extracts multi-branch feature information without ballooning the parameter count.
  2. The CAM Module: A novel Multiscale Channel Attention Module (CAM) was introduced. This "plug-and-play" module extracts global and local features separately and fuses them. This helps the network better handle "scale-inconsistent" features—essentially helping the model understand both the fine texture of a lesion and its broader context on a leaf.
  3. Enhanced Grid Prediction: Standard YOLOv5 uses three grids to predict a target. The authors added a fourth neighboring grid to increase the number of positive samples during training. They also modified the centroid offset formula to prevent the model from struggling when a target's center falls exactly on a grid boundary.
  4. Improved DIoU Loss: To fix issues where prediction boxes were scaled incorrectly during training, they swapped the standard GIoU loss for a modified Distance-IoU (DIoU) loss. Their version adds a penalty term based on the ratio of the prediction box width to the ground truth width, speeding up convergence.

Datasets

The study utilized the well-known PlantVillage public dataset.

  • Scope: 5 crops and 8 specific disease types (e.g., Apple Scab, Potato Late Blight, Grape Black Rot).
  • Preprocessing: 1,319 original images were manually annotated.
  • Augmentation: To prevent overfitting, they expanded the set to 4,079 images using Gaussian blurring, horizontal flips, and random rotation.
  • Mosaic Augmentation: They experimented with Mosaic data augmentation and found that using it for the first 40% of training rounds yielded the best results.

Key Insights and Ideas

  • Attention to Scale: The "aha moment" here is the realization that crop diseases aren't just small; they are semantically complex. The CAM module’s ability to bridge the gap between shallow (detailed) and deep (semantic) layers is what allows the model to distinguish between diseases that look visually similar.
  • Geometry over Raw Power: Instead of just making the network "deeper," the authors focused on the geometry of prediction. Adding a fourth grid and tweaking the sigmoid-based offset formula directly addresses the mathematical "dead zones" in the original YOLOv5 architecture.
  • Loss Function Stability: The improved DIoU loss demonstrates that accounting for the ratio of box dimensions (not just distance and overlap) prevents the model from "wrongly enlarging" prediction boxes, a common failure mode in small target detection.

Key Results

The improved model, dubbed "Improved-YOLOv5s," showed dominant performance across the board:

  • Accuracy: Achieved a 95.92% mAP, a 4.58% improvement over the baseline YOLOv5s.
  • Precision & Recall: Precision reached 94.15% and Recall hit 87.89%.
  • Speed: Maintained a detection speed of 40.01 FPS, comfortably meeting the requirements for real-time deployment on edge devices or agricultural robots.
  • Benchmarking: It outperformed Faster R-CNN (65.45% mAP), SSD (84.83%), YOLOv3, and YOLOv4.

Limitations and Future Work

While the results are impressive, the authors acknowledge a few areas for growth:

  • Real-world Conditions: The PlantVillage dataset is relatively "clean." Future work needs to test the model against the messy, variable lighting and complex backgrounds of actual field conditions.
  • Model Compression: While the improved model is efficient, the authors noted that using an even lighter backbone (like MobileNetv3) significantly reduced accuracy (dropping mAP to ~83%). Finding a "middle ground" that maintains 95%+ accuracy on ultra-low-power hardware remains a challenge.
  • Robotic Integration: The ultimate goal is deployment on autonomous picking or spraying robots, which will require further optimization for specific hardware constraints.

Summary updated

Abstract

Accurate identification of crop diseases can effectively improve crop yield. Most current crop diseases present small targets, dense numbers, occlusions and similar appearance of different diseases, and the current target detection algorithms are not effective in identifying similar crop diseases. Therefore, in this paper, an improved model based on YOLOv5s was proposed to improve the detection of crop diseases. First, the CSP structure of the original model in the feature fusion stage was improved, and a lightweight structure was used in the improved CSP structure to reduce the model parameters, while the feature information of different layers was extracted in the form of multiple branches. A structure named CAM was proposed, which can extract global and local features of each network layer separately, and the CAM structure can better fuse semantic and scale inconsistent features to enhance the extraction of global information of the network. In order to increase the number of positive samples in the model training process, one more grid was added to the original model with three grids to predict the target, and the formula for the prediction frame centroid offset was modified to obtain the better prediction frame centroid offset when the target centroid falled on the special point of the grid. To solve the problem of the prediction frame being scaled incorrectly during model training, an improved DIoU loss function was used to replace the GIoU loss function used in the original YOLOv5s. Finally, the improved model was trained using transfer learning, the results showed that the improved model had the best mean average precision (mAP) performance compared to the Faster R-CNN, SSD, YOLOv3, YOLOv4, YOLOv4-tiny, and YOLOv5s models, and the mAP, F1 score, and recall of the improved model were 95.92%, 0.91, and 87.89%, respectively. Compared with YOLOv5s, they improved by 4.58%, 5%, and 4.78%, respectively. The detection speed of the improved model was 40.01 FPS, which can meet the requirement of real-time detection. The results showed that the improved model outperformed the original model in several aspects, had stronger robustness and higher accuracy, and can provide better detection for crop diseases.
BibTeX
@inproceedings{zhao2023precision,
  author = {Yun Zhao and Yuan Yang and Xing Xu and Cheng Sun},
  title = {{Precision detection of crop diseases based on improved YOLOv5 model}},
  booktitle = {Frontiers in Plant Science},
  year = {2023},
  doi = {10.3389/fpls.2022.1066835},
}
Figure