Autonomous Vehicle: Self Driving Car Simulator

Autonomous Vehicle: Self Driving Car Simulator

Hello, today we will talk about the simple working of self-driving cars using python and deep learning. We will create a convolutional neural network in the Keras framework that will detect the road and automatically turn the steering as per the path.

Let’s Get Started

First of all, we need to download the dataset for the self-driving autonomous car to train our convolutional neural network so that it can learn the features of the road and navigate according to the road. One can download the dataset from here which is publicly available created by Udacity. After downloading data, we need to train the CNN on the downloaded data. To do this, first, make sure that you have all the necessary libraries installed on your machine. Following is the list of libraries.

  • numpy
  • matplotlib
  • opencv-python
  • keras
  • h5py
  • scipy
  • tensorflow

OR I have created the requirements.txt file which you can install all the required libraries with only one command instead of installing every single library. You can get the code from here.

pip install -r requirements.txt

After installing all the libraries, we need to convert our data i.e. images to NumPy arrays so that it can be fed to the CNN so that it gets trained. We have to run the file. Edit the below dataset path as per your downloaded path in your machine. Otherwise, you will face an error.

features_directory = ‘../../data/’
labels_file = ‘../../data/driving_log.csv’

After changing the path, we will transform our images to NumPy array by running the


Now, we will train CNN architecture on the transformed dataset.


After the training gets completed, automatically the model with their weights will get saved in the models directory which is knowledge of the model learned. Now, it’s the testing time. I already have the video saved in the directory resources. To run the simulator,



You can see when the steering is straight the output value is 0.00. If the steering turns the left side then the values are negative and steering turns right the values are positive. This is a simple understanding simulator created by Udacity which gives us an idea of how the self-driving car works on autopilot mode.

If you are facing in the training the CNN and directly see the output instead of training the CNN. No worries!!! You can directly run the file. As I have already trained and saved the weights to the projects. Moreover, if you have low processing power then the simulator might take time to run and it may lag. But if you have a good processing power machine then it will run smoothly. Moreover, you can access the code from the library sandbox public machine. One can access it from here. Thank you for reading the article.🙂✌️