IacopomC / CarND-Behavioral-Cloning-P3

CNN model to drive autonomously a car in a simulator using Keras

Home Page:https://iacopomc.github.io/projects/2020-08-03-behavioral-cloning-project/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Behavioral Cloning Project

Udacity - Self-Driving Car NanoDegree

This repository contains my implementation of the homonymous open source project part of the Udacity - Self-Driving Car NanoDegree.

For a step by step walkthrough of the project see here

Dependencies

This project requires:

The lab enviroment can be created with CarND Term1 Starter Kit. Click here for the details.

The project includes the following files:

  • behavioral_cloning.ipynb 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
  • model_aug containing a trained convolution neural network with more data collected

The simulator can be downloaded here

Installation

Clone the Github Repository and run each cell contained in the Jupiter Notebook behavioral_cloning.ipynb

git clone https://github.com/IacopomC/CarND-Behavioral-Cloning-P3
cd CarND-Behavioral-Cloning-P3
jupyter notebook behavioral_cloning.ipynb

Functional Code

Usage of drive.py requires you have saved the trained model as an h5 file, i.e. model.h5. To do so, run the jupyter notebook behavioral_cloning.ipynb.

Once the model has been saved, it can be used with drive.py using this command:

python drive.py model.h5

and then run the simulator.

The above command will load the trained model and use the model to make predictions on individual images in real-time and send the predicted angle back to the server via a websocket connection.

Note: There is known local system's setting issue with replacing "," with "." when using drive.py. When this happens it can make predicted steering values clipped to max/min values. If this occurs, a known fix for this is to add "export LANG=en_US.utf8" to the bashrc file.

Saving a video of the autonomous agent

python drive.py model.h5 run1

The fourth argument, run1, is the directory in which to save the images seen by the agent. If the directory already exists, it'll be overwritten.

ls run1

[2017-01-09 16:10:23 EST]  12KiB 2017_01_09_21_10_23_424.jpg
[2017-01-09 16:10:23 EST]  12KiB 2017_01_09_21_10_23_451.jpg
[2017-01-09 16:10:23 EST]  12KiB 2017_01_09_21_10_23_477.jpg
[2017-01-09 16:10:23 EST]  12KiB 2017_01_09_21_10_23_528.jpg
...

The image file name is a timestamp of when the image was seen. This information is used by video.py to create a chronological video of the agent driving. Executing the command:

python video.py run1

creates a video based on images found in the run1 directory. The name of the video will be the name of the directory followed by '.mp4', so, in this case the video will be run1.mp4.

Optionally, one can specify the FPS (frames per second) of the video:

python video.py run1 --fps 48

Will run the video at 48 FPS. The default FPS is 60.

About

CNN model to drive autonomously a car in a simulator using Keras

https://iacopomc.github.io/projects/2020-08-03-behavioral-cloning-project/

License:MIT License


Languages

Language:Jupyter Notebook 65.0%Language:Python 31.0%Language:Shell 4.0%