In many non-motor vehicle traffic accidents in China, the main cause of injury or death for drivers is not wearing a helmet. Therefore, the detection and punishment of such riders hold great significance in protecting people's lives and property safety. This paper delves into a deep learning-based method for detecting helmet-wearing on electric vehicles. The approach involves studying and designing an improved YOLOv5 model to identify the violation behavior of not wearing a helmet, including inserting the SE module in the network of the visual attention mechanism into the enhanced backbone network; bidirectional feature fusion is significantly enhanced by substituting the concat module with the Bidirectional Feature Pyramid Network (BiFPN) module, and adding receptive field attention Convolution (RFAConv) to the detection head. The improved YOLOv5 model demonstrates a higher mean Average Precision (mAP) while achieving a relatively smaller model size. This method provides technical support for the real-time and accurate detection of non-vehicle helmet targets; its efficacy has been confirmed through analysis of experimental results. These findings suggest that this method can assist traffic management departments in supervising non-motor vehicles, carrying significant practical value and importance.