At present, the picking of nectarines mainly relies on manual completion in China, and the process involves high labor intensity during picking and low picking efficiency. Therefore, it is necessary to introduce automated picking. To improve the accuracy of nectarine fruit recognition in complex environments and to increase the efficiency of automatic orchard-picking robots, a lightweight nectarine detection method, YOLOv8n-CSD, is proposed in this study. This model improves on YOLOv8n by first proposing a new structure, C2f-PC, to replace the C2f structure used in the original network, thus reducing the number of model parameters. Second, the SEAM is introduced to improve the model’s recognition of the occluded part. Finally, to realize real-time detection of nectarine fruits, the DySample Lightweight Dynamic Upsampling Module is introduced to save computational resources while effectively enhancing the model’s anti-interference ability. With a compact size of 4.7 MB, this model achieves 95.1% precision, 84.9% recall, and a mAP@0.5 of 93.2%—the model’s volume has been reduced while the evaluation metrics have all been improved over the baseline model. The study shows that the YOLOv8n-CSD model outperforms the current mainstream target detection models, and can recognize nectarines in different environments faster and more accurately, which lays the foundation for the field application of automatic picking technology.