The tidal movement of the ocean carries garbage to the shore. The garbage needs to be dealt with in time, otherwise, the pollution of the garbage to the environment will become increasingly serious. According to statistics, plastic garbage accounts for a substantial proportion of marine garbage. This study developed a target detection model for some plastic garbage to help achieve automatic marine garbage capture. Firstly, according to the principle of balanced label distribution, multi-background, and multi-angle, we created an image dataset based on artificial synthesis to solve the problem of insufficient data. Secondly, the CBAM attention module was used for the target detection algorithm Yolov5 to improve the ability of target feature extraction and model generalization. Furthermore, the loss function of bounding box regression CIoU was replaced with SIoU to solve the problems of slow convergence speed and low training efficiency. Finally, the effectiveness of the Yolov5 model was discussed with the analysis of experimental results.