ashna022 commited on
Commit
7ea7e0c
·
1 Parent(s): 53c29e9

Update README with usage code

Browse files
Files changed (1) hide show
  1. README.md +13 -4
README.md CHANGED
@@ -26,12 +26,21 @@ This is a trained model of a **PPO** agent playing **LunarLander-v2**
26
  using the [stable-baselines3 library](https://github.com/DLR-RM/stable-baselines3).
27
 
28
  ## Usage (with Stable-baselines3)
29
- TODO: Add your code
30
-
31
 
32
  ```python
33
- from stable_baselines3 import ...
 
 
34
  from huggingface_sb3 import load_from_hub
35
 
36
- ...
 
 
 
 
 
 
 
 
 
37
  ```
 
26
  using the [stable-baselines3 library](https://github.com/DLR-RM/stable-baselines3).
27
 
28
  ## Usage (with Stable-baselines3)
 
 
29
 
30
  ```python
31
+ from stable_baselines3 import PPO
32
+ from stable_baselines3.common.env_util import make_vec_env
33
+ from stable_baselines3.common.evaluation import evaluate_policy
34
  from huggingface_sb3 import load_from_hub
35
 
36
+ # Get model
37
+ repo_id = "ashna022/ppo-lunarLander"
38
+ filename = "ppo-lunarLander"
39
+ checkpoint = load_from_hub(repo_id, filename)
40
+ model = PPO.load(checkpoint, custom_objects=custom_objects, print_system_info=True)
41
+
42
+ # Evaluate
43
+ eval_env = Monitor(gym.make("LunarLander-v2"))
44
+ mean_reward, std_reward = evaluate_policy(model, eval_env, n_eval_episodes=10, deterministic=True)
45
+ print(f"mean_reward={mean_reward:.2f} +/- {std_reward}")
46
  ```