Views
No views yet
1import gym
2
3from stable_baselines3 import PPO
4from stable_baselines3.common.vec_env import DummyVecEnv
5from stable_baselines3.common.env_util import make_vec_env
6
7from huggingface_sb3 import package_to_hub
8from huggingface_sb3 import load_from_hub
9repo_id = "raghuvamsidhar/ppo-LunarLander-v2" # The repo_id
10filename = "PPO-LunarLander-v2-RVD.zip" # The model filename.zip
11
12# When the model was trained on Python 3.8 the pickle protocol is 5
13# But Python 3.6, 3.7 use protocol 4
14# In order to get compatibility we need to:
15# 1. Install pickle5 (we done it at the beginning of the colab)
16# 2. Create a custom empty object we pass as parameter to PPO.load()
17custom_objects = {
18 "learning_rate": 0.0,
19 "lr_schedule": lambda _: 0.0,
20 "clip_range": lambda _: 0.0,
21}
22
23checkpoint = load_from_hub(repo_id, filename)
24model = PPO.load(checkpoint, custom_objects=custom_objects, print_system_info=True)
25
26...