At present, tomato transplanting in facility agriculture is mainly manual operation. In an attempt to resolve the problems of high labor intensity and low efficiency of manual operation, this paper designs a clip stem automatic transplanting and seedling picking device based on the yolov5 algorithm. First of all, through the study of the characteristics of tomato seedlings of different seedling ages, the age of tomato seedlings suitable for transplanting was obtained. Secondly, the improved yolov5 algorithm was used to determine the position and shape of tomato seedlings. By adding a lightweight upsampling operator (CARAFE) and an improved loss function, the feature extraction ability and detection speed of tomato seedling stems were improved. The accuracy of the improved yolov5 algorithm reached 92.6%, and mAP_0.5 reached 95.4%. Finally, the seedling verification test was carried out with tomato seedlings of about 40 days old. The test results show that the damage rate of the device is 7.2%, and the success rate is not less than 90.3%. This study can provide a reference for research into automatic transplanting machines.