mirror of
https://github.com/saymrwulf/stable-baselines3.git
synced 2026-09-17 22:30:59 +00:00
Fixes
This commit is contained in:
parent
0274aaf056
commit
37a942c8f9
1 changed files with 46 additions and 35 deletions
|
|
@ -53,7 +53,7 @@ Most of them are available via the RL Zoo.
|
||||||
Official pre-trained models are saved in the SB3 organization on the hub: https://huggingface.co/sb3
|
Official pre-trained models are saved in the SB3 organization on the hub: https://huggingface.co/sb3
|
||||||
|
|
||||||
We wrote a tutorial on how to use 🤗 Hub and Stable-Baselines3
|
We wrote a tutorial on how to use 🤗 Hub and Stable-Baselines3
|
||||||
`here <https://colab.research.google.com/github/huggingface/huggingface_sb3/blob/main/notebooks/sb3_huggingface.ipynb>`_
|
`here <https://colab.research.google.com/github/huggingface/huggingface_sb3/blob/main/notebooks/sb3_huggingface.ipynb>`_.
|
||||||
|
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
|
|
@ -63,6 +63,19 @@ Installation
|
||||||
|
|
||||||
pip install huggingface_sb3
|
pip install huggingface_sb3
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
If you use the `RL Zoo <https://github.com/DLR-RM/rl-baselines3-zoo>`_, pushing/loading models from the hub is integrated in the RL Zoo:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
# Download model and save it into the logs/ folder
|
||||||
|
python -m rl_zoo3.load_from_hub --algo a2c --env LunarLander-v2 -orga sb3 -f logs/
|
||||||
|
# Test the agent
|
||||||
|
python -m rl_zoo3.enjoy --algo a2c --env LunarLander-v2 -f logs/
|
||||||
|
# push model, config and hyperparameters to the hub
|
||||||
|
python -m rl_zoo3.push_to_hub --algo a2c --env LunarLander-v2 -f logs/ -orga sb3 -m "Initial commit"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Download a model from the Hub
|
Download a model from the Hub
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
|
@ -95,8 +108,8 @@ For instance ``sb3/demo-hf-CartPole-v1``:
|
||||||
|
|
||||||
You need to define two parameters:
|
You need to define two parameters:
|
||||||
|
|
||||||
- `repo-id`: the name of the Hugging Face repo you want to download.
|
- ``repo-id``: the name of the Hugging Face repo you want to download.
|
||||||
- `filename`: the file you want to download.
|
- ``filename``: the file you want to download.
|
||||||
|
|
||||||
|
|
||||||
Upload a model to the Hub
|
Upload a model to the Hub
|
||||||
|
|
@ -104,9 +117,9 @@ Upload a model to the Hub
|
||||||
|
|
||||||
You can easily upload your models using two different functions:
|
You can easily upload your models using two different functions:
|
||||||
|
|
||||||
1. `package_to_hub()`: save the model, evaluate it, generate a model card and record a replay video of your agent before pushing the complete repo to the Hub.
|
1. ``package_to_hub()``: save the model, evaluate it, generate a model card and record a replay video of your agent before pushing the complete repo to the Hub.
|
||||||
|
|
||||||
2. `push_to_hub()`: simply push a file to the Hub.
|
2. ``push_to_hub()``: simply push a file to the Hub.
|
||||||
|
|
||||||
|
|
||||||
First, you need to be logged in to Hugging Face to upload a model:
|
First, you need to be logged in to Hugging Face to upload a model:
|
||||||
|
|
@ -128,11 +141,14 @@ First, you need to be logged in to Hugging Face to upload a model:
|
||||||
|
|
||||||
Then, in this example, we train a PPO agent to play CartPole-v1 and push it to a new repo ``sb3/demo-hf-CartPole-v1``
|
Then, in this example, we train a PPO agent to play CartPole-v1 and push it to a new repo ``sb3/demo-hf-CartPole-v1``
|
||||||
|
|
||||||
With package_to_hub()
|
With ``package_to_hub()``
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
|
from stable_baselines3 import PPO
|
||||||
|
from stable_baselines3.common.env_util import make_vec_env
|
||||||
|
|
||||||
from huggingface_sb3 import package_to_hub
|
from huggingface_sb3 import package_to_hub
|
||||||
|
|
||||||
# Create the environment
|
# Create the environment
|
||||||
|
|
@ -159,20 +175,24 @@ With package_to_hub()
|
||||||
|
|
||||||
You need to define seven parameters:
|
You need to define seven parameters:
|
||||||
|
|
||||||
- `model`: your trained model.
|
- ``model``: your trained model.
|
||||||
- `model_architecture`: name of the architecture of your model (DQN, PPO, A2C, SAC…).
|
- ``model_architecture``: name of the architecture of your model (DQN, PPO, A2C, SAC…).
|
||||||
- `env_id`: name of the environment.
|
- ``env_id``: name of the environment.
|
||||||
- `eval_env`: environment used to evaluate the agent.
|
- ``eval_env``: environment used to evaluate the agent.
|
||||||
- `repo-id`: the name of the Hugging Face repo you want to create or update. It’s <your huggingface username>/<the repo name>.
|
- ``repo-id``: the name of the Hugging Face repo you want to create or update. It’s <your huggingface username>/<the repo name>.
|
||||||
- `commit-message`.
|
- ``commit-message``.
|
||||||
- `filename`: the file you want to push to the Hub.
|
- ``filename``: the file you want to push to the Hub.
|
||||||
|
|
||||||
With push_to_hub()
|
With ``push_to_hub()``
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
from huggingface_sb3 import package_to_hub
|
|
||||||
|
from stable_baselines3 import PPO
|
||||||
|
from stable_baselines3.common.env_util import make_vec_env
|
||||||
|
|
||||||
|
from huggingface_sb3 import push_to_hub
|
||||||
|
|
||||||
# Create the environment
|
# Create the environment
|
||||||
env_id = "CartPole-v1"
|
env_id = "CartPole-v1"
|
||||||
|
|
@ -197,20 +217,11 @@ With push_to_hub()
|
||||||
commit_message="Added CartPole-v1 model trained with PPO",
|
commit_message="Added CartPole-v1 model trained with PPO",
|
||||||
)
|
)
|
||||||
|
|
||||||
# This method save, evaluate, generate a model card and record a replay video of your agent before pushing the repo to the hub
|
|
||||||
package_to_hub(model=model,
|
|
||||||
model_name="ppo-CartPole-v1",
|
|
||||||
model_architecture="PPO",
|
|
||||||
env_id=env_id,
|
|
||||||
eval_env=eval_env,
|
|
||||||
repo_id="sb3/demo-hf-CartPole-v1",
|
|
||||||
commit_message="Push ppo-CartPole-v1 model to the Hub")
|
|
||||||
|
|
||||||
You need to define three parameters:
|
You need to define three parameters:
|
||||||
|
|
||||||
- `repo-id`: the name of the Hugging Face repo you want to create or update. It’s <your huggingface username>/<the repo name>.
|
- ``repo-id``: the name of the Hugging Face repo you want to create or update. It’s <your huggingface username>/<the repo name>.
|
||||||
- `filename`: the file you want to push to the Hub.
|
- ``filename``: the file you want to push to the Hub.
|
||||||
- `commit-message`.
|
- ``commit-message``.
|
||||||
|
|
||||||
MLFLow
|
MLFLow
|
||||||
======
|
======
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue