Anozivaishe Kuwandira
Login
All projects

Computer Vision

DriveAware

Vision-based driver distraction detection from three in-car cameras, with four model pipelines compared on drivers the model never saw.

Role
Researcher & Developer
PyTorchNumPyOpenCVMediaPipeFastAPIAngularPostgreSQL

DriveAware is my honours year project: a vision-based, multi-cue system that detects driver distraction from in-car video. Instead of relying on a single signal, it watches three: what the driver is doing (body camera), where they are looking (face camera) and their hands on the wheel (hands camera). A model is trained for each cue on the Driver Monitoring Dataset (DMD), and the three decisions are combined by decision-level fusion.

The system runs end to end: an Angular dashboard, a FastAPI service backed by PostgreSQL, and analysis of uploaded or live video with any of the four trained pipelines.

Four pipelines, one shared setup

Every pipeline sees the same input (16 RGB frames from a 2-second window, 224 x 224) and the same split by participant (10 training drivers, 2 validation, 2 test), so the differences come from the architecture.

PipelineArchitectureParameters
1. Manual NumPy CNNCompact residual CNN; every layer, the backward pass and the Adam optimiser written by hand in NumPyabout 177k
2. PyTorch CNNThe same network in PyTorch, used to validate the manual implementationabout 177k
3. Pretrained CNNImageNet ResNet-18 fine-tuned end to end, averaged over the 16 frames11.3M
4. Pretrained CNN + TransformerThe Pipeline 3 frame encoder plus a 2-layer temporal transformer (8 attention heads)12.4M

Results on drivers the model never saw

Test accuracy on the two held-out participants:

PipelineActionGazeWheel
1. Manual NumPy CNN39.62%42.31%41.22%
2. PyTorch CNN17.97%48.72%45.55%
3. Pretrained CNN81.22%77.56%67.43%
4. Pretrained CNN + Transformer80.19%78.85%79.39%
Majority-class baseline42.7%14.1%50.4%
  • The hand-written network matches the framework. Pipelines 1 and 2 reach the same validation accuracy on gaze (35.81%), which supports the correctness of the manual backpropagation.
  • Training from scratch does not generalise. With only 10 training drivers, the small networks learn those drivers rather than the task.
  • Transfer learning is the largest single improvement, raising action accuracy from 17.97% to 81.22%.
  • Temporal modelling helps where motion matters. The transformer lifts wheel accuracy from 67.43% to 79.39% (macro-F1 0.639 to 0.763).
  • Pipeline 4 is the most consistent model, at 78.85% to 80.19% on all three cues, and is the one recommended for the system.

Limitations

A gap to unseen drivers remains (85 to 98% training accuracy against 67 to 81% on test). The validation and test sets hold only two drivers each, so scores move noticeably between epochs. Rare actions, such as reaching to the backseat, are recognised less reliably than the headline accuracy suggests (action macro-F1 about 0.68).

System design: three cameras, three cues, one fused decision
System design: three cameras, three cues, one fused decision
Test accuracy on the two held-out drivers, against the majority-class baseline
Test accuracy on the two held-out drivers, against the majority-class baseline
Pipeline training results in the DriveAware dashboard
Pipeline training results in the DriveAware dashboard
Pipeline 4: training history and confusion matrices for the action cue
Pipeline 4: training history and confusion matrices for the action cue
Pipeline 4 architecture: ResNet-18 frame encoder with a temporal transformer
Pipeline 4 architecture: ResNet-18 frame encoder with a temporal transformer
Pipeline 3 architecture: ImageNet ResNet-18 fine-tuned end to end
Pipeline 3 architecture: ImageNet ResNet-18 fine-tuned end to end
Pipelines 1 and 2 architecture: compact residual CNN, in NumPy and in PyTorch
Pipelines 1 and 2 architecture: compact residual CNN, in NumPy and in PyTorch
Monitor: choose a pipeline and cue, then analyse uploaded or live video
Monitor: choose a pipeline and cue, then analyse uploaded or live video
Settings: detection thresholds, enabled cues and fusion strategy
Settings: detection thresholds, enabled cues and fusion strategy
DriveAware sign-up screen
DriveAware sign-up screen
DriveAware - Anozivaishe Kuwandira