Detection of Distracted Driver
A report submitted in partial fulfillment of the requirements for the award of the degree of
                          BACHELOR OF TECHNOLOGY
                                         in
                          Computer Science and Engineering
                                               By
                                  Chiraag Mittal(18111)
                           SCHOOL OF COMPUTING
INDIAN INSTITUTE OF INFORMATION TECHNOLOGY UNA
               HIMACHAL PRADESH
                                   DECEMBER 2021
                                                                                                  1
School of Computing, IIITU[CSL702]: 18111
                            BONAFIDE CERTIFICATE
This is to certify that the project titled Zone is a bonafide record of the work done by
                                 Chiraag Mittal(18111)
in partial fulfillment of the requirements for the award of the degree of Bachelor of
Technology in Computer Science and Engineering of the INDIAN INSTITUTE OF
INFORMATION TECHNOLOGY UNA, HIMACHAL PRADESH, during the year 2018 -
2022.
                                    under the guidance of
                                     Dr. Avantika Singh
                          Project viva-você held on: 01-Dec-2021
                                                                Dr. Avantika Singh
                                                                                           1
School of Computing, IIITU[CSL702]: 18111
             ORIGINALITY / NO PLAGIARISM DECLARATION
We certify that this project report is our original report and no part of it is copied from any
published reports, papers, books, articles, etc. We certify that all the contents in this report
are based on our personal findings and research and we have cited all the relevant sources
which have been required in the preparation of this project report, whether they be books,
articles, reports, lecture notes, and any other kind of document. We also certify that this
report has not previously been submitted partially or as whole for the award of degree in
any other university in India and/or abroad.
We hereby declare that we are fully aware of what constitutes plagiarism and understand
that if it is found at a later stage to contain any instance of plagiarism, our degrees may be
cancelled.
                                                                Chiraag Mittal(18111)
                                                                                              2
School of Computing, IIITU[CSL702]: 18111
                                    ABSTRACT
The number of road accidents is continuously increasing in the last few
years worldwide. As per the survey of the National Highway Traffic
Safety Administrator, nearly one in five motor vehicle crashes are
caused by a distracted driver. An accurate and robust system can be
developed for detecting distracted drivers and warn them against them.
                                                                          3
School of Computing, IIITU[CSL702]: 18111
                              ACKNOWLEDGEMENT
I would like to thank the following people for their support and guidance without whom the
completion of this project in fruition would not be possible.
I would like to express my sincere gratitude and heartfelt thanks to Dr. Avantika Singh for
their unflinching support and guidance, valuable suggestions and expert advice. Their
words of wisdom and expertise in subject matter were of immense help throughout the
duration of this project.
I also take the opportunity to thank our Director and all the faculty of School of Computing,
IIIT Una for helping us by providing necessary knowledge base and resources.
I would also like to thank my parents and friends for their constant support.
                                                                 Chiraag Mittal(18111)
                                                                                           4
School of Computing, IIITU[CSL702]: 18111
                               TABLE OF CONTENTS
Title                                              Page No.
ABSTRACT                                                 iii
ACKNOWLEDGEMENT                                          iv
TABLE OF CONTENTS                                        v
1       Introduction                                     1
        1.1    Introduction                              1
        1.2    Background                                2
2       Preliminary Study                                3
        2.1    Introduction                              3
        2.2    Working                                   3
        2.3    Layers                                    4
3       Methodology                                      5
        3.1 Introduction                                 5
        3.2 Importing The Libraries                      5
        3.3 Defining the directories                     5
        3.4 Analysing the Data                           6
        3.5 Defining the Model                           7
        3.6 Model Analysis                               7
4       Experimnetation Results                          9
        4.1 Input Data                                   9
                                                               5
School of Computing, IIITU[CSL702]: 18111
       4.2 Training Loss                    9
       4.3 Training Accuracy                10
       4.4 Heatmap                          10
5      Conclusion                           11
6      References                           12
                                                 6
School of Computing, IIITU[CSL702]: 18111
                                     Chapter 1
                                  Introduction
1.1     Introduction
According to the World Health Organization (WHO) survey, 1.3 million people worldwide
die in traffic accidents each year, making them the eighth leading cause of death and an
additional 20-50 million are injured/ disabled.
As per the report of the National Crime Research Bureau (NCRB), Govt. of India, Indian
roads account for the highest fatalities in the world. There has been a continuous increase in
road crash deaths in India since 2006. The report also states that the total number of deaths
has risen to 1.46 lakhs in 2015 and driver error is the most common cause behind these
traffic accidents.
1.1.1   Language Used
I used PYTHON language to develop this project. It is an interpreted high-level general-
purpose programming language. Its language constructs as well as its object-oriented
approach aim to help programmers write clear, logical code for small and large-scale
projects.
1.1.3 Dependencies
Pandas – It is a fast, powerful, flexible and easy to use open source data analysis and
manipulation tool built on top of the python programming language.
NumPy - It is the fundamental package for scientific computing in Python. It is a Python
library that provides a multidimensional array object, various derived objects (such as
masked arrays and matrices), and an assortment of routines for fast operations on arrays,
                                                                                                1
