Skip to content

Commit

Permalink
First Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
adityaguptai committed Oct 9, 2018
1 parent 1ec73a0 commit 1f0ae54
Show file tree
Hide file tree
Showing 19 changed files with 562 additions and 2 deletions.
27 changes: 25 additions & 2 deletions README.md 100644 → 100755
@@ -1,2 +1,25 @@
# Self-Driving-Car-
A End to End Model which predicts the steering wheel angle based on the video/image
# Self Driving Car (End to End CNN/Dave-2)
![alt img](https://cdn-images-1.medium.com/max/868/0*7dReqQXElneHBWUr.jpg)
Please so refer the [Self Driving Car Notebook](./Self_Driving_Car_Notebook.ipynb) for complete Information and Visualization

A TensorFlow/Keras implementation of this [Nvidia paper](https://arxiv.org/pdf/1604.07316.pdf) with some changes.

### How to Use
Download Dataset by Sully Chen: [https://drive.google.com/file/d/0B-KJCaaF7elleG1RbzVPZWV4Tlk/view]
Size: 25 minutes = 25{min} x 60{1 min = 60 sec} x 30{fps} = 45,000 images ~ 2.3 GB

Note: You can run without training using the pretrained model if short of compute resources

Use `python3 train.py` to train the model

Use `python3 run.py` to run the model on a live webcam feed

Use `python3 run_dataset.py` to run the model on the dataset

To visualize training using Tensorboard use `tensorboard --logdir=./logs`, then open http://0.0.0.0:6006/ into your web browser.

### Credits & Inspired By
(1) https://github.com/SullyChen/Autopilot-TensorFlow<br>
(2) Research paper: End to End Learning for Self-Driving Cars by Nvidia. [https://arxiv.org/pdf/1604.07316.pdf]<br>
(3) Nvidia blog: https://devblogs.nvidia.com/deep-learning-self-driving-cars/ <br>
(4) https://devblogs.nvidia.com/explaining-deep-learning-self-driving-car/
240 changes: 240 additions & 0 deletions Self_Driving_Car_Notebook.ipynb
@@ -0,0 +1,240 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
},
"colab_type": "code",
"collapsed": true,
"id": "XHFnthirwlfn"
},
"source": [
"# Self Driving Car using (End to End CNN/Dave-2)\n",
"![alt img](https://cdn-images-1.medium.com/max/868/0*7dReqQXElneHBWUr.jpg)\n",
"* Used convolutional neural networks (CNNs) to map the raw pixels from a front-facing camera to the steering commands for a self-driving car. This powerful end-to-end approach means that with minimum training data from humans, the system learns to steer, with or without lane markings, on both local roads and highways. The system can also operate in areas with unclear visual guidance such as parking lots or unpaved roads.\n",
"* The system is trained to automatically learn the internal representations of necessary processing steps, such as detecting useful road features, with only the human steering angle as the training signal. We do not need to explicitly trained it to detect, for example, the outline of roads.\n",
"* End-to-end learning leads to better performance and smaller systems. Better performance results because the internal components self-optimize to maximize overall system performance, instead of optimizing human-selected intermediate criteria, e. g., lane detection. Such criteria understandably are selected for ease of human interpretation which doesn’t automatically guarantee maximum system performance. Smaller networks are possible because the system learns to solve the problem with the minimal number of processing steps.\n",
"* It is also called as DAVE-2 System by Nvidia\n",
"\n",
"Watch Real Car Running Autonoumously using this Algorithm\n",
"https://www.youtube.com/watch?v=NJU9ULQUwng"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Credits & Inspired By\n",
"(1) https://github.com/SullyChen/Autopilot-TensorFlow<br>\n",
"(2) Research paper: End to End Learning for Self-Driving Cars by Nvidia. [https://arxiv.org/pdf/1604.07316.pdf]<br>\n",
"(3) Nvidia blog: https://devblogs.nvidia.com/deep-learning-self-driving-cars/ <br>\n",
"(4) https://devblogs.nvidia.com/explaining-deep-learning-self-driving-car/"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Conclusions from the paper\n",
"* This demonstrated that CNNs are able to learn the entire task of lane and road following without manual decomposition into road or lane marking detection, semantic abstraction, path planning, and control.The system learns for example to detect the outline of a road without the need of explicit labels during training. \n",
"* A small amount of training data from less than a hundred hours of driving was sufficient to train the car to operate in diverse conditions, on highways, local and residential roads in sunny, cloudy, and rainy conditions. \n",
"* The CNN is able to learn meaningful road features from a very sparse training signal (steering alone).\n",
"* More work is needed to improve the robustness of the network, to find methods to verify the robust- ness, and to improve visualization of the network-internal processing steps."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Other Larger Datasets you can train on\n",
"(1) Udacity: https://medium.com/udacity/open-sourcing-223gb-of-mountain-view-driving-data-f6b5593fbfa5<br>\n",
"70 minutes of data ~ 223GB<br>\n",
"Format: Image, latitude, longitude, gear, brake, throttle, steering angles and speed<br>\n",
"(2) Udacity Dataset: https://github.com/udacity/self-driving-car/tree/master/datasets [Datsets ranging from 40 to 183 GB in different conditions]<br>\n",
"(3) Comma.ai Dataset [80 GB Uncompressed] https://github.com/commaai/research<br>\n",
"(4) Apollo Dataset with different environment data of road: http://data.apollo.auto/?locale=en-us&lang=en<br>\n",
"### Some other State of the Art Implementations\n",
"Implementations: https://github.com/udacity/self-driving-car<br>\n",
"Blog: https://medium.com/udacity/teaching-a-machine-to-steer-a-car-d73217f2492c<br><br>"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"# Imports\n",
"import numpy\n",
"import matplotlib.pyplot as plt\n",
"from __future__ import division\n",
"import os\n",
"import random\n",
"\n",
"from scipy import pi\n",
"from itertools import islice\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
},
"colab_type": "code",
"id": "vgcc6iQobKHi"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Completed processing data.txt\n"
]
}
],
"source": [
"# read images and steering angles from driving_dataset folder\n",
"\n",
"DATA_FOLDER = './driving_dataset/' # change this to your folder\n",
"TRAIN_FILE = os.path.join(DATA_FOLDER, 'data.txt')\n",
"\n",
"\n",
"split =0.8 #Train = 80%\n",
"X = []\n",
"y = []\n",
"with open(TRAIN_FILE) as fp:\n",
" for line in fp:\n",
" path, angle = line.strip().split()\n",
" full_path = os.path.join(DATA_FOLDER, path)\n",
" X.append(full_path)\n",
" \n",
" # converting angle from degrees to radians\n",
" y.append(float(angle) * pi / 180 )\n",
"\n",
"\n",
"y = np.array(y)\n",
"print(\"Completed processing data.txt\")\n",
"\n",
"split_index = int(len(y)*0.8)\n",
"\n",
"train_y = y[:split_index]\n",
"test_y = y[split_index:]\n",
"\n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### PDF of steering angle in radians in train and test "
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAEbJJREFUeJzt3W2MpWV9x/Hvr7vrsy6NTCLdhzk0Els1KjpBrElDxKZICbwQU0zqUzWbGlEhJq3ahAVf1bQRNBjNKlasxIcgNavBKkaN+gJ0wRWF1WYrc2QrDSvIIvUpa/99cc7ocPbMnjMzZ/bMXPv9JCd7P1xzn//NLr+5znXu+7pTVUiS2vIH0y5AkjR5hrskNchwl6QGGe6S1CDDXZIaZLhLUoMMd0lqkOEuSQ0y3CWpQZun9cannnpqdTqdab29JG1It99++0+ramZUu6mFe6fTYd++fdN6e0nakJJ0x2nnsIwkNchwl6QGGe6S1CDDXZIaZLhLUoMMd0lqkOEuSQ0aGe5JHpfkW0m+m+SuJFcNafPaJIeT7O+/3rA25UqSxjHOTUy/Bl5SVY8k2QJ8M8kXqurWgXafqqpLJ1+iJGm5Rvbcq+eR/uqW/sunaq93nQ4kvZfTPEgnnbHG3JNsSrIfuB+4papuG9Ls5UnuTHJjkh1LHGdXkn1J9h0+fHgVZWukbheqeq/uWHcrS2rIWOFeVb+tqucB24Gzkjx7oMnngE5VPQf4MnD9EsfZU1VzVTU3MzNy3htJ0got62qZqnoI+Bpw3sD2B6rq1/3VDwEvmEh1kqQVGedqmZkkp/SXHw+8FPjBQJvTFq1eCByYZJGSpOUZ52qZ04Drk2yi98vg01X1+STvAvZV1V7gLUku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 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
" \n",
"plt.hist(train_y, bins=50, density=True, color='green', histtype ='step');\n",
"plt.hist(test_y, bins=50, density=True, color='red', histtype ='step');\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Model 0: Baseline Model [Predicted Value = Mean Value]"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Test_MSE(MEAN):0.191127\n",
"Test_MSE(ZERO):0.190891\n"
]
}
],
"source": [
"#y_test_pred = mean(y_train_i) \n",
"train_mean_y = np.mean(train_y)\n",
"\n",
"# Predicted value as mean value\n",
"print('Test_MSE(MEAN):%f' % np.mean(np.square(test_y-train_mean_y)) )\n",
"\n",
"#Predicted value as zero\n",
"print('Test_MSE(ZERO):%f' % np.mean(np.square(test_y-0.0)) )"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"source": [
"##### We are getting quite okay Mean Squared Error(MSE) with even dumb model of predicted value as mean value or 0"
]
}
],
"metadata": {
"accelerator": "GPU",
"colab": {
"collapsed_sections": [],
"default_view": {},
"name": "Self_driving_car.ipynb",
"provenance": [],
"version": "0.3.2",
"views": {}
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.6"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
60 changes: 60 additions & 0 deletions driving_data.py
@@ -0,0 +1,60 @@
import scipy.misc
import random

xs = []
ys = []

#points to the end of the last batch
train_batch_pointer = 0
val_batch_pointer = 0

#read data.txt
with open("driving_dataset/data.txt") as f:
for line in f:
# Saving the location of each image in xs
xs.append("driving_dataset/" + line.split()[0])
#the paper by Nvidia uses the inverse of the turning radius,
#but steering wheel angle is proportional to the inverse of turning radius
#so the steering wheel angle in radians is used as the output

# Converting steering angle which we need to predict from radians
# to degrees for fast computation
ys.append(float(line.split()[1]) * scipy.pi / 180)

#get number of images
num_images = len(xs)

# To change the train and test ratio do it here
# Here Train -> 80% and Test -> 20%
train_xs = xs[:int(len(xs) * 0.8)]
train_ys = ys[:int(len(xs) * 0.8)]

val_xs = xs[-int(len(xs) * 0.2):]
val_ys = ys[-int(len(xs) * 0.2):]

num_train_images = len(train_xs)
num_val_images = len(val_xs)

def LoadTrainBatch(batch_size):
# Train batch pointer allows we use subsequent ahead images for train
# Rather than using random images from train data as we train the model
# on batches of data rather thatn whole data at each epoch
global train_batch_pointer
x_out = []
y_out = []
for i in range(0, batch_size):
#Resizing and Converting image in ideal form to train
x_out.append(scipy.misc.imresize(scipy.misc.imread(train_xs[(train_batch_pointer + i) % num_train_images])[-150:], [66, 200]) / 255.0)
y_out.append([train_ys[(train_batch_pointer + i) % num_train_images]])
train_batch_pointer += batch_size
return x_out, y_out

def LoadValBatch(batch_size):
global val_batch_pointer
x_out = []
y_out = []
for i in range(0, batch_size):
x_out.append(scipy.misc.imresize(scipy.misc.imread(val_xs[(val_batch_pointer + i) % num_val_images])[-150:], [66, 200]) / 255.0)
y_out.append([val_ys[(val_batch_pointer + i) % num_val_images]])
val_batch_pointer += batch_size
return x_out, y_out
Binary file added logs/events.out.tfevents.1538972216.Cyanamac
Binary file not shown.
Binary file added logs/events.out.tfevents.1539017583.Cyanamac
Binary file not shown.
Binary file added logs/events.out.tfevents.1539031365.Cyanamac
Binary file not shown.

0 comments on commit 1f0ae54

Please sign in to comment.