Floating garbage removal is an essential environmental strategy to reduce water pollution and achieve environmental sustainability, and it is a pressing issue for global ecological restoration. Under the interference of complex environments, floating garbage will gather, overlap, and change its shape due to water flow and wind. Efficient and automatic detection and collection of floating garbage gathered on the water surface is a challenging environmental management task. This study proposed an efficient and economical deep learning solution based on YOLOv8 (You Only Look Once v8). By improving the backbone, introducing the Wise-Powerful IoU loss, and adding the AuxHead detection head, the negative impact of complex environmental factors was effectively compressed, and the detection mean Average Precision(mAP) of the surface model aggregated floating garbage was improved to 89.4 %. The Precision(P) was improved to 95.8 %. The model size is only 18.8 MB, and the number of model parameters is reduced by 32.2 % compared with the original model. The proposed model addresses the challenging issue of detecting aggregated floating garbage on the water surface, and the lightweight model is also more conducive to promoting outdoor use. The research results can improve the aggregated floating garbage collection rate by up to 61.5 % compared with the mainstream model Faster R-CNN. It can save up to about 1730.3 kW·h of electricity per ton of recycled waste oil and reduce the emission of 452.7 kg of CO2 and 2328.8t of water pollution. The scheme is superior to the current technical level in terms of detection Precision and mean Average Precision and makes essential scientific contributions to the protection and restoration of water ecosystems, energy conservation, emission reduction, and carbon reduction.