Code Monkey home page Code Monkey logo

car-behavioral-cloning-with-pytorch's Introduction

Car Behavioral Cloning using Pytorch

Overview

I create this project after watching Siraj's video about how to simulate a self-driving car. Instead using Keras to build a model, I want to using Pytorch for the model and training.

The repo is inspired by naokishibuya. I adapt his augmentation methods.

Video demo:

Screenshot

Youtube link

Challenges:

  • I think the most challenge is generating enough data for your model. For some tricky curves on the road, you need to creat more data.
  • Building a model in Pytorch is not as straighforward as in Keras. You need to understand the framework and how it processes data first.
  • Need to create a Dataloader for your own data.
  • Re-use as much code as possible.

What has been done so far

  • Created the Dataloader for car dataset
  • Created the CarModel for training with the dataset. The model is based on The NVIDIA model.
  • Created another Simple Car Model by reducing the number of Convolutional and Linear layers.
  • Modified drive.py so that it can load the Pytorch model.
  • After training Simple Model around 15 epochs, the model can drive a car for one full lap without any crashing.
  • I save two model, the first model is saved when the validation loss is lowest, the second model is saved after training phase stop. As I notice, the second model is quite smoother than the first one.
  • Working models are put inside working_models dir

Model summary:

  (module): CarSimpleModel (
    (conv_layers): Sequential (
      (0): Conv2d(3, 24, kernel_size=(3, 3), stride=(2, 2), bias=False)
      (1): ELU (alpha=1.0)
      (2): Conv2d(24, 48, kernel_size=(3, 3), stride=(2, 2), bias=False)
      (3): MaxPool2d (size=(4, 4), stride=(4, 4), dilation=(1, 1))
      (4): Dropout (p = 0.25)
    )
    (linear_layers): Sequential (
      (0): Linear (3648 -> 50)
      (1): ELU (alpha=1.0)
      (2): Linear (50 -> 10)
      (3): Linear (10 -> 1)
    )

Notes

  • Training the neural network

Training the model

  • After trained, the network is able to generate steering commands from the video images of a single center camera.

generate steering

  • Testing the model with the Simulator

Testing the model

Dependencies

  • You can install all dependencies by running conda:
conda env create -f environments.yml
  • Note: I've removed tensorflow in this file
  • After that, you need to install Pytorch
  • To run up the server, you need to download Udacity Self-Driving Car Simulator. (using Autonomous Mode when trying your model)

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.