Downloads · 30 days
4
3% of all-time downloads
kuds/atari-breakout-v4-ppo
atari-breakout-v4-ppo is a reinforcement learning model from kuds. 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.
- Github Repository - Google Colab Notebook - Finding Theta - Blog Post
Downloads · 30 days
4
3% of all-time downloads
All-time downloads
145
Public
Repo size
20.7 MB
Likes
0
Public
Click a slice to open those files.
.zip20.7 MB · 100%
From the Hugging Face model README
Then, you can load the model using the following Python code:
import gymnasium as gym
from stable_baselines3 import PPO
from stable_baselines3.common.env_util import make_atari_env
from stable_baselines3.common.vec_env import VecTransposeImage
from stable_baselines3.common.atari_wrappers import WarpFrame
# Load the trained model
model = PPO.load("best-model.zip")
# Create the environment
env = make_atari_env("BreakoutNoFrameskip-v4", n_envs=1)
env = VecFrameStack(env, n_stack=4)
env = VecTransposeImage(env)
# 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()
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
import gymnasium as gym
from stable_baselines3 import PPO
from stable_baselines3.common.env_util import make_atari_env
from stable_baselines3.common.vec_env import VecTransposeImage
from stable_baselines3.common.atari_wrappers import WarpFrame
# Download the model from the Hub
model_path = hf_hub_download(repo_id="kuds/atari-breakout-v4-ppo", filename="best-model.zip")
# Load the model
model = PPO.load(model_path)
# Create the environment
env = make_atari_env("BreakoutNoFrameskip-v4", n_envs=1)
env = VecFrameStack(env, n_stack=4)
env = VecTransposeImage(env)
# 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")
env.close()