School of Computing, IIITU[CSL702]: 18111
including mathematical, logical, shape manipulation, sorting, selecting, I/O, discrete
Fourier transforms, basic linear algebra, basic statistical operations, random simulation and
much more.
Keras - It is an open-source software library that provides a Python interface for artificial
neural networks. It acts as an interface for the TensorFlow library.
Matplotlib - It is a plotting library for the Python programming language and its numerical
mathematics extension NumPy. It provides an object-oriented API for embedding plots into
applications using general-purpose GUI toolkits like Tkinter, wxPython, Qt, or GTK.
1.2    Background
The main aim of this project is to build an Advanced Driver Assistance Systems (ADAS) to
prevent accidents by offering technologies that alert the driver to potential problems and to
keep the car’s driver and occupants safe if an accident does occur.
The focus is on detecting manual distractions where the driver is engaged in other activities
than safe driving and also identify the cause of distraction.
                                                                                            2
School of Computing, IIITU[CSL702]: 18111
                                     Chapter 2
                              Preliminary Study
2.1        Convolutional Neural Networks
Convolutional Neural Networks, like neural networks, are made up of neurons with
learnable weights and biases. Each neuron receives several inputs, takes a weighted sum
over them, pass it through an activation function and responds with an output.
The whole network has a loss function and all the tips and tricks that we developed for
neural networks still apply on Convolutional Neural Networks.
2.2        How Do Convolutional Neural Networks Work?
There are four layered concepts to understand in Convolutional Neural Networks:
      1.   Convolution,
      2.   ReLu,
      3.   Pooling and
      4.   Full Connectedness (Fully Connected Layer).
2.3        Layers -
                                                                                     3
School of Computing, IIITU[CSL702]: 18111
Convolution Of An Image :
Convolution has the nice property of being translational invariant. Intuitively, this means
that each convolution filter represents a feature of interest (e.g pixels in letters) and the
Convolutional Neural Network algorithm learns which features comprise the resulting
reference (i.e. alphabet).
We have 4 steps for convolution:
       Line up the feature and the image
       Multiply each image pixel by corresponding feature pixel
       Add the values and find the sum
       Divide the sum by the total number of pixels in the feature
ReLU Layer :
ReLU is an activation function.
Rectified Linear Unit (ReLU) transform function only activates a node if the input is above
a certain quantity, while the input is below zero, the output is zero, but when the input rises
above a certain threshold, it has a linear relationship with the dependent variable.
Pooling Layer
In this layer we shrink the image stack into a smaller size. Pooling is done after passing
through the activation layer. We do this by implementing the following 4 steps:
       Pick a window size (usually 2 or 3)
       Pick a stride (usually 2)
       Walk your window across your filtered images
       From each window, take the maximum value
Stacking Up The Layers
So to get the time-frame in one picture we’re here with a 4×4 matrix from a 7×7 matrix
after passing the input through 3 layers – Convolution, ReLU and Pooling .
                                                                                                4
School of Computing, IIITU[CSL702]: 18111
                                   Chapter 3
                                Methodology
3.1 Introduction
This chapter provides a walkthrough of the coding practices and various implementations
used across the code to optimize the performance.
3.2 Importing The Libraries
3.3 Defining the directories
                                                                                          5
School of Computing, IIITU[CSL702]: 18111
3.4 Analysing the Data
                                            6
School of Computing, IIITU[CSL702]: 18111
3.5 Defining the Model
3.6 Model Analysis
                                            7
School of Computing, IIITU[CSL702]: 18111
                                            8
School of Computing, IIITU[CSL702]: 18111
                                            9
School of Computing, IIITU[CSL702]: 18111
                                            10
School of Computing, IIITU[CSL702]: 18111
                                   Chapter 4
                     Experimentation Results
3.1 Input Data
3.2 Training Loss
                                               11
School of Computing, IIITU[CSL702]: 18111
3.3 Training Accuracy
3.4 Heatmap
                                            12
School of Computing, IIITU[CSL702]: 18111
                                 Conclusion
Driver distraction is a serious problem leading to a large number of road
crashes worldwide. Hence detection of he distracted drivers becomes an
essential system component in self-driving cars. Here, we present a
robust Convolutional Neural Network-based system to detect distracted
drivers and also identify the cause of distraction.
                                                                       13
School of Computing, IIITU[CSL702]: 18111
References
1. Center for disease control and prevention.
https://www.cdc.gov/motorvehiclesafety
distracted_driving/.
2.National highway traffic safety administration
traffic safety facts
https://www.nhtsa.gov/risky-driving/distracted-driving/.
3. State farm distracted driver detection.
https://www.kaggle.com/c/state-farm-distracted-
driver-detection
                                                           14
School of Computing, IIITU[CSL702]: 18111