Git Product home page Git Product logo

wandb-jetracer's Introduction

๐Ÿ๐ŸŽ๏ธ๐Ÿ’จ = W&B โž• NVIDIA Jetracer

tests flake8 Lint codecov

A picture of the car along with it's POV

This project builds on top of the NVIDIA Jetracer project to instrument it with Weights&Biases, making it easier to train, evaluate and refine models.
It features a full pipeline to effortlessly collect_data, label it, train/optimize models and finally drive the car while monitoring how the model is doing.

Weights&Biases Artifacts' graph showing the whole pipeline.

Pipeline overview

The repo is meant to be used by running (and modifying!) scripts under src/wandb_jetracer/scripts. These allow to train a model to detect the center of the racetrack which we can then feed to a control policy to drive the car.

  1. collect_data.py will take pictures using the car's camera and upload them to Weights&Biases. It should be ran while manually driving the car around.
  2. label.py is a labelling utiliy. It will download the images from the previous step to a computer to annotate them with the relevant labels. The labels will then be added to the dataset stored on Weights&Biases servers.
  3. Open In Colabwandb_jetracer_training.ipynb is used to download the same dataset, train a model and upload it's weights to WandB.
  4. trt_optim is meant to be ran on the car. It will convert the latest trained model to TensorRT for inference.
  5. drive.py will take the optimized model and use it to drive the car. It will also log sensor data (IMU, Camera), system metrics (jetson stats, inference time) as well as the control signal to WandB. This helps with monitoring the model's perfomances in production.

Building the car

Check out NVIDIA Jetracer.

Setup and dependencies

These scripts are ran on three different types of machine: the actual embedded jetson nano computer on the car, a machine used for labelling and a colab instance used for training.
They all relie on different dependencies:

  • Training dependencies are installed in the Colab notebook so you don't need to worry about those.
  • Labelling dependencies can be installed in a conda env using conda create -f labelling_env.yml
  • Dependencies for the car are slightly trickier to get right, you'll find instructions here. Feel free to open issues if you run into troubles!

Disclaimer about default throttle values:

Even though default throttle values are set in the scripts under /src/scripts I would recommend testing those while the car is on a stand and it's wheels are not touching the ground. Depending on how your ESC was calibrated a throttle value of 0.0002 might mean going full reverse and your car might fly off into a wall.

Testing

After installing the labelling dependencies run pytest

Footnote

Feel free to open GitHub issues if you have any questions!

Ressources

wandb-jetracer's People

Contributors

armandpl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

wandb-jetracer's Issues

Make improvements to argparser

  1. use f-strings for the help strings and put in the default values e.g.
default_debug_time = 120
parser.add_argument(...
    help=f"how long should it run for in seconds. Default is {default_debug_time}.")
  1. use action=store_true for boolean flags: https://docs.python.org/3/library/argparse.html#action. Fixes bug with --debug boolean handling.

  2. add help strings for all arguments. Use consistent formatting.

  3. run python --help and look at what gets printed, make changes as needed. Ordering/aesthetics/clarity.

Download current version of the dataset before adding to it

In the current code we write images to an output directory and then add the directory to a wandb artifact.

The goal of this script is to incrementally increase the size of the dataset, thus we need to add to it each time it is run, not create a new one including only the new images. It must include the old images AND the new images.
To do so, first download the latest dataset version (in the setup function?) and set that as the directory in which to write new images.
Once the new images are written, add this dir as a wandb artifact.

https://github.com/Armandpl/wandb_jetracer/blob/d99f98194ae2e0ab0d970b1337748bc2458f7a05/collect_data.py#L37

Add flake8 and/or black to your Python dev env

Linting is super crucial to good team Python coding practice. Interacts with version control. flake8 inside your editor gives you hints as you're working (on saves, tells you where there's errors/warnings). black will auto-resolve these errors. can add it to pre-commit hooks if you want (for git).

Investigate interaction with local artifacts

If I create an artifact, and log it to wandb I end up with an artifact on wandb servers and on my local machine.
If I then delete this artifact from wandb server (but not my local machine), then instanciate a new artifact with the same name, add files to it and log it to wandb it will contain the content from the version that was deleted on wandb servers but not locally.
This a behavior that might be confusing for users. When I delete the artifact from wandb servers I feel like it's gone forever.

https://github.com/Armandpl/wandb_jetracer/blob/75cefd6e2a8bfe992719d51c3782802e1d299597/collect_data.py#L68
https://github.com/Armandpl/wandb_jetracer/blob/75cefd6e2a8bfe992719d51c3782802e1d299597/label.py#L113

Rewrite inference with OpenAI gym

If this is a good idea, use hooks/callbacks to do logging, and

  • watch out for state that needs to be passed around
  • package logging up very tightly -- separate e.g. jetson logging from image logging from accelerometer logging (as separate callbacks?) -- rather than combining things that are coincidentally logged at the same time/with the same hook

Decide how to handle magic numbers/constants/config and implement

Option 1: make these command line arguments (adds extra complexity that might not be needed)
Option 2: set the values in code to "global" variables (with all-caps names) at top of the file. Right after imports, do STEERING_GAIN = -1 etc. etc. (very very simple, allow re-use, but complicates scope [especially bad for mutable values like lists/dicts] and is hard to change)
Option 3: use configparser to configure these values from files, add a config pointer argument to argparse (with sensible default). (adds some weight/complexity, adds dependence on an additional file, adds another library that's relatively new to python [i think?], but is most flexible/sensible and is a good skill to learn).

https://github.com/Armandpl/wandb_jetracer/blob/dc4fdbbf3a00ae7f0b773016a8c673132beb3eac/inference.py#L41-L44

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.