# Clone the repository
git clone https://github.com/username/driver-drowsiness.git
cd driver-drowsiness
# Create a virtual environment (recommended)
python -m venv venv
# Activate the virtual environment
# Windows:
venv\Scripts\activate
# macOS/Linux:
source venv/bin/activate
# Install required packages
pip install -r requirements.txtThe ETH-XGaze model is not included in the repository due to its large size. Follow these steps:
- Visit the ETH-XGaze official page
- Download the model file (
epoch_24_ckpt.pth.tar) - Place it in the
models/directory:mkdir -p models # Copy the downloaded file to the models directory cp /download/path/epoch_24_ckpt.pth.tar models/eth_xgaze_model.pth
# Run the model conversion script
python scripts/convert_ethxgaze_model.py models/eth_xgaze_model.pth models/eth_xgaze_model.onnx --export_onnx# Start the main application
python run.pyUsage Steps:
- Make sure your camera is connected
- Click the "Start" button
- Keep your face in the camera's field of view
- Monitor real-time metrics
- End the analysis with "Stop"
# Video file analysis
python examples/analyze_video.py --input video.mp4 --output results/
# Batch video analysis
python scripts/batch_analyze.py --input_dir videos/ --output_dir results/You can use the feature either command line or application.
# Gaze zone test
python tests/test_gaze_zone_detector.py --camera 0 --show_zones
# Gaze zone calibration
python scripts/calibrate_gaze_zones.pyEU regulation C(2023)4523 compliant zones:
| Zone ID | Zone Name | Area | Criticality |
|---|---|---|---|
| 0 | Road Center | Area 2 | 🔴 Critical |
| 1 | Driving Instruments | Area 2 | 🟡 Driving Related |
| 2 | Infotainment | Area 1 | 🟠 Non-Driving |
| 3 | Left Side | Area 2 | 🟡 Driving Related |
| 4 | Right Side | Area 2 | 🟡 Driving Related |
| 5 | Rear Mirror | Area 2 | 🔴 Critical |
- Overall Accuracy: 93.23%
- Balanced Accuracy: 83.70%
- Macro-averaged Precision: 91.96%
- Macro-averaged Recall: 83.70%
- Macro-averaged F1-Score: 85.84%
- Cohen's Kappa: 0.9110 (Almost Perfect)
- Matthews Correlation Coefficient: 0.8549
- Krippendorff's Alpha: 0.9110
- Formula:
EAR = (|p2-p6| + |p3-p5|) / (2 * |p1-p4|) - Threshold Value: 0.21 (eyes considered closed below this)
- Usage: Instant eye blink and closure detection
- Formula:
MAR = |p14-p18| / |p12-p16| - Threshold Value: 0.65 (mouth considered open above this)
- Usage: Yawning detection
- Definition: Percentage of eye closure over a 60-second period
- Warning Threshold: 15%
- Critical Threshold: 20%
| Score | Status | Description |
|---|---|---|
| 1-3 | 🟢 Normal | Fully awake state |
| 4-5 | 🟡 Mild | Mild signs of fatigue |
| 6-7 | 🟠 Warning | Beginning of attention deficit |
| 8-9 | 🔴 Critical | Immediate intervention required |
- ETH-XGaze: Gaze estimation model (Paper)
- MediaPipe: Face mesh detection (Documentation)



