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