Hugging Face integration

The Hugging Face (HF) Hub is a platform for building, training, and deploying ML models, as well as accessing a variety of datasets and metrics for further analysis and validation.



Integration


Download model from HF Hub

Several skrl-trained models (agent checkpoints) for different environments/tasks of Gym/Gymnasium, Isaac Gym, Omniverse Isaac Gym, etc. are available in the Hugging Face Hub

These models can be used as comparison benchmarks, for collecting environment transitions in memory (for offline reinforcement learning, e.g.) or for pre-initialization of agents for performing similar tasks, among others

Visit the skrl organization on the Hugging Face Hub to access publicly available models!


API

skrl.utils.huggingface.download_model_from_huggingface(repo_id: str, filename: str = 'agent.pt') str

Download a model from Hugging Face Hub

Parameters:
  • repo_id (str) – Hugging Face user or organization name and a repo name separated by a /

  • filename (str, optional) – The name of the model file in the repo (default: "agent.pt")

Raises:
  • ImportError – The Hugging Face Hub package (huggingface-hub) is not installed

  • huggingface_hub.utils._errors.HfHubHTTPError – Any HTTP error raised in Hugging Face Hub

Returns:

Local path of file or if networking is off, last version of file cached on disk

Return type:

str

Example:

# download trained agent from the skrl organization (https://huggingface.co/skrl)
>>> from skrl.utils.huggingface import download_model_from_huggingface
>>> download_model_from_huggingface("skrl/OmniIsaacGymEnvs-Cartpole-PPO")
'/home/user/.cache/huggingface/hub/models--skrl--OmniIsaacGymEnvs-Cartpole-PPO/snapshots/892e629903de6bf3ef102ae760406a5dd0f6f873/agent.pt'

# download model (e.g. "policy.pth") from another user/organization (e.g. "org/ddpg-Pendulum-v1")
>>> from skrl.utils.huggingface import download_model_from_huggingface
>>> download_model_from_huggingface("org/ddpg-Pendulum-v1", "policy.pth")
'/home/user/.cache/huggingface/hub/models--org--ddpg-Pendulum-v1/snapshots/b44ee96f93ff2e296156b002a2ca4646e197ba32/policy.pth'