Update README.md
Browse files
README.md
CHANGED
|
@@ -30,8 +30,28 @@ TODO: Add your code
|
|
| 30 |
|
| 31 |
|
| 32 |
```python
|
| 33 |
-
from stable_baselines3 import
|
| 34 |
from huggingface_sb3 import load_from_hub
|
|
|
|
| 35 |
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
```
|
|
|
|
| 30 |
|
| 31 |
|
| 32 |
```python
|
| 33 |
+
from stable_baselines3 import PPO
|
| 34 |
from huggingface_sb3 import load_from_hub
|
| 35 |
+
import gym
|
| 36 |
|
| 37 |
+
# Define model repo_id and filename
|
| 38 |
+
repo_id = "mavleo96/rl-bots" # Change this to the actual repo if different
|
| 39 |
+
filename = "ppo-LunarLander-v2.zip"
|
| 40 |
+
|
| 41 |
+
# Load the model from the Hugging Face Hub
|
| 42 |
+
model = load_from_hub(repo_id, filename, model_class=PPO)
|
| 43 |
+
|
| 44 |
+
# Create the environment
|
| 45 |
+
env = gym.make("LunarLander-v2")
|
| 46 |
+
|
| 47 |
+
# Run a few episodes
|
| 48 |
+
obs = env.reset()
|
| 49 |
+
for _ in range(1000):
|
| 50 |
+
action, _states = model.predict(obs, deterministic=True)
|
| 51 |
+
obs, reward, done, info = env.step(action)
|
| 52 |
+
env.render()
|
| 53 |
+
if done:
|
| 54 |
+
obs = env.reset()
|
| 55 |
+
|
| 56 |
+
env.close()
|
| 57 |
```
|