Views
No views yet
1from stable_baselines3 import PPO
2from huggingface_sb3 import load_from_hub
3import gym
4
5# Define model repo_id and filename
6repo_id = "mavleo96/rl-bots" # Change this to the actual repo if different
7filename = "ppo-LunarLander-v2.zip"
8
9# Load the model from the Hugging Face Hub
10model = load_from_hub(repo_id, filename, model_class=PPO)
11
12# Create the environment
13env = gym.make("LunarLander-v2")
14
15# Run a few episodes
16obs = env.reset()
17for _ in range(1000):
18 action, _states = model.predict(obs, deterministic=True)
19 obs, reward, done, info = env.step(action)
20 env.render()
21 if done:
22 obs = env.reset()
23
24env.close()