Views
No views yet
1import gymnasium as gym
2from stable_baselines3 import PPO
3from stable_baselines3.common.env_util import make_vec_env
4from huggingface_sb3 import load_from_hub
5
6# Load the model
7model_name = "LunarLander-v2"
8model_path = load_from_hub(repo_id="ch-bz/ppo-" + model_name, filename=model_name + ".zip")
9model = PPO.load(model_path)
10
11# Demonstrate the model with 4 parallel instances
12vec_env = make_vec_env(model_name, n_envs=4)
13
14obs = vec_env.reset()
15while True:
16 action, _states = model.predict(obs)
17 obs, rewards, dones, info = vec_env.step(action)
18 vec_env.render("human")