Recently a famous NFL player, father and mother were both involved in a very serious car crash. His father died, while his mother remains in the ICU with serious injuries. Amongst young people, specifically under the age of 30, road accidents are the leading cause of death. When we were brainstorming projects, we thought of this event and realized there are no current solutions which can help people prevent accidents. Thus we decided to create Innovate Driving to help prevent and reduce the number of accidents on the road for drivers, bikers, and pedestrians, along with predicting accident severity in order to help accident management processes such as first responder response times and resource management, ultimately saving lives.

What it does

Our Project has three core features. The first is the map, the second is an accident severity predictor, and our third feature is detecting if a driver is distracted or not, which can figure out what specifically the driver is doing that is making them distracted. All three features utilize machine learning. The map is a heatmap, which uses a neural network to show certain cities and the risk of an accident on the streets. Based on a user selected city, the website will display a heatmap, which shows areas that have a high chance of an accident. From here users are informed about which streets to avoid and which to be more cautious around. Many accidents occur due to weather in addition to a variety of reasons which create crash hotspots. Crash hotspots are important because they suggest that there is a constant factor that results in more crashes than other locations. This can then alert drivers to avoid driving at marked crash hotspots, so they reduce the chances that they, themselves, are involved in a crash, ultimately saving lives.

The second feature of our project is that it predicts the severity of an accident by the location and time. A user can input a location and time, and based on specific locations, weather, time, and other features, we are able to predict how severe accidents would be. We are able to do this with a random forest model. By predicting the severity of accidents in certain locations, we can give our findings to city planners and workers, who can then create eye catching signs that notify drivers of what locations and during what times have the highest risk of severe accidents. This will make sure that drivers will drive carefully during these times and areas, thus reducing the number of accidents and saving lives. Our crash severity prediction model can also be used to relay vital information to first responders before they arrive on the scene. Based on location, if first responders know the severity of the accident beforehand, they can bring more or less resources in order to better accommodate those in need and also know whether they need to drive extremely high speeds to get to the accident. Accident severity prediction is a key step in the accident management process and governments can use this information to take effective measures to reduce accident impacts and improve traffic safety. This would not only help the common people, but cities and governments as well.

Our last feature is detecting whether or not a driver is distracted or not. The model intakes a picture of a driver from inside the car. Using a CNN model we are able to detect a distracted driver and what they are doing. If they are classified as distracted we can separate them into 4 of the most common reasons for being distracted. Using their phone, radio, drinking/eating, or using their mirror. Although our model is fully functional and can classify images of drivers at an extremely accurate rate, this feature is more of a proof of concept as we would need to have access to cameras inside of cars and from there alert the driver to keep their eyes on the road. About 3,000 people die from distracted driving every year, and with our model, we would be able to reduce the number of distracted drivers immensely and save countless lives.

How we built it

Our website was built with four main languages. HTML, CSS, and JS for our frontend, and JS and Python for our backend and model development. We used countless models from a library in python known as Scikit-learn alongside a CNN and neural network.

The accident heatmap was created using a neural network and was trained on data from a few select urban areas. Because it was hard to find data and due to time constraints, we had to stick to just a few areas for now. We found our data from an article and trained our model on it. The data consists of road infrastructure, weather feeds, speed limits, traffic congestion to predict accident risk per street. However, with more data we would be able to incorporate this for more cities.

For our accident severity predictor we tried many different models in order to achieve the highest accuracy possible. The inputs for the model were the location, and time. We split the location into latitude and longitude, whereas time was split into the date, month, year, and hour. We needed all these features as based on the time, accident severities can change drastically. Location is a huge factor as well as weather. Different locations have different climates especially based on the time of year. All of these factors combined can make the severity of an accident extremely different. We fit a decision tree classifier, random forest, SVM, a linear SVM, logistic regression, MultinomialNB, and a Knn. The logistic regression and MultinomialNB models performed extremely poorly only producing an accuracy around 55-60%, however the SVM had a 73%. Ultimately we decided to use the Random Forest model as it had the highest accuracy of 95%. In order to implement our model to our website, we had to use flask to get the user input and then put it into the model then finally display the output. With flask we were able to have the user input values and when they click submit, we display the predicted accident severity.

The distracted driver section uses a Convolutional Neural Network model in order to break down the photo into many layers. Through training the CNN model learns what to look for, and filters the picture so it can figure out what is going on. Our Model was trained on an extreme amount of pictures of drivers doing certain things. The model has 5 categories it can classify an image as. Attentive, using phone, using radio, eating/drinking, and using mirror. Since all of these can be differentiated based on what the hand is doing, the CNN is able to figure that out and focuses on the hand placement. After final testing the model performed extremely well and had very few false negatives, where the driver was distracted but our model thought they were attentive. We also used flask here in order to download the user's file to a local drive and then put the file through the model. Because it would take a very long time and maybe even impossible to have a perfectly accurate model, we decided to have our model have more false positives than false negatives as we would rather be safe than sorry and alert them when they were already paying attention.

Our last page contains visuals we have used throughout the project in order to get a better understanding of our models and which features are useful. We also have a confusion matrix from our distracted driver model so we are able to see how many false positives and false negatives we have. Lastly, we hosted our website with Google Cloud's Firebase.

Challenges we ran into

Finding data for the map was a struggle. Because we needed very detailed data we were only able to create functionality for a select few metropolitan areas. On top of this rendering a new heatmap after a user selects the location, so we decided to not deploy our heatmap models to the web, but rather just the heatmaps.

As we had never used flask before, deploying our model for predicting severity was difficult. We had to read a lot of documentation and go through a lot of trial and error. The main issue was getting the inputs from the user as we had to form separate inputs into a single dataframe and then put it through the model. However, after quite a bit of testing we were able to get it fully functional.

Accomplishments that we're proud of

We are proud of creating a fully functional web app using machine learning, which is able to truly help people and save lives. We are extremely proud of developing a solution that has never been previously considered or implemented in this setting and developing a working model.

What we learned

We had to learn how to use flask as well as new machine learning models. Because we had never deployed a live machine learning model to the web none of us knew how to use flask. Therefore this experience was completely new. On top of this, we strengthened our skills with CNN's for our distracted driver model and used three new models we had never used before for the accident severity predictor.

What's next for Innovate-Driving

Currently our project is suited for the common person and everyday use, however in addition to this we want to give our project to local and state governments so they can take steps to improve roads and reduce risks of crashes.

We also would like to work with first responders, so they can use our project to gain vital information about accidents before they arrive at the scene. Giving our project to city planners would allow for them to make effective signs, which notify drivers when and where crashes are the most severe, which will prompt them to drive more carefully.

We plan on partnering with car manufacturers for our distracted driver feature so they can install a camera which feeds directly into our model and their cars can have an alert system similar to a seatbelt system when our model senses that the driver is distracted and only stops once it senses the driver is no longer distracted.

Built With

Share this project: