In order to mitigate the risk of irreversible drowning injuries, this study introduces an enhanced YOLOv5 algorithm aimed at improving the efficacy of indoor swimming pool drowning detection and facilitating the timely rescue of endangered individuals. To simulate drowning and swimming positions accurately, four swimmers were deliberately chosen and observed, with monitoring conducted by drones flying above the swimming pool. The study was approved by the ethics committee of our institution, with the registration number 2022024. The images captured by the drones underwent a meticulous evaluation, and only those deemed suitable were selected to construct the self-made dataset, comprising a total of 8572 images. Furthermore, two enhancements were implemented in the YOLOv5 algorithm. Firstly, the inclusion of the ICA module strengthened category classification and the localization of water behavioral postures, which is improved from the coordinated attention module (CA). Secondly, the PAN module was replaced with the bi-directional feature pyramid network (BiFPN). Subsequently, the improved YOLOv5 algorithm underwent training using the self-made dataset. Evaluation of the algorithm’s performance revealed a notably improved detection accuracy rate, recall rate, and an impressive mean Average Precision (mAP) score of 98.1%, 98.0%, and 98.5%, respectively. Our paper introduces the improved YOLOv5 algorithm, surpassing the original YOLOv5 algorithm in terms of recognition accuracy for instances of drowning.