Downloads · 30 days
0
0% of all-time downloads
trewby/ppo-CartPole-v1
ppo-CartPole-v1 is a reinforcement learning model from trewby. Use it for the reinforcement learning task on the model card, and read the license before you ship it in a product. It is set up for stable-baselines3.
This is a trained model of a PPO agent playing CartPole-v1 using the stable-baselines3 library.
Downloads · 30 days
0
0% of all-time downloads
All-time downloads
8
Public
Repo size
264 KB
Likes
0
Public
Click a slice to open those files.
.zip138 KB · 41%
From the Hugging Face model README
This is a trained model of a PPO agent playing CartPole-v1 using the stable-baselines3 library.
Trained on CartPole-v1 in Colab as part of the Hugging Face deep RL course; Box2D environments (for example LunarLander) can be unreliable on Colab’s current Python runtime, so CartPole is used for a clean, reproducible baseline.
import gymnasium as gym
from stable_baselines3 import PPO
from huggingface_sb3 import load_from_hub
# Download model files from the Hub
checkpoint_path = load_from_hub(
repo_id="trewby/ppo-CartPole-v1",
filename="ppo-CartPole-v1.zip",
)
# Load the model
model = PPO.load(checkpoint_path)
# Run one episode
env = gym.make("CartPole-v1", render_mode="human") # use "rgb_array" if you do not want a window
obs, info = env.reset()
done = False
while not done:
action, _ = model.predict(obs, deterministic=True)
obs, reward, terminated, truncated, info = env.step(action)
done = terminated or truncated
env.close()