Several factors cause vehicle accidents during driving, such as driver negligence, drowsiness, and fatigue. These accidents can be prevented if drivers receive timely warnings. Additionally, recent advancements in computer vision and artificial intelligence (AI) have enabled the monitoring of drivers and the ability to alert them when they are not focused on driving. AI techniques can analyse key facial features, such as eye closure, yawning, and head movements, to assess the driver’s level of sleepiness. In response to the growing concerns surrounding drowsy driving and its potential safety hazards, this study presents a comprehensive approach for detecting a driver’s attention state using an enhanced version of the You Only Look Once (YOLOv5) algorithm. By leveraging critical facial landmarks and calculating the eye and mouth aspect ratios, the method effectively identifies signs of fatigue by establishing threshold values indicative of closed eyes and yawning. This work introduces an advanced YOLOv5 model integrated with Swin Transformer modules in the feature fusion network and refined backbone network feature extraction to detect driver drowsiness. Additionally, a real-time fatigued-driving detection model, built on an improved YOLOv5s architecture and incorporating Attention Mesh 3D key points, demonstrates superior effectiveness over conventional models. The proposed method achieves a notable 2.4% enhancement in mean average precision (mAP) compared to the baseline model through extensive experimentation on benchmark datasets. By combining YOLOv5 with facial 3D landmarks, the system benefits from the complementary strengths of both techniques, leading to more accurate and robust detection of fatigue-related cues and ultimately mitigating accidents caused by drowsy driving.