Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added pytorch tutorial #219

Open
wants to merge 2 commits into
base: gh-pages
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 29 additions & 12 deletions _pages/quick_start/tutorial.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Behavior Metrics tutorial using Tensoflow <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/2/2d/Tensorflow_logo.svg/1200px-Tensorflow_logo.svg.png" alt="TF logo" width="50"/>
title: Behavior Metrics tutorial using Tensoflow <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/2/2d/Tensorflow_logo.svg/1200px-Tensorflow_logo.svg.png" alt="TF logo" width="50"/> and PyTorch <img src="https://pytorch.org/assets/images/pytorch-logo.png" alt="Pytorch logo" width="50"/>
layout: posts
permalink: /quick_start/tutorial
permalink: /quick_start/tutorial/

collection: posts

Expand All @@ -14,31 +14,48 @@ sidebar:

In this tutorial, you will train your first follow line brain for the F1 that can be run on Behavior Metrics.

1. First of all, make sure you have Behavior Metrics installed, following the [installation section](/install/). You can try running the *explicit brain* that is
**Step 1.** First of all, make sure you have Behavior Metrics installed, following the [installation section](/install/). You can try running the *explicit brain* that is
already included on Behavior Metrics brains folder. This brain is capable of finishing every circuit available for the project.

2. All the deep learning brains with their code can be located at [Deep Learning Studio's repo](https://github.com/JdeRobot/DeepLearningStudio).
**Step 2.** All the deep learning brains with their code can be located at [Deep Learning Studio's repo](https://github.com/JdeRobot/DeepLearningStudio).
For this tutorial, we will be using PilotNet architecture, a CNN based solution for self-driving cars. You can navigate to the previous repo to the
[Formula 1-Follow line folder](https://github.com/JdeRobot/DeepLearningStudio/tree/main/Formula1-FollowLine), where both implementations for pytorch and tensorflow are located.
We will use tensorflow <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/2/2d/Tensorflow_logo.svg/1200px-Tensorflow_logo.svg.png" alt="TF logo" width="20"/> .

3. Follow the step on that repo for generating a new deep learning model using tensorflow and PilotNet. On that repo you will find information about how to download the dataset
First, we will use tensorflow <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/2/2d/Tensorflow_logo.svg/1200px-Tensorflow_logo.svg.png" alt="TF logo" width="20"/> .

1. Follow the step on that repo for generating a new deep learning model using tensorflow and PilotNet. On that repo you will find information about how to download the dataset
and how to train the model. Using the examples shown there should be fine for this tutorial (you can explore different combinations afterwards 😄).

4. After training your first tensorflow model for the follow line problem, you will have a *.h5* file generated by the previous execution.
2. After training your first tensorflow model for the follow line problem, you will have a *.h5* file generated by the previous execution.

5. Take that *.h5* file and store it on *behavior_metrics/models/* creating a new folder *tensorflow_models*.
3. Take that *.h5* file and store it on *behavior_metrics/models/* creating a new folder *tensorflow_models*.

6. We're almost ready to go. Modify the *DL-tensorflow.yml* file under *behavior_metrics/configs/* folder, changing the *Model:* '[your_model_name].h5' with your model name.
4. We're almost ready to go. Modify the *DL-tensorflow.yml* file under *behavior_metrics/configs/* folder, changing the *Model:* '[your_model_name].h5' with your model name.

7. Execute Behavior Studio with the command
5. Execute Behavior Studio with the command

```
python3 driver.py -c configs/default.yml -g
python3 driver.py -c configs/DL-tensorflow.yml -g
```

and your done. Press the **PLAY** button shown on the GUI and the f1 should be running!

**NOTE:** If you find any problem running this tutorial, create an issue on [Behavior Metrics repo](https://github.com/JdeRobot/BehaviorMetrics/issues/new) so we can help you.
Second, we will use pytorch <img src="https://pytorch.org/assets/images/pytorch-logo.png" alt="Pytorch logo" width="50"/>.

1. Follow step 1 of the above Tensorflow <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/2/2d/Tensorflow_logo.svg/1200px-Tensorflow_logo.svg.png" alt="TF logo" width="20"/> tutorial.

2. After training your first pytorch model for the follow line problem, you will have a *.ckpt* file generated by the previous execution.

3. Take that *.ckpt* file and store it on *behavior_metrics/models/* creating a new folder *torch_models*.

4. We're almost ready to go. Modify the *DL-torch.yml* file under *behavior_metrics/configs/* folder, changing the *Model:* '[your_model_name].ckpt' with your model name.

5. Execute Behavior Studio with the command

```
python3 driver.py -c configs/DL-torch.yml -g
```

and your done. Press the **PLAY** button shown on the GUI and the f1 should be running!

**NOTE:** If you find any problem running this tutorial, create an issue on [Behavior Metrics repo](https://github.com/JdeRobot/BehaviorMetrics/issues/new) so we can help you.