Pytorch Driving Guardian

Pytorch Driving Guardian

Pytorch powered convolutional neural networks that monitor a driver alertness, emotional state and blind spots through an embedded device and cameras.

Github: GitHub - altaga/Pytorch-Driving-Guardian

Devpost: Pytorch Driving Guardian | Devpost


Driving has become such a daily task for humans in the same level as eating, brushing our teeth or sleeping, however this in turn has become a task that can consume a large part of our day to day, in addition to being a potentially dangerous if certain safety rules are not followed.

Theoretical Support:

The Center for Disease Control and Prevention (CDC) says that 35% of American drivers sleep less than the recommended minimum of seven hours a day. It mainly affects attention when performing any task and in the long term, it can affect health permanently [1].

According to a report by the WHO (World Health Organization) [2], falling asleep while driving is one of the leading causes of traffic accidents. Up to 24% of accidents are caused by falling asleep, and according to the DMV USA (Department of Motor Vehicles) [3] and NHTSA (National Highway traffic safety administration) [4], 20% of accidents are related to drowsiness, being at the same level as accidents due to alcohol consumption with sometimes even worse consequences than those.

Also, the NHTSA mentions that being angry or in an altered state of mind can lead to more dangerous and aggressive driving [5], endangering the life of the driver due to these psychological disorders.


We built a prototype which is capable of performing these 3 monitoring reliably and in addition to being easy to install in any vehicle.

This PoC uses a Jetson Nano 4gb in 5W mode as the main computer to maintain low consumption for continuous use in a vehicle. The Jetson Nano is a mini computer very similar to the RaspberryPi, with the difference that it has a Dedicated GPU enabled with CUDA, in order to run the Pytorch AI models on the GPU.

Jetson Nano Pytorch Support

To visualize the results, an M5core2 was used, which is an IoT device with a screen capable of displaying the data through MQTT.

Full Solution Diagrams:

This is the connection diagram of the system:

The device mounted in the car would look like this.


All the Computer Vision models powered by pytorch are step by step explained here:



The function of this model is to make a detection of distraction or closed eyes of the driver for more than 2 seconds (Drowsiness) or he is distracted from the road (for example, looking at the cell phone).

More Info:

Emotion Detection:


The function of this model is to detect the driver’s emotions at all times and through musical responses (songs) try to correct the driver’s mental state, in order to keep him neutral or in a good mood while driving, thus reducing the risk of accidents.

More Info:

Blind Spot:


The function of this model is to detect objects that are less than 3 meters from the car at the blind spot.

More Info:

The Final Product:

Product installed inside the car:

Epic DEMO:


I would consider the product finished as we only need a little of additional touches in the industrial engineering side of things for it to be a commercial product. Well and also a bit on the Electrical engineering perhaps to use only the components we need. That being said this functions as an upgrade from a project that a couple friends and myself are developing and It was ideal for me to use as a springboard and develop the idea much more. This one has the potential of becoming a commercially available option regarding Smart cities as the transition to autonomous or even smart vehicles will take a while in most cities.

That middle ground between the Analog, primarily mechanical-based private transports to a more “Smart” vehicle is a huge opportunity as the transition will take several years and most people are not able to afford it. Thank you for reading.



  1. Healthy Sleep | MedlinePlus


  3. Press Release - 03-09-2018

  4. Drowsy Driving: Avoid Falling Asleep Behind the Wheel | NHTSA

  5. Speeding and Aggressive Driving Prevention | NHTSA

1 Like