# A Raisin Foreign Object Target Detection Method Based on Improved YOLOv8
## 4 Discussion
[PERSON] et al. [32] put forth a tomato ripeness detection technique grounded in the MatDet model, an iteration of Faster R-CNN that employs ResNet-50 as its backbone, integrates RoAlign for precise bounding box delineation, and utilizes PANet for multi-scale feature fusion. This model excelled in complex environments with branch occlusions, fruit superpositions, and variable lighting, reaching an average accuracy of 96.14% and effectively mitigating challenges like occlusion, overlapping, and lighting variations. [PERSON] et al. [33] also introduced a real-time apple stem/calyx recognition system founded on the YOLO-v5 algorithm, which through the optimization of hyperparameters, transfer learning, and the refinement of model parameters and weight volumes using detection head search algorithms and pruning techniques, achieves an overall reduction of approximately 71%, enabling a real-time detection rate of 25.51 frames per second on a CPU with an accuracy of 93.89%. [PERSON] et al. [34] presented a disease detection methodology for sweet pepper plant leaves, capitalizing on the YOLOv5 model, which adeptly identified early bacterial spot infections with a compact model size, an average accuracy of 0.907, and an average processing speed of 20 ms per image. [PERSON] et al. [35] proposed a strawberry ripeness detection strategy predicated on the LS-YOLOv8 model, an evolution of the YOLOv8 algorithm that assimilates the LW-Swin Transformers model and introduces novel random variables to govern contrast enhancement, thereby enhancing model performance. The LS-YOLOv8s model achieved a detection accuracy of 94.4% and a rate of 19.23 frames per second, with 51.93% of the parameters of the YOLOv8s model. The current studies comprehensively showcase the applicability of deep learning in agricultural product detection, with the YOLO model exemplifying the efficacy of single-stage object detection approaches. Although its accuracy cannot be compared to that of traditional machine learning methods and two-stage object detection methods, it has significant advantages in terms of detection speed and the resources required, while also achieving product standard accuracy. In the detection of foreign matter in raisins, there are situations where materials and foreign matter overlap to some extent, and some foreign matter is very small, making detection even more challenging. To address this, we propose an enhanced real-time detection approach leveraging an improved YOLOv8 model. This novel method integrates MHSA from BoTNet into YOLOv8's backbone. In the model's neck layer, selected C2f modules have been strategically replaced with RFAConv modules. The model also adopts an EIoU loss function in place of the original CIoU. Our experiments reveal that the refined YOLOv8 boasts a precision of 94.5%, a recall rate of 89.9%, and an F1-score of 0.921, with a mAP reaching 96.2% at the 0.5 IoU threshold and 81.5% across the 0.5-0.95 IoU range. For this model, comprising 13,177,692 parameters, the average time required for detecting each image on a GPU is 7.8 milliseconds. The model demonstrates good performance both in comparison with existing models and in the detection of samples composed of single or multiple foreign substances combined with raisins. Nonetheless, there remains scope for enhancing the research. First, although the model has shown some improvement in detecting raisins under conditions where they are obscured by foreign substances, there is still an issue of missed detection. Second, although the model has shown promising results in terms of accuracy and computational efficiency, further enhancements can be achieved through techniques such as pruning and knowledge distillation, which are also being explored in the domain of agricultural product detection. Third, the current model is only targeted at the seedless white variety of raisins from Turpan City, Xinjiang Uyghur Autonomous Region, China. In future research, the range of dried grape varieties can be expanded to increase the applicability of the model.