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