raghuvamsidhar
commited on
Commit
·
3f27b2f
1
Parent(s):
1e14775
Update README.md
Browse files
README.md
CHANGED
@@ -30,8 +30,30 @@ TODO: Add your code
|
|
30 |
|
31 |
|
32 |
```python
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
from huggingface_sb3 import load_from_hub
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
...
|
37 |
```
|
|
|
30 |
|
31 |
|
32 |
```python
|
33 |
+
import gym
|
34 |
+
|
35 |
+
from stable_baselines3 import PPO
|
36 |
+
from stable_baselines3.common.vec_env import DummyVecEnv
|
37 |
+
from stable_baselines3.common.env_util import make_vec_env
|
38 |
+
|
39 |
+
from huggingface_sb3 import package_to_hub
|
40 |
from huggingface_sb3 import load_from_hub
|
41 |
+
repo_id = "raghuvamsidhar/ppo-LunarLander-v2" # The repo_id
|
42 |
+
filename = "PPO-LunarLander-v2-RVD.zip" # The model filename.zip
|
43 |
+
|
44 |
+
# When the model was trained on Python 3.8 the pickle protocol is 5
|
45 |
+
# But Python 3.6, 3.7 use protocol 4
|
46 |
+
# In order to get compatibility we need to:
|
47 |
+
# 1. Install pickle5 (we done it at the beginning of the colab)
|
48 |
+
# 2. Create a custom empty object we pass as parameter to PPO.load()
|
49 |
+
custom_objects = {
|
50 |
+
"learning_rate": 0.0,
|
51 |
+
"lr_schedule": lambda _: 0.0,
|
52 |
+
"clip_range": lambda _: 0.0,
|
53 |
+
}
|
54 |
+
|
55 |
+
checkpoint = load_from_hub(repo_id, filename)
|
56 |
+
model = PPO.load(checkpoint, custom_objects=custom_objects, print_system_info=True)
|
57 |
|
58 |
...
|
59 |
```
|