Driver Monitoring + ADAS Platform provides an end-to-end solution for driver behavior analytics and advanced driver assistance using dashcam video streams. It combines a Python backend for event detection and report generation with a modern React frontend for convenient data review and dashboarding.
- Upload trip files (front required, rear recommended, cabin optional for strong DMS)
- Trip ingestion and assembly for segmented dashcam clips
- Front/rear/cabin stream ordering and best-effort timestamp sync
- Day/night/dusk scene profiling with adaptive detection thresholds
- DMS detections:
- driver fatigue (PERCLOS + microsleep)
- distracted driving
- mobile phone use
- seatbelt not worn (heuristic baseline)
- ADAS detections:
- lane deviation
- obstruction ahead
- tailgating
- rear obstruction behind
- rear tailgating behind
- Event engine with debounce, min-duration, cooldown, and severity smoothing
- Scene reliability gating to suppress low-confidence events in poor visibility
- Event artifacts:
- snapshot image
- annotated short MP4 clip around event
- Scoring:
- fatigue/distraction/lane/following-distance
- overall score
- Reports:
- JSON report
- downloadable PDF report
- Dashboard:
- upload + process status
- event timeline with artifact links
- scores
- trip history (driver/vehicle fields supported)
- FastAPI
- SQLite (via SQLAlchemy)
- OpenCV + MediaPipe + YOLOv8n
- FPDF2 (PDF report)
- Vite + React + TypeScript + Tailwind CSS
Implemented tables:
tripseventsscores
POST /api/tripsPOST /api/trips/{id}/complete-uploadGET /api/tripsGET /api/trips/{id}GET /api/trips/{id}/eventsGET /api/trips/{id}/scoresPOST /api/evaluation/run(ground truth + predictions path)POST /api/evaluation/run-range(ground truth + DB date range selection)GET /api/evaluation/reports(recent evaluation report list)POST /api/ml/pipeline/run(start training pipeline job)GET /api/ml/pipeline/jobs(list training jobs)GET /api/ml/pipeline/jobs/{id}(job status)GET /api/ml/pipeline/jobs/{id}/log(tail logs)
Backward compatibility:
POST /api/analyze/dayGET /api/jobs/{job_id}GET /api/reports/{job_id}
cd backend
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reloadcd frontend
npm install
npm run devOpen http://localhost:5173.
- Seatbelt detection is currently heuristic and should be replaced with a dedicated trained model.
- If no cabin stream is provided, DMS events are approximated and should not be used for legal enforcement.
- Sync is timestamp-based MVP logic; add audio cross-correlation and GPS speed fusion for harder drift scenarios.
- For scale, replace background task execution with worker queue (Redis + RQ/Celery).
The repository now includes a full model-improvement scaffold under backend/ml:
- dataset manifest schema and sample
- dataset QA + leakage checks
- deterministic split builder
- YOLO training wrapper
- detection export + confidence calibration
- release metrics assembly + acceptance gate checks
See backend/ml/README.md for usage.
- Dashboard now exposes:
- rear stream upload controls
- model insights (scene distribution, streams used, limitations, road profile)
- a fixed bottom-left
Model Trainingbutton that opens a dedicated training page - training page actions: run, cancel, retry, view logs, and download artifacts directly
A full offline evaluation suite is now included in backend/app/eval.
- Ground truth JSON: labeled trips/events (
backend/eval_ground_truth.sample.jsonas template) - Predictions source:
- a JSON file with predicted events, or
- a directory containing generated
report.jsonfiles (for examplebackend/reports)
From backend/:
.\.venv\Scripts\python -m app.eval.run --ground-truth .\eval_ground_truth.sample.json --predictions .\reportsOr use helper script:
.\run_eval.ps1 -GroundTruth .\eval_ground_truth.sample.json -Predictions .\reportsEach run creates backend/eval_reports/eval_YYYYMMDD_HHMMSS/ with:
evaluation.jsonfull result objectsummary.jsoncompact summarymetrics_by_event.csvmetrics_by_stream.csvmetrics_by_scenario.csvthreshold_sweep.csvreliability_diagram.pngthreshold_curve.png
- Overall: TP/FP/FN, precision, recall, F1
- Slices: per event type, stream (
front/rear/cabin), scenario (day/dusk/night) - Confidence calibration: ECE, Brier score, reliability bins
- Threshold optimization: global best threshold and per-event best thresholds
- Failure analysis: top FP and FN examples for error review