Training layer
Jupyter notebooks inspect datasets, train pretrained nano models, validate performance, and save weights plus charts and prediction artifacts.
Technical project documentation
A notebook-backed explanation of the datasets, three model pipelines, image preparation, detection merging, model results, deployment architecture, and people behind this academic computer vision project.
Project guide
The page follows the complete journey from training data to final result, with the exact settings and metrics stored in this repository.
System architecture
YOLO predicts a behavior class, confidence score, and bounding box for each detected region. The CNN classifies the entire image into one behavior category. Combining them gives a richer academic comparison between object detection and image classification.
Jupyter notebooks inspect datasets, train pretrained nano models, validate performance, and save weights plus charts and prediction artifacts.
Exported ONNX weights run client-side for YOLO. The Keras .h5 model is loaded only by the local Flask server.
The browser maps model-specific labels into shared behavior names, suppresses duplicate boxes, and builds an understandable result report.
Dataset documentation
Each YOLO dataset uses images paired with bounding-box labels and defines separate training, validation, and test folders. Both YOLO dataset configurations identify their source as Roboflow Universe under CC BY 4.0.
Roboflow project: Driver Monitoring System, version 1. The dataset has eight classes and was reviewed for class imbalance before training.
| Training images | train/images |
|---|---|
| Validation images | valid/images |
| Test images | test/images |
| Annotation format | YOLO bounding boxes |
| License | CC BY 4.0 |
Roboflow project: Abnormal Driver Behaviour, version 1. Its five classes focus on observable objects and activities around the driver.
| Training images | train/images |
|---|---|
| Validation images | valid/images |
| Test images | test/images |
| Annotation format | YOLO bounding boxes |
| License | CC BY 4.0 |
The CNN notebook loads Multi-Class Driver Behavior Image Dataset with Keras image_dataset_from_directory. Folder names become class labels automatically. Corrupt images are removed, images are resized to 128×128, batches contain 32 samples, and a 20% validation split is created with seed 123. The notebook refers to the second split as test_ds, so its reported “test” result comes from this held-out directory split rather than a separately documented external test dataset.
Model-by-model analysis
The metrics below are read from the saved final training epoch or notebook evaluation output. Precision describes how often predicted detections were correct; recall describes how many labeled objects were found; mAP summarizes detection quality across classes and confidence thresholds.
Model 01 · Object detector
A lightweight pretrained YOLO11 Nano detector selected for student hardware. The notebook targets an NVIDIA RTX 3050 Laptop GPU with 4 GB VRAM and includes dataset checks, class-count visualization, imbalance handling, training, and saved evaluation artifacts.
| Base weights | yolo11n.pt |
|---|---|
| Epochs / batch | 50 / 16 |
| Input size | 640 × 640 |
| Optimizer | AdamW |
| Learning schedule | Cosine LR |
| Augmentation | Mosaic 1.0, mixup 0.1 |
| Other | AMP, deterministic seed 0 |
Model 02 · Object detector
A compact YOLOv8 Nano detector trained for five visible driver-related activities and objects. It complements YOLO11 by providing a second independently trained source for drinking, eating, phone, seatbelt, and smoking-related detections.
| Base weights | yolov8n.pt |
|---|---|
| Epochs / saved batch | 50 / 16 |
| Input size | 640 × 640 |
| Optimizer | Ultralytics auto |
| Augmentation | Mosaic 1.0, mixup 0.0 |
| Validation | Enabled every run |
| Other | AMP, deterministic seed 0 |
YOLO11 has higher final precision and mAP in its own eight-class dataset, while YOLOv8 has slightly higher recall in its five-class dataset. These are not direct leaderboard scores because the models were trained on different datasets and class sets. In the product, their outputs are used as complementary evidence and merged only after label normalization.
Model 03 · Whole-image classifier
A TensorFlow/Keras convolutional neural network that classifies an entire 128×128 driver image. It achieves strong reported notebook accuracy and adds a classification perspective, but it requires TensorFlow and server-side model loading, so it is enabled only when the Flask app runs locally.
The notebook’s first class is other_activities. The local API assigns the friendlier but narrower label “Smoking/Drinking/Yawning” to that output index. This should be described as an interface alias, not a separately trained three-action class.
| Input / batch | 128 × 128 / 32 |
|---|---|
| Training epochs | 15 configured |
| Optimizer / loss | Adam / sparse categorical crossentropy |
| Output activation | Softmax |
| Reported test accuracy | 91.20% |
| Reported test loss | 0.3044 |
The saved classification report contains 1,455 evaluated images and approximately 91% overall accuracy, but only texting_phone (116 samples) and turning (1,339 samples) have non-zero support. The other three classes have zero support in that output. This means the result demonstrates strong performance on the represented split, especially turning, but it does not establish balanced 91% performance across all five classes.
Image preprocessing
Models only accept tensors with fixed dimensions and numeric ranges. The app preserves the uploaded image’s aspect ratio for YOLO, records the scale and padding, and later uses those values to translate predicted boxes back to the original image.
The browser reads JPG/PNG files and creates an image element. Local CNN requests decode a Base64 data URL with Pillow.
YOLO scales the image to fit inside 640×640 without distortion and fills unused space with neutral gray.
RGB byte values from 0–255 are divided by 255 to produce floating-point values from 0–1.
YOLO pixels are reordered into NCHW shape [1,3,640,640]. CNN uses NHWC shape [1,128,128,3].
YOLO output coordinates have padding offsets removed and are divided by the saved scale to match the original image.
#808080.Post-processing
YOLO can propose several boxes around the same activity. Non-Maximum Suppression (NMS) keeps the strongest candidate and removes nearby duplicates, producing a cleaner report. In this app NMS is applied after both model outputs are mapped into shared class names.
Phone and PhoneUse both become Phone Usage.NMS operates per unified class across detections from both YOLO models. This means two models predicting the same behavior in the same region compete on confidence. Soham’s SafeDriving output is intentionally skipped during the final warning-detection merge so it does not suppress or dilute actionable behavior detections.
Deployment architecture
The environment variable VERCEL=1 separates static cloud deployment from full local execution. This keeps the hosted project within a browser-compatible stack while preserving the CNN model for demonstrations on a capable local machine.
The static site loads both exported ONNX YOLO models in the browser through ONNX Runtime Web. Images remain client-side for those detections. TensorFlow and the .h5 CNN are not installed or loaded.
The browser still runs both YOLO models. In addition, the UI calls /api/cnn; Flask lazily loads models/mishra/driver_behavior_cnn.h5, preprocesses the image, and returns the predicted class and confidence.
Responsible interpretation
This is an academic demonstration designed for mini-projects, final-year presentations, AI labs, and viva explanations. Its metrics describe held-out project data, not every road, camera, driver, or lighting condition.
New camera positions, nighttime footage, occlusion, image quality, clothing, and vehicle interiors can differ from training data and reduce accuracy.
Rare behaviors may have less training support. The YOLO11 notebook addresses imbalance with augmentation, while the CNN report exposes an uneven evaluation split.
The current product analyzes uploaded still images. It does not model temporal behavior, gaze duration, repeated warnings, vehicle telemetry, or real-time safety intervention.
Do not use this project for road-safety decisions, commercial driver scoring, surveillance, insurance decisions, production ADAS, or any situation where a false positive or false negative could affect a person’s safety or rights.
Team and contributions
Developed under the Advanced Course on Green Skills and AI (Skills4Future Program), with separate ownership for model training and application infrastructure.
YOLOv8 model training, five-class driver behavior detector, validation, and model export workflow.
YOLO11 model training, eight-class detector, class-imbalance analysis, augmentation, and evaluation artifacts.
CNN model training, Keras classification architecture, confusion matrix, classification report, and local model capability.
Backend logic and server infrastructure for local inference and advanced deployment scenarios.
Divyanshu Mishra trained the CNN-based model that achieves excellent accuracy on the represented evaluation data but is not browser-compatible in this project due to TensorFlow and computational requirements. It can be run locally for enhanced classification capability.
Anurag Pawar developed the backend logic and server infrastructure used for advanced deployment scenarios and local CNN inference.
For complete model access, notebooks, saved training results, backend implementation, and deployment files, visit the project’s GitHub repository.
Review the training and testing notebooks, datasets, YOLO and CNN weights, ONNX browser inference, Flask backend, Vercel configuration, and project history.