Views
No views yet
stable-baselines3 and huggingface_sb3 installed. You can install them using pip:1pip install stable-baselines3 huggingface_sb3 gymnasium
2
3
4```python
5from huggingface_sb3 import load_from_hub
6from stable_baselines3 import PPO
7import gymnasium as gym
8
9# Identifier for the repository and model file name
10repo_id = "TyurinYuriRost/ppo-LunarLander-v2"
11filename = "ppo-LunarLander-v2.zip"
12
13# Load the model checkpoint from Hugging Face Hub
14checkpoint = load_from_hub(repo_id=repo_id, filename=filename)
15
16# Load the PPO model
17model = PPO.load(checkpoint)
18
19# Create the environment for evaluation
20env = gym.make("LunarLander-v3", render_mode="human")
21obs = env.reset()
22
23# Visualize the model's performance
24for _ in range(1000):
25 action, _states = model.predict(obs)
26 obs, rewards, dones, info = env.step(action)
27 env.render()
28 if dones:
29 obs = env.reset()
30
31# Close the environment
32env.close()