# A Raisin Foreign Object Target Detection Method Based on Improved YOLOv8
## 1 Introduction  
Amidst escalating global concerns over food safety [1], raisins--ubiquitous as a popular snack in everyday life--frequently encounter the challenge of foreign object contamination during their production [2]. Such contamination not only undermines the product's market competitiveness but also poses a significant risk to consumer health [3]. Consequently, the advancement of a precise and efficient detection system for foreign objects in raisins is imperative for safeguarding food safety and bolstering product quality. In conventional raisin production, the identification of foreign matter predominantly depends on manual visual inspection, a method that, despite its simplicity, is fraught with inefficiencies [4, 5]. Initially, this approach necessitates substantial labor, escalating production expenses and proving impractical for large-scale operations [6, 7]. Moreover, the efficacy of manual inspection is constrained by factors such as the inspector's visual acuity, fatigue, and concentration span, which can result in both oversights and erroneous identifications [8]. In addition, manual detection is difficult to adapt to rapidly changing production environments, and it is hard for inspectors to promptly find foreign bodies that are small or similar in color to raisins. In stark contrast, automated foreign object detection systems have significant advantages. Initially, automation significantly enhances detection velocity, facilitating real-time surveillance and aligning with the exigencies of high-throughput production lines [9]. Moreover, these systems, leveraging machine vision, refine their discernment of foreign object characteristics through extensive training datasets, thereby bolstering detection precision and dependability. Immune to the vicissitudes of human fatigue and concentration,they operate with unwavering consistency. Furthermore, with the capacity to fine-tune algorithmic parameters and training data, these automated systems adeptly accommodate diverse production settings and product varieties, adeptly managing a spectrum of foreign object detection challenges [10]. Numerous researchers have extensively investigated the automation of raisin grading and sorting. [PERSON] et al. [11] designed a new model for raisin classification, combining eleven machine learning and five AI methods to classify raisins based on size, shape, and texture, with the LightGBM model peaking at 98.40% accuracy. [PERSON] et al. [12] optimized feature extraction for raisin evaluation through particle swarm algorithms, coupling with linear discriminant analysis (LDA) to reach the zenith of classification accuracy at 99.73%. Predominantly, these raisin detection studies are rooted in traditional machine learning, heavily dependent on feature engineering, and often constrained by oversimplified image backgrounds, limiting their detection efficacy and hindering industrial scalability. As deep learning technology rapidly develops, an influx of researchers have delved into the detection of agricultural products utilizing this advanced technology. [PERSON] et al. [13] introduced a deep-learning-based multi-class fruit detection approach for plant analysis, employing Faster R-CNN to discern apples under various occlusion scenarios. The model's accuracy is 0.909 in the absence of obstructions, 0.899 when leaves are blocking the view, 0.858 when branches or wire mesh are obstructing, and 0.848 when other fruits are in the way. The average overall accuracy is 0.879. [PERSON] et al. [14] proposed an enhanced YOLO-V3 model for the real-time tracking of apples throughout different growth phases in orchards. By integrating DenseNet to refine the YOLO-V3 network's lower-resolution feature layers, the YOLOV3-dense model achieved an average precision of 0.882, with a swift average detection time of 0.304 s per frame. [PERSON] et al. [15] have developed a technique for detecting and quantifying wheat seeds using an enhanced YOLOv8 model, incorporating shared convolutional layers for a streamlined design with reduced parameters.