The present study addresses the issue of non-compliance with helmet laws and the potential danger to both motorcycle riders and passengers. Despite the well-established advantages of helmet usage, compliance remains a formidable challenge in many regions of the world, with various factors contributing to the issue. To mitigate this concern, real-time monitoring and enforcement of helmet laws have been advocated as a plausible solution. However, previous attempts at real-time helmet violation detection have been limited by their inability to operate in real-time. To remedy this issue, the current paper proposes a real-time helmet violation detection system utilizing a single-stage object detection model called YOLOv5. The model was trained on the 2023 NVIDIA AI City Challenge Track 5 dataset and employed genetic algorithms in selecting the optimal hyperparameters for training the model. Furthermore, data augmentation techniques such as flip, and rotation were implemented to improve model performance. The efficacy of the model was assessed using mean average precision (mAP). Our developed model achieved an mAP score of 0.5377 on the experimental test data which won 10th place on the public leaderboard. The proposed approach represents a noteworthy breakthrough in the field and holds the potential to significantly improve motorcycle safety.