lit_sb3.huggingface.load_from_hub
source module lit_sb3.huggingface.load_from_hub
Download models from the HuggingFace Hub.
Integrates:
load_from_hub: thin HF download function, adapted from https://github.com/huggingface/huggingface_sb3/blob/main/huggingface_sb3/load_from_hub.pydownload_from_hub: RL-Zoo3-format downloader, adapted from https://github.com/DLR-RM/rl-baselines3-zoo/blob/master/rl_zoo3/load_from_hub.py
Functions
-
load_from_hub — Download a single file from the HuggingFace Hub.
-
download_from_hub — Download a model from the HuggingFace Hub and save it in RL-Zoo3 format.
source load_from_hub(repo_id: str, filename: str) → str
Download a single file from the HuggingFace Hub.
Adapted from https://github.com/huggingface/huggingface_sb3/blob/main/huggingface_sb3/load_from_hub.py
:param repo_id: Repository id from the HuggingFace Hub
(e.g. "sb3/ppo-CartPole-v1").
:param filename: Name of the file to download from the repository.
:return: Local path to the downloaded file.
:raises ImportError: If huggingface_hub is not installed.
Raises
-
ImportError
source download_from_hub(algo: str, env_name: EnvironmentName, exp_id: int, folder: str, organization: str, repo_name: str | None = None, force: bool = False) → None
Download a model from the HuggingFace Hub and save it in RL-Zoo3 format.
Adapted from https://github.com/DLR-RM/rl-baselines3-zoo/blob/master/rl_zoo3/load_from_hub.py
Default repo is {organization}/{algo}-{env_id} where
repo_name = {algo}-{env_id}.
:param algo: Algorithm name (e.g. "ppo").
:param env_name: Environment name.
:param exp_id: Experiment ID (0 = auto-increment to latest + 1).
:param folder: Root log folder.
:param organization: HuggingFace organisation name.
:param repo_name: Override the default {algo}-{env_id} repository name.
:param force: Allow overwriting if the target folder already exists.
:raises ImportError: If huggingface_hub is not installed.
:raises ValueError: If the target folder already exists and force is False.
Raises
-
ValueError