## 4 Results and Discussion  
### Dataset Construction  
The tomato dataset used in this study was collected from the Big Data Laboratory of Shandong Agricultural University, where tomatoes are cultivated. The images were captured using a digital commercial camera with a resolution of 3968 \(\times\) 2976 pixels in the RGB color space and saved in JPG format. All images were taken under natural daylight conditions, including the complexity of the growing environment: changes in lighting, occlusions, and overlaps. This significantly increased the difficulty of tomato yield detection. Under natural daylight conditions, 425 tomato images were captured, which were then divided into an 80% training set and a 20% test set to create a dataset representing natural scenes. The ground truth bounding boxes for all objects in each image in the dataset were manually annotated using the graphical image annotation tool Labellmg ([[https://github.com/tzutalin/labellmg](https://github.com/tzutalin/labellmg)]([https://github.com/tzutalin/labellmg](https://github.com/tzutalin/labellmg)) (accessed on 2 March 2024)), and the annotations were saved in YOLO format. The captured images are categorized into single unobstructed targets, single targets occluded by foliage, and multiple targets with or without occlusion. The main purpose of having a diverse dataset is to simulate real-world conditions. When the model is exposed to a broader range of data categories, it can learn richer and more comprehensive features, enabling it to better classify and recognize new, unseen data. This capability enhancement contributes to the model's stability and reliability in practical applications. Additionally, a diverse set of data categories helps prevent the model from overfitting noise or specific features in the training data, thereby improving its performance on unknown data. Finally, a variety of data categories means the model needs to adapt to more variations and disturbances, which helps improve its robustness against noise and outliers in the input data. In the real world, data are often filled with uncertainties, so training a model that is highly resistant to interference is extremely valuable. Furthermore, to increase the diversity and robustness of the dataset, data augmentation methods are used to expand the training set. Pre-training data augmentation includes operations such as random cropping, rotation, scaling, and flipping. These operations can generate more training samples and enhance the model's generalization and robustness. To avoid confounding algorithm comparisons due to data augmentation, we incorporated data augmentation uniformly within the training framework. Figure 8 shows some captured images under different environmental conditions. Finally, the training set consisted of 340 images containing 1253 tomatoes, while the remaining 85 images containing 512 tomatoes formed the test set.  
Figure 8: Tomato image samples under different environments in the natural scene dataset: (**a**) Single target without occlusion, (**b**) Multiple targets with occlusion, (**c**) tomato cluster, (**d**) enhanced lighting, (**e**) diminished lighting, and (**f**) multiple targets with or without occlusion.