This study was conducted to address the challenges of detecting citrus fruits in complex orchard environments characterized by overlap, occlusion, and variable lighting conditions. To tackle these issues, an improved detection model named YOLO-MGP was developed based on the YOLOv8n architecture. Four key enhancements were introduced to the core components of the detection framework. First, the primary backbone network was replaced with MobileNetV3, which substantially reduced computational requirements while preserving the capability for multi-scale feature extraction. Second, a C2f-GLU module was incorporated into the neck network. By leveraging Gated Linear Units, this module strengthens the feature selection and fusion processes. Third, an additional P2 detection layer was added to improve the detection of small targets. This modification was complemented by the integration of a Coordinate Attention mechanism, which refines the distribution of feature weights across spatial and channel dimensions. Finally, the CIoU loss was replaced by PIoU to enhance the accuracy of bounding box regression, particularly for occluded and overlapping targets. Experimental results demonstrate that the YOLO-MGP model achieved a precision of 94.2%, a recall of 89.7%, and a of 95.7% on our custom citrus dataset. By substantially reducing the number of parameters while maintaining competitive detection performance, the proposed method offers a practical and lightweight solution for fruit detection in automated harvesting systems.
To reduce confusion between adjacent maturity categories, as well as false detections and low detection accuracy caused by complex backgrounds in tomato object detection, this study develops an improved YOLOv7-based model, named YOLO-RCM (Reduce classes misjudgment). First, a stability-enhanced ECANet channel attention module is embedded into the feature pyramid network (FPN) to strengthen discriminative channel responses. Second, a DCNv2-based deformable convolution enhancement module, namely DCNConv with adaptive magnitude constraints, is incorporated into the backbone network to alleviate feature misalignment caused by shape variation, partial occlusion, and fine-grained appearance differences in tomato maturity detection. Third, the WIoU v3 loss function is adopted to refine bounding box regression stability. The model was evaluated on the public Laboro Tomato dataset and TomatOD dataset. Experimental results indicate that YOLO-RCM obtains 83.7% Precision and 89.6% mAP@0.5, exceeding the baseline by 3.3 and 1.2 percentage points, respectively. Its Recall is 80.5%, with a decrease of 0.8 percentage points, whereas GFLOPs are reduced to 96.9, 6.3 lower than the baseline. These results indicate that the proposed method improves detection accuracy and computational efficiency while maintaining an almost unchanged model scale. The confusion matrix and PR curves further show that YOLO-RCM can effectively mitigate misdetections associated with adjacent maturity stages and complex scenes. In the external-dataset robustness test, Precision and mAP@0.5 are improved by 5.8 and 4.0 percentage points over the baseline, respectively, confirming the generalization ability of the proposed model. The main contribution of this study lies in improving tomato maturity detection from three complementary aspects: channel feature discrimination, local geometric perception, and bounding box regression stability. The study offers a practical technical reference for intelligent tomato harvesting systems in complex agricultural environments.