## 4 Results and Analysis
### Performance Comparison of Different Detection Algorithms
It can also be seen from the last row and column of the confusion matrix that our model is able to better distinguish the target from the background and reduce the probability of recognizing the target as the background or recognizing the background as the target. This is due to the fact that our improved model is able to better capture the feature information of the target and is able to perform finer target localization, which improves the accuracy of the model detection. Figure 8: _Cont._  
Display of Some Test Results  
Some of the detection results are shown in Figure 9. In these images, the background is very complex, and the fruits are obscured from each other, and the color of the fruits in the green ripening stage is similar to the background color, which is not easy to distinguish. In Figure 9, the left side shows the object labels of the input image, the middle image shows the detection results using YOLOv8s, and the right image shows the detection results using an improved model. The red box in the picture represents category b_green, the pink box represents category b_half_riped, the yellow box represents category l_green, the yellow-green box represents category l_half_riped, and the green box represents category l_full_riped. At the same time, we use arrows to mark the parts that are false detections and missed detections. Comparing the top three images, we can see that the YOLOv8s model mistakenly detects category b_green as b_half_ripened, while the test results of the improved model are all correct. From the six pictures of the second row and the third row, it is obvious that the missed detection is caused by the occlusion of branches, and the color of tomato fruit is similar to that of leaves. In the second row of the picture, YOLOv8s missed detecting a fruit of category b_green. Our model correctly detects the types of tomato maturity. In the third row of the picture, there are not only missed detections but also false detections of YOLOv8s. It missed detecting a fruit with the category b_green at the bottom of the picture. And it also incorrectly detected the leaves at the top of the picture as fruit. In addition, YOLOv8s incorrectly detected one of the fruits with the category b_green as b_half_ripened. Although our method also missed detecting a fruit with category b_green in this image, our method's detection results are still more accurate than YOLOv8s. From the bottom three images, we can observe that the tomato fruit in the picture is smaller and denser, resulting in false detection in the YOLOv8s model. While the improved model can effectively avoid missed detection and false detection. To sum up, although our model also has the problem of inaccurate detection, our method is more accurate than YOLOv8s. Therefore, our method is more suitable to detect the maturity of tomato in a complex environment. Because our improved model can more easily learn the characteristic information of tomato fruit from the complex environment, so as to detect and locate tomato fruit more accurately. Figure 8: Confusion matrix of YOLOv8s and improved model. The left side of (**a**) is the confusion matrix detected using YOLOv8s, and the right side is its normalized confusion matrix. The left side of (**b**) is the confusion matrix detected using the improved model, and the right side is its normalized confusion matrix. Therefore, the results of the above comparison indicate that our improved model can better solve the problems of missed or false detections in complex backgrounds, objects with similar background colors, and occlusion, thereby improving the accuracy of model detection. This improvement is of great significance for tomato ripeness detection tasks, as it can improve the reliability and stability of object detection and provide more effective solutions for practical applications. Figure 9: Partial test result. (**a**,**d**,**g**,**j**) are object labels of input image; (**b**,**e**,**h**,**k**) are detection results of YOLOv8s; (**c**,**f**,**i**,**l**) are detection results of our method.