Detection of Farmland Obstacles Based on an Improved YOLOv5s Algorithm by Using CIoU and Anchor Box Scale Clustering

Jinlin Xue, Feng Cheng, Yuqing Li, Yue Song, Tingting Mao2022 · DOI

TL;DR

This paper tackles the critical challenge of real-time, accurate obstacle detection for agricultural robots in complex farmland environments. They propose an improved YOLOv5s model that leverages K-Means clustering for optimized anchor boxes and CIoU Loss for enhanced detection accuracy, achieving a significant speedup and improved performance over existing methods.

What Problem Does This Paper Address?

Unmanned agricultural vehicles need to navigate diverse and dynamic farmland environments, which are often cluttered with various obstacles like people, machinery, trees, and even livestock. Existing obstacle detection methods, while effective in controlled environments, struggle with the complexity and variability of farmland. Traditional approaches like SVMs often fail to identify and classify obstacles, while deep learning models like Faster R-CNN, though accurate, are too computationally expensive for real-time deployment on resource-constrained agricultural robots. YOLOv5s offers a good speed-accuracy trade-off, but its accuracy, especially for small or varied obstacles, needs improvement. This paper aims to bridge this gap by enhancing YOLOv5s for robust and efficient farmland obstacle detection.

Methods

The authors propose an improved YOLOv5s architecture with two key modifications:

  • K-Means Clustering for Anchor Box Optimization: Instead of relying on default anchor boxes derived from the COCO dataset, they use K-Means clustering on their farmland obstacle dataset. This customizes the anchor box scales to better fit the specific shapes and sizes of farmland obstacles, which can differ significantly from general object datasets. This optimization aims to speed up model training and inference by providing more relevant initial guesses for object localization.
  • CIoU Loss Function: The original YOLOv5s uses GIoU Loss. This paper replaces it with CIoU (Complete Intersection over Union) Loss. CIoU Loss is a more sophisticated bounding box regression loss that considers not only the overlap area and center point distance but also the aspect ratio consistency between the predicted and ground-truth bounding boxes. This comprehensive approach helps to reduce missed detections and false positives, particularly for small targets.

Datasets

The study utilizes a custom dataset created for farmland obstacle detection. This dataset comprises:

  • 2370 images collected from farmland using a mobile phone and the internet.
  • These images contain 8 types of common farmland obstacles: people, tractors, haystacks, wire poles, trees, houses, sheep, and cattle.
  • The dataset was split into training (80%) and testing (20%) sets.
  • Data augmentation techniques, including random brightness, rotation, Gaussian noise, rainy processing, and atomization processing, were applied to expand the training set to 14,220 images, addressing the issue of small sample sizes and simulating various environmental conditions.

Key Insights and Ideas

  • Anchor boxes matter, especially for specific domains: The K-Means clustering approach highlights that generic anchor boxes are suboptimal for specialized tasks like farmland obstacle detection. Tailoring anchor boxes to the dataset's characteristics can significantly improve model efficiency.
  • CIoU Loss is a powerful tool for improving detection accuracy: The adoption of CIoU Loss demonstrably reduces missed and false detections, particularly for small targets, by incorporating more geometric information into the bounding box regression.
  • Speed vs. Accuracy Trade-off is Manageable: While Faster R-CNN offers higher accuracy, its computational cost is prohibitive. The improved YOLOv5s strikes a better balance, achieving comparable accuracy to Faster R-CNN on some metrics while being significantly faster.

Key Results

  • Inference Speed: The improved YOLOv5s achieved an inference time of 0.074 seconds per image, which is approximately 75% faster than Faster R-CNN (0.274 seconds).
  • Accuracy (mAP):
    • The improved YOLOv5s achieved a mean Average Precision (mAP) of 65.12%, an improvement of 5.80% over the original YOLOv5s (59.32%).
  • The mAP of the improved YOLOv5s (65.12%) was slightly lower than Faster R-CNN (66.76%) by 1.64%, but it significantly outperformed the original YOLOv5s.
  • Qualitative Improvements: Visual comparisons showed that the improved YOLOv5s was better at detecting small target obstacles and reduced instances of missed and false detections compared to both the original YOLOv5s and Faster R-CNN in certain scenarios.

Limitations and Future Work

  • Dataset Size: The authors acknowledge that while data augmentation was used, establishing a more adequate farmland obstacle dataset in future research would be beneficial for training even better detection models.
  • Generalizability: While the model performs well on its custom dataset, further validation on diverse farmland environments and obstacle types would be valuable.
  • Future Work: The authors suggest that the improved YOLOv5s, due to its small weight file, is well-suited for deployment on unmanned agricultural machinery. Future research should focus on building more comprehensive datasets to further enhance the model's performance.

Summary updated

BibTeX
@misc{xue2022detection,
  author = {Jinlin Xue and Feng Cheng and Yuqing Li and Yue Song and Tingting Mao},
  title = {{Detection of Farmland Obstacles Based on an Improved YOLOv5s Algorithm by Using CIoU and Anchor Box Scale Clustering}},
  year = {2022},
  doi = {10.3390/s22051790},
}
Figure