Downloads · 30 days
0
0% of all-time downloads
MohanadMetrash/ppo-LunarLander-v3
ppo-LunarLander-v3 is a reinforcement learning model from MohanadMetrash. 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 LunarLander-v3 using the stable-baselines3 library.
Downloads · 30 days
0
0% of all-time downloads
All-time downloads
19
Public
Repo size
284 KB
Likes
0
Public
Click a slice to open those files.
.zip150 KB · 39%
From the Hugging Face model README
This is a trained model of a PPO agent playing LunarLander-v3 using the stable-baselines3 library.
import gymnasium as gym
from stable_baselines3 import PPO
from huggingface_sb3 import load_from_hub
# --- Load the model from the Hugging Face Hub ---
# The repo_id is the name of the model repository on the Hub
repo_id = "MohanadMetrash/ppo-LunarLander-v3"
# The filename is the name of the saved model zip file
filename = "ppo-LunarLander-v3.zip"
# Download the model from the Hub and load it into a PPO object
checkpoint = load_from_hub(repo_id, filename)
model = PPO.load(checkpoint)
# --- Use the trained agent ---
# Create a new environment for the agent to play in
# "human" render_mode opens a window to display the environment
env = gym.make("LunarLander-v3", render_mode="human")
# Reset the environment to get the initial observation
obs, info = env.reset()
# Run the agent in the environment for 1000 steps
for _ in range(1000):
# The model predicts the best action to take based on the observation
action, _states = model.predict(obs, deterministic=True)
# The environment takes the action and returns the next observation, reward, etc.
obs, reward, terminated, truncated, info = env.step(action)
# If the episode is finished (the lander has landed or crashed), reset the environment
if terminated or truncated:
print("Episode finished. Resetting environment.")
obs, info = env.reset()
env.close()