Skip to content
/ D3-CNN Public

An academic project that implements a Convolutional Neural Network (CNN) entirely from scratch using NumPy — no PyTorch or TensorFlow. Designed to detect driver distractions from images and videos, it includes a Streamlit frontend for real-time testing. Built to understand deep learning fundamentals through hands-on coding.

Notifications You must be signed in to change notification settings

AS-0167/D3-CNN

Repository files navigation

🚗 D3-CNN: Driver Distraction Detector

D3-CNN is a simple Convolutional Neural Network (CNN) built from scratch using NumPy to detect driver distractions from images and videos. It’s an academic project designed to deeply understand how CNNs work internally — with no deep learning frameworks like PyTorch or TensorFlow used.

It is trained purely on CPU, and also features a Streamlit-based frontend for easy testing with image or video input.


📸 Sample Input vs Prediction

Input Image Prediction
sample Texting

🧠 Model Architecture

The CNN is simple and built from scratch using NumPy only:

self.layers = [
    Conv2D(filters=32, kernel_size=3, in_channels=3, padding=1),
    ReLU(),
    MaxPool2D(),
    Conv2D(filters=64, kernel_size=3, in_channels=32, padding=1),
    ReLU(),
    MaxPool2D(),
    Flatten(),
    Dense(input_size=16*16*64, output_size=128),
    ReLU(),
    Dense(input_size=128, output_size=NUM_CLASSES),
    Softmax()
]

📊 Architecture Diagram

CNN Architecture

Note: Please include the architecture diagram as architecture.png in the project root directory.


📂 Dataset

  • A mix of publicly available data and self-collected images.
  • Download the dataset from this Google Drive link: 📎 Download Dataset

✅ Model Performance

  • Trained on CPU from scratch
  • Test Accuracy: ~75%
  • Lightweight model for quick experimentation and learning

🚀 Setup & Installation

1. Clone the repository

git clone https://github.com/AS-0167/D3-CNN.git
cd D3-CNN

2. Install dependencies

pip install -r requirements.txt

🧪 Running the Streamlit App

You can upload an image or a video and get distraction predictions.

streamlit run app.py

🏋️‍♂️ Training the Model (Optional)

To retrain the model from scratch using the dataset:

  1. Ensure dependencies are installed:

    pip install -r requirements.txt
  2. Run the training notebook:

    jupyter notebook train-detect-distraction.ipynb

🎓 About the Project

This project was created as a hands-on academic experiment to:

  • Learn how CNNs work internally
  • Understand forward and backward propagation using NumPy
  • Handle dataset collection and preprocessing
  • Build a mini deep learning pipeline without relying on big frameworks

No libraries like TensorFlow or PyTorch were used.


👨‍💻 Author

[AS-0167] 🧑‍🎓 Student, Enthusiastic Learner of Machine Learning & Computer Vision


About

An academic project that implements a Convolutional Neural Network (CNN) entirely from scratch using NumPy — no PyTorch or TensorFlow. Designed to detect driver distractions from images and videos, it includes a Streamlit frontend for real-time testing. Built to understand deep learning fundamentals through hands-on coding.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published