Git Product home page Git Product logo

carnd-behavioral-clone's Introduction

Behavioral Cloning

CarND Starter Kit

Install the car nanodegree starter kit if you have not already done so: carnd starter kit

Project introduction

This project finished drive the car around the track in the simulator, collect the data and use the data train a deep learning neural network, then make the car drive autumatically.

The goals / steps of this project are the following:

  • Use the simulator to collect data of good driving behavior
  • Build, a convolution neural network in Keras that predicts steering angles from images
  • Train and validate the model with a training and validation set
  • Test that the model successfully drives around track one without leaving the road
  • Summarize the results with a written report

My project includes the following files:

  • model.py containing the script to create and train the model
  • drive.py for driving the car in autonomous mode
  • model.h5 containing a trained convolution neural network
  • writeup_report.md or writeup_report.pdf summarizing the results

Run project

Udacity Driving Simulator and drive.py file he car can be driven autonomously around the track by executing python drive.py model.h5 , Here is the simulator interface.

Train the Model

Collect train data

In order to start collecting training data, you'll need to do the following:

  • Enter Training Mode in the simulator.
  • Start driving the car to get a feel for the controls.
  • When you are ready, hit the record button in the top right to start recording.
  • Continue driving for a few laps or till you feel like you have enough data.
  • Hit the record button in the top right again to stop recording.

This simulator has two sense, they are differen terrains. make sure driver the car in the center of the road as much as possible. I track data into two different folder, data1 for t Track1 and data2 for the Track2 in the simulator which make me collect the data clearly. I rename them data1 and data2, Here is the folder image.

Data augmentation

The data record folder has a csv file for recording images' name, steering, throttle, break and speed, and IMG floder for recording cameras' datas(center, left and right). Here is an example image of center lane driving:

alt text

In the simulator there are three cameras for center, left, right which capture images to capture driver's behavior. For convenience, the left steering and right steering add or subtract the correction factor correction = 0.2 for the left camera and the right camera.

As we can see, the 75px above and 20px below are not ROI area, and will affect the analysis of the network structure on the image.

alt text

so I crop the image and left the area in the middle and a little below. keras.layers.Cropping2D function crops the image easyly, Here is the code model.add(Cropping2D(cropping=((75, 20), (0,0)))).

Before training the model, we will augment the data in case of insufficient data. so I use cv2.flip flip image. Here are the example,the right is fliped:

But I don't think it's a good idea to flip all the images because of drive behaviour, so I just need to flip some photos randomly and control them by `np.random.rand() < 0.5`. When the data is flipped, steering data need to be multiplied by -1.

Model architecture

I use End-to-End Deep Learning for Self-Driving Cars model which designed by NVIDIA.

My model architecture is shown in the following table:

Layer filter stride activation
Image Normalizaion
Cropping2D(cropping=(75,20),(0,0))
Convolution 5X5X24 2 relu
Convolution 5X5X36 2 relu
Convolution 5X5X48 2 relu
Convolution 3X3X64 1 relu
Convolution 3X3X48 1 relu
Flatten()
Dropout(0.5)
Dense(50) relu
Dense(10) relu
output = Dense(1)

Training and Validation

Before training, I randomly assigned data and epoch=3 to avoid overfitting. 80% of the data is used for training, and 20% for validation.

Epoch 1/3
87009/87009 [==============================] - 181s - loss: 0.0692 - val_loss: 0.05
Epoch 2/3
87009/87009 [==============================] - 171s - loss: 0.0521 - val_loss: 0.051
Epoch 3/3
87009/87009 [==============================] - 171s - loss: 0.0495 - val_loss: 0.049
Training Finish!
Time:  526.0187499523163

carnd-behavioral-clone's People

Contributors

aaronmayue avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.