Electric vehicle accidents on the road occur frequently, and head injuries are often the cause of serious casualties. However, most electric vehicle riders seldom wear helmets. Therefore, combining target detection algorithms with road cameras to intelligently monitor helmet-wearing has extremely important research significance. Therefore, a helmet-wearing detection algorithm based on the improved YOLOv8n model, PRE-YOLO, is proposed. First, we add small target detection layers and prune large target detection layers. The sophisticated algorithm considerably boosts the effectiveness of data manipulation while significantly reducing model parameters and size. Secondly, we introduce a convolutional module that integrates receptive field attention convolution and CA mechanisms into the backbone network, enhancing feature extraction capabilities by enhancing attention weights within both channel and spatial aspects. Lastly, we incorporate an EMA mechanism into the C2f module, which strengthens feature perception and captures more characteristic information while maintaining the same model parameter size. The experimental outcomes indicate that in comparison to the original model, the proposed PRE-YOLO model in this paper has improved by 1.3%, 1.7%, 2.2%, and 2.6% in terms of precision P, recall R, [email protected], and [email protected]:0.95, respectively. At the same time, the number of model parameters has been reduced by 33.3%, and the model size has been reduced by 1.8 MB. Generalization experiments are conducted on the TWHD and EBHD datasets to further verify the versatility of the model. The research findings provide solutions for further improving the accuracy and efficiency of helmet-wearing detection on complex traffic roads, offering references for enhancing safety and intelligence in traffic.