TL;DR
This paper introduces YOLOv7-Peach, an improved YOLOv7 model specifically designed for detecting small, immature yellow peaches in complex natural environments. By incorporating anchor redesign, a coordinate attention module, and a modified detection head, the model significantly enhances detection accuracy and recall, addressing the challenges posed by similar colors to foliage and small sizes.
What Problem Does This Paper Address?
Intelligent orchard management relies heavily on accurately identifying and counting fruits, especially at early stages. For yellow peaches, this is crucial for tasks like fruit thinning and yield estimation. However, detecting immature yellow peaches presents a significant challenge. These fruits are often small, easily obscured by leaves, and their green color makes them difficult to distinguish from the surrounding foliage. Traditional manual inspection is labor-intensive and prone to errors. Existing object detection models, while powerful, struggle with these specific challenges, leading to missed detections and low accuracy in complex natural settings. This paper aims to bridge this gap by developing a robust and accurate detection algorithm for immature yellow peaches.
Methods
The authors build upon the YOLOv7 architecture, introducing several key improvements:
- Anchor Redesign: The original YOLOv7 anchor boxes, derived from the COCO dataset, were not optimal for the small, relatively uniform size of immature yellow peaches. The researchers used the K-means clustering algorithm on their custom yellow peach dataset to generate anchor frame sizes and proportions better suited for this specific task.
- Coordinate Attention (CA) Module: To enhance the model's ability to focus on relevant features and suppress background noise (like leaves), a CA module was integrated into the YOLOv7 backbone. This module helps the network better capture spatial and channel information, improving feature extraction for small and occluded peaches.
- EIoU Loss Function: The standard CIoU loss function was replaced with the efficient EIoU loss. This modification aims to accelerate convergence and improve the accuracy of bounding box regression by directly minimizing the differences in width and height between predicted and ground truth boxes.
- Detection Head Optimization: The YOLOv7 detection head was modified by adding a P2 module for shallow downsampling and removing the P5 module for deep downsampling. This change is crucial for improving the detection of small targets, as shallower features retain more spatial information that is often lost in deeper layers.
Datasets
The study utilized a custom dataset of 1021 images of immature yellow peaches. These images were collected from a yellow peach plantation in Jiangxi Province, China, between April and May 2022. The dataset captures variations in lighting and weather conditions (rainy, cloudy, sunny; morning, midday, evening) to ensure the model's generalization ability. The images were annotated using Labelimg according to the PASCAL VOC 2007 standard, resulting in 33,743 annotated instances. The dataset was split into training (80%) and validation (20%) sets. Data augmentation techniques, including mosaic stitching, were applied to further enhance the dataset's diversity.
Key Insights and Ideas
- Anchor box optimization is critical for small, specific objects: The study highlights that generic anchor boxes from large datasets like COCO are insufficient for specialized tasks involving small, uniform objects. Tailoring anchor boxes through clustering significantly improves detection performance.
- Attention mechanisms are vital for complex backgrounds: The integration of the CA module demonstrates the power of attention in distinguishing target objects (peaches) from visually similar backgrounds (foliage), a common challenge in agricultural settings.
- Shallow features matter for small object detection: Modifying the detection head to leverage shallower feature maps (via the P2 module) is key to retaining and utilizing the fine-grained details necessary for detecting small targets, which are often missed by models focusing solely on deep semantic features.
- EIoU loss accelerates convergence: Replacing the loss function with EIoU not only improves accuracy but also speeds up the training process, making model development more efficient.
Key Results
The YOLOv7-Peach model achieved a mean Average Precision (mAP) of 80.4%, a significant improvement over the original YOLOv7 (76.9%). Specifically:
- The model showed a 3.5% improvement in mAP compared to the original YOLOv7.
- It outperformed other classical and recent target detection models like SSD, YOLOv3, YOLOv4, YOLOv5, and ObjectBox in terms of mAP and recall.
- The model demonstrated a recall rate of 73%, which is notably higher than many other models, indicating fewer missed detections.
- In small target detection tests, YOLOv7-Peach exhibited superior performance, with no missed detections in several scenarios where YOLOv4 and YOLOv7 did.
- In severe occlusion tests, YOLOv7-Peach also showed fewer missed detections compared to YOLOv4 and YOLOv7.
- The model achieved a detection speed of 21 fps, making it suitable for real-time applications.
Limitations and Future Work
The authors acknowledge that despite improvements, the YOLOv7-Peach model can still exhibit wrong detections and missed detections due to the inherent similarity between leaf and peach features. They suggest that future research should focus on strengthening feature extraction to further reduce information loss in deeper network layers.
The paper also points towards future work including:
- Lightweighting the model: Making the model more computationally efficient for deployment on resource-constrained hardware.
- Improving detection speed: Further optimizing the model for faster inference.
- Hardware deployment: The ultimate goal is to deploy the developed model on hardware for practical use in yellow peach orchards.
Summary updated