GithubHelp home page GithubHelp logo

axionautv2's Introduction

AxionautV2 - DIY Robocar Tricks and Hacks

The Axionaut is the winner of the second IronCar France robocar competition. The following repository contains all the tricks we used to win. The final Keras model achieves more than 98% of accuracy on the validation set. The provided autopilot model will work seamlessly with Vincent's IronCar framework.

Introduction

The Axionaut is based on a 4x4 Radio Controlled (RC) monster truck chassis, the complete bill of materials is available here: https://www.axionable.com/axionaut-termine-1er-de-la-deuxieme-course-iron-car/

The following code and documentation will guide you through the best practices and tricks to train the car. All strategies were defined both searching on the Internet and by experimentation. So, are you ready to win your next race?

Finding the right camera position

Make sure to put the camera such that the three lanes are always visible. Also, crop the original image to keep only the track. The position and crop level depends on your vehicle and the camera you are using. In our case, the image was cropped to [90, 250, 3] and the camera was placed at 20cm from the floor. We recommend the use of eyefish cameras.

It is normally easy to know when the camera is not in the right position. Here an useful example, make sure to check your training data before training your model. Once you found a good fit, fix the camera. alt text

Training the vehicle

Once you found the right camera position, it is necessary to build your own dataset. We built ours with approximately 60K images with labels verified by inspection. Taking the data directly from the car can add noise due contradictory examples and lack of synchronization, as we make mistakes or anticipate curves while driving. To avoid that, we took images directly from the car and we assigned the labels after using a script. Finally, all labels were manually inspected to assure its quality. The final dataset (2.9GB) including both IronCar track and proper data is avaliable here.

The images were labeled as follows: alt text

If the labels are consistent, your training and validation accuracy should increase importantly. It is because the labels respect the inner structure of your data. If you get that, you are in a good path :)

Data augmentation

Augmenting your data is a good way to improve the generalisation capabilities of your model. There is a lot of information about this on the Internet. We took some functions and we added some more to easily allow you to generate new data. All functions are available in thefunctions.py script.

alt text

Data preparation

Before training your model, it is necessary to balance the number of examples per class. Doing so, you will avoid biases, ensuring a smooth driving behavior in almost all road conditions. In general, we try to preserve a 1:1 ratio between curves and straights examples, we also give less frequency to very hard turns. It is recommended to test the car after training a model with balanced data, see if it learned well to go straight, turn left and right. If there is a task it does not perform well, just add more data of that class and train again. After a few iterations your car will be ready to run on any track :).

A good way to see the global distribution of your data is the histogram. In the Data Preparation.ipynb jupyter notebook, you will find some code examples to balance your own dataset using Pandas.

alt text

The model

The proposed architecture is a slightly modified version of the PilotNet published by Nvidia. This architecture is powerful to modelize all possible driving situations while simple enough to run on the raspberry pi 3 B+. Dropout of 10% was added on two classifier layers to avoid overfitting.

Code Exemple

The python train.py script allows to train a driving model using the aforementioned architecture and dataset. By default, the script will save the best model snapshot after each epoch if the validation loss decreased. Normally, the default settings works well, however you can freely modify the settings according the following examples:

Start training with default settings: python train.py

List of parameters:

  1. --augmentation: Use data augmentation functions, default True.
  2. --val_split: Validation split, default 0.2.
  3. --epochs: Number of training epochs, default 100.
  4. --batch_size: Size of batch, default 64 images.
  5. --early_stop: Use early stop, default True.
  6. --patience: Maximum number of epochs without loss improvement, default 5.

To train your own driving model: python train.py --augmentation True --epochs 10 --batch_size 128 --patience 5

The snapshot model is saved in the Models/checkpoint_model.hdf5 folder. The final model is stored in the current folder as final_model.hdf5.

Feel free to explore and set your prefered training hyperparameters!

Installation

Clone repository to your laptop: git clone https://github.com/Axionable/AxionautV2

Install required libraries: pip install -r requirements.txt

Download the training dataset and put it in the Dataset folder: Dataset

Contribute

Axionaut is totally free and open for everyone to use, please feel free to contribute!

About Axionable

Axionable is a leading Data Science and Data Consulting firm based in Paris, France. For knowing more about our projects and careers please visit our website. Follow us on Twitter.

axionautv2's People

Contributors

nfsrules 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.