1. Introduction
Tomatoes are globally cultivated and consumed, holding considerable economic value due to their distinct flavor and rich nutritional profile [
1]. Currently, harvesting operations remain predominantly manual, characterized by high labor intensity and low efficiency, which severely hinders the improvement of industry quality and productivity [
2]. To alleviate the conflict between labor-intensive picking and rising labor costs, harvesting robots have emerged as a core focus in smart agricultural equipment research [
3]. However, in authentic orchard environments, fruits such as tomatoes and peaches typically grow in dense clusters and are easily obscured by branches and foliage. This complex, unstructured environment leads to persistently high rates of missed harvests, causing fruits to be picked past their optimal ripeness window [
4]. Such delays not only reduce the marketability and flavor quality of the crop but also result in severe economic losses for farmers [
5]. Therefore, enhancing the precision and speed of tomato ripeness recognition is crucial for ensuring product freshness, optimizing real-time transportation, and advancing automated agricultural logistics.
Early machine vision methodologies [
6,
7,
8] and machine learning methods based on color analysis [
9] are highly sensitive to dynamic light interference, frequently introducing subjective errors and exhibiting poor generalization capabilities in unstructured environments. To address complex foliage occlusion, deep learning frameworks have been progressively introduced. For instance, Ko et al. [
10] fused multiple pure convolutional neural network (CNN) streams for maturity sorting, achieving an Average Precision (AP) of 0.96; however, this method imposes a significant computational burden and high inference latency. Furthermore, its performance degrades markedly under dynamic light interference and foliage occlusion, making it difficult to meet the practical deployment requirements of complex agricultural fields. Ni et al. [
11] evaluated the application of lightweight CNNs in greenhouse tomato leaf disease classification and found that although EfficientNet-B0 achieved an accuracy of 70.40%, its performance was significantly constrained by background clutter and illumination variability. Consequently, the You Only Look Once (YOLO) series [
12] has emerged as a dominant paradigm for balancing efficiency and performance. For example, Liu et al. [
13] proposed YOLO-Tomato-A based on YOLOv3, attaining a detection accuracy of 98.3%; nonetheless, the model demonstrates insufficient capability in detecting small-sized tomatoes and performs poorly in dense fruit-overlapping scenarios. Subsequently, Gao et al. [
14] combined YOLOv5 with transfer learning for greenhouse tomato detection, reaching a 93.6% accuracy, yet this model still encounters substantial limitations when confronting complex backgrounds and dynamic light interference. More recently, Yang et al. [
15] proposed an improved YOLOv8 model for tomato ripeness recognition, achieving a precision of 95.8% and an accuracy of 91.7% on the test set. Despite these advancements, a critical bottleneck persists: to maintain high-speed localization, these single-stage architectures fundamentally rely on non-maximum suppression (NMS). When confronting dense fruit overlapping, NMS frequently and incorrectly suppresses the valid bounding boxes of adjacent tomatoes, resulting in severe missed detections. Fundamentally, pure CNN architectures lack the global long-range dependencies necessary to accurately distinguish heavily occluded and densely overlapping fruits within cluttered greenhouse backgrounds.
To overcome the inherent limitations of pure CNN architectures in complex agricultural environments, the Transformer model proposed by Vaswani et al. [
16] has garnered significant attention due to its exceptional global modeling capabilities. Nahak et al. [
17] compared Vision Transformer (ViT) with CNN models for tomato ripeness detection and found that ViT achieved an accuracy of 98.6%, significantly outperforming the CNN baseline. Carion et al. [
18] proposed the DEtection TRansformer (DETR) paradigm. By utilizing the Hungarian matching algorithm to achieve direct end-to-end set prediction, DETR structurally eliminates the reliance on NMS post-processing. This fundamentally addresses the missed detection dilemma in dense fruit overlapping scenarios, where NMS frequently and incorrectly suppresses adjacent bounding boxes. The practical advantages of this architecture have been empirically validated in various agricultural tasks. Liu et al. [
19] developed an optimized Deformable-DETR for green apple detection, reaching a precision of 80.4% under conditions where fruit appearance is similar to the foliage background and positions vary dynamically. To address dynamic light interference and foliage occlusion, Yao et al. [
20] proposed EG-DETR, a tomato ripeness detection model based on the DETR architecture. When evaluated on a multimodal tomato dataset containing diverse dynamic lighting conditions, the model maintained an accuracy of 83.7% in complex agricultural scenes, further verifying DETR’s capability to effectively aggregate global contextual information for severely occluded fruits. In summary, by virtue of end-to-end set prediction, global self-attention, and an NMS-free design, DETR and its variants exhibit structural superiorities over CNN/YOLO architectures in addressing the three major greenhouse challenges: dynamic light, severe occlusion, and dense overlapping. Furthermore, Gao et al. [
21] integrated CT-DETR with a ReID module to significantly enhance pedestrian tracking performance (94.8% precision, 92.8% accuracy), corroborating the architectural strength of DETR in handling object overlap and re-identification from a general target association perspective. However, the original DETR suffers from slow training convergence and high inference latency. To mitigate these issues, Zhao et al. [
22] proposed Real Time DEtection TRansformer (RT-DETR), successfully extending the DETR paradigm to real-time detection scenarios. For instance, Zhao et al. [
23] combined RT-DETR with Swin Transformer to develop RT-DETR-Tomatoes-BS, achieving an mAP@0.5 of 88.7% by better capturing wide-range global dependencies and contextual information while balancing training costs and detection performance. Gu et al. [
24] further introduced an improved RT-DETR method for automated tomato detection, integrating machine learning and graphics processing techniques to reach an mAP@0.5 of 86% (a 3% improvement over the baseline), enabling precise real-time phenotype computation. Nevertheless, despite these advantages, standard RT-DETR still imposes a significant computational burden on resource-constrained agricultural edge devices due to its massive parameter count and computational overhead, necessitating further lightweight optimization.
Consequently, the urgent demand for deploying models on resource-constrained agricultural edge devices has accelerated the development of lightweight object detection networks. Wang [
25] proposed a lightweight two-stage detection network that achieved an inference speed of 130 FPS and an mAP@0.5 of 75.87% on the KITTI dataset, establishing a high-speed baseline for real-time detection. Recent studies have made significant progress in agricultural vision tasks that balance efficiency and accuracy. For instance, Gao et al. [
26] proposed a lightweight tomato ripeness detection model, YOLOv8n-FDE, which achieved a 97.6% mAP@0.5 with its parameter count drastically reduced to 1.56 M; however, its accuracy still experienced a noticeable decline under conditions of severe occlusion and dynamic lighting. Song et al. [
27] presented an improved instance segmentation model, FGS-YOLOv8s-seg, for tomato detection and ripeness grading in greenhouse environments. Experimental results demonstrated that, compared to the YOLOv8s-seg baseline, the model improved precision and mAP@0.5 by 2.6% and 5.1%, respectively, achieving a favorable balance between accuracy and speed while maintaining high computational efficiency. Ma et al. [
28] developed TMSDDet, a lightweight tomato ripeness detection model based on YOLO11n that integrates ADown, SlimNeck, and Efficient-Head modules. This model was successfully deployed on edge devices and achieved 80.4% mAP@0.5. Furthermore, Wang et al. [
29] proposed PDSI-RTDETR, a lightweight tomato ripeness detection model based on an improved RT-DETR. Compared to the standard RT-DETR baseline, it increased mAP@0.5 and FPS by 3.9% and 38.7%, respectively, further validating the immense application potential of the RT-DETR architecture in tomato ripeness detection tasks.
In summary, although existing models are capable of performing tomato ripeness classification, their applicability remains highly limited in unstructured greenhouse environments characterized by dynamic light interference, fruit overlapping, and foliage occlusion. Furthermore, they struggle to meet the urgent demand for deployment on resource-constrained agricultural edge devices. To address this, the present study adopts the Transformer-based RT-DETR as a baseline framework and proposes a lightweight tomato ripeness detection model, CFD-DETR. Under complex real-world greenhouse backgrounds, this model achieves an optimal balance among mAP@0.5, GFLOPs, and inference speed, and its superior generalization capability has been validated on the public Laboro Tomato and RauTD datasets. The proposed model not only overcomes the critical challenges faced by existing algorithms in fine-grained tasks but also significantly reduces model parameters and computational overhead, thereby providing a highly efficient and deployable algorithmic foundation for agricultural robotic harvesting. The primary objectives and contributions of this study are as follows:
- (1)
To meet the requirements of lightweight deployment and mitigate dynamic light interference, a lightweight backbone network, CAEfficientViT, is designed based on the EfficientViT architecture. By embedding the CAEViTBlock, the model’s capacity to extract tomato fruit color features is enhanced, enabling the highly efficient capture of subtle, fine-grained ripeness traits.
- (2)
To overcome severe foliage occlusion, a Focused Efficient Additive Attention (FEAA) mechanism is proposed. Utilizing global weighted attention scores and an additive attention paradigm, this mechanism effectively directs the model’s focus toward local feature regions crucial for ripeness classification while simultaneously reducing computational overhead, facilitating its deployment on resource-constrained agricultural edge devices.
- (3)
To resolve the issues of fruit blurring and artifacts caused by traditional upsampling, a depthwise dynamic upsampling module, DwDySample, is designed. This module ensures that critical information, such as maturity-related color transitions and occlusion boundaries, is prominently preserved within the upsampled feature maps.
- (4)
To improve the accuracy of tomato boundary fitting and effectively handle low-quality greenhouse tomato samples, this study integrates Wise-IoUv3 with SIoU to design the Wise-SIoU loss function. This enhances the model’s high-precision fitting capability and strong robustness in complex scenarios.
This study is organized as follows:
Section 2 introduces the materials and methods;
Section 3 presents and discusses the experimental results;
Section 4 summarizes the conclusions.
5. Conclusions
To overcome the critical bottleneck of deploying high-precision vision detection models on resource-constrained agricultural edge devices, this study proposes CFD-DETR, a lightweight tomato ripeness detection model tailored for real-world greenhouse environments. To address the three core challenges of dynamic light interference, severe foliage occlusion, and dense fruit overlapping, CFD-DETR introduces four key innovations: (1) the lightweight CAEfficientViT backbone network, which enhances tomato color feature extraction capabilities to efficiently capture fine-grained ripeness traits; (2) the FEAA mechanism, which utilizes global weighted attention scores to direct the model’s focus toward critical ripeness regions while reducing computational overhead; (3) the DwDySample overcomes the blurring and artifacts caused by traditional upsampling, preserving maturity-related color transitions and occlusion boundary information; and (4) the Wise-SIoU loss function, which integrates Wise-IoUv3 and SIoU to enhance bounding box fitting capabilities for low-quality samples and improve robustness in complex scenarios. Experimental results demonstrate that, compared to the RT-DETR baseline, CFD-DETR achieves improvements of 2.5%, 2.6%, and 2.1% in Precision, Recall, and mAP@0.5, respectively, while reducing GFLOPs and parameter count by 29.9 G and 9.4 M, respectively. On the public LaboroTomato and RauTD datasets, mAP@0.5 and mAP@0.5:0.95 are increased by 3.4% and 1.3%, respectively, confirming its strong generalization capabilities. In summary, CFD-DETR provides a highly deployable algorithmic foundation for automated robotic harvesting. Future research will focus on optimizing robustness under extreme conditions and exploring physical deployment and real-time hardware acceleration on harvesting robots.