metadata
library_name: stable-baselines3
tags:
- FetchPushDense-v4
- deep-reinforcement-learning
- reinforcement-learning
- stable-baselines3
model-index:
- name: TQC
results:
- task:
type: reinforcement-learning
name: reinforcement-learning
dataset:
name: FetchPushDense-v4
type: FetchPushDense-v4
metrics:
- type: mean_reward
value: '-2.02 +/- 1.19'
name: mean_reward
verified: false
license: mit
language:
- en
TQC Agent playing FetchPushDense-v4
Then, you can load the model using the following Python code:
import gymnasium as gym
from sb3_contrib import TQC
from stable_baselines3.common.env_util import make_vec_env
gymnasium.register_envs(gymnasium_robotics)
# Load the trained model
model = TQC.load("best-model.zip")
# Create the environment
env = make_vec_env("FetchPushDense-v4", n_envs=1)
# Reset the environment
obs, info = env.reset()
# Enjoy the trained agent
for _ in range(1000):
action, _states = model.predict(obs, deterministic=True)
obs, rewards, terminated, truncated, info = env.step(action)
if terminated or truncated:
obs, info = env.reset()
env.render()
env.close()
Hugging Face Hub
You can also use the Hugging Face Hub to load the model. First, you need to install the Hugging Face Hub library:
pip install huggingface_hub
Then, you can load the model from the hub using the following code:
from huggingface_hub import hf_hub_download
import torch as th
from sb3_contrib import TQC
from stable_baselines3.common.env_util import make_vec_env
gymnasium.register_envs(gymnasium_robotics)
# Download the model from the Hub
model_path = hf_hub_download(repo_id="kuds/fetch-push-dense-tqc", filename="best-model.zip")
# Load the model
model = TQC.load(model_path)
# Create the environment
env = make_vec_env("FetchPushDense-v4", n_envs=1)
# Enjoy the trained agent
obs = env.reset()
for i in range(1000):
action, _states = model.predict(obs, deterministic=True)
obs, rewards, dones, info = env.step(action)
env.render("human")