ThomasSimonini HF staff commited on
Commit
bea7037
1 Parent(s): 7f6050c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +41 -1
README.md CHANGED
@@ -4,4 +4,44 @@ tags:
4
  - reinforcement-learning
5
  - stable-baselines3
6
  ---
7
- # TODO: Fill this model card
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  - reinforcement-learning
5
  - stable-baselines3
6
  ---
7
+
8
+ This is a pre-trained model of a PPO agent playing CartPole-v1 using the [stable-baselines3](https://github.com/DLR-RM/stable-baselines3) library.
9
+
10
+ ### Usage (with Stable-baselines3)
11
+ Using this model becomes easy when you have stable-baselines3 and huggingface_sb3 installed:
12
+
13
+ ```
14
+ pip install stable-baselines3
15
+ pip install huggingface_sb3
16
+ ```
17
+
18
+ Then, you can use the model like this:
19
+
20
+ ```python
21
+ import gym
22
+
23
+ from huggingface_sb3 import load_from_hub
24
+ from stable_baselines3 import PPO
25
+ from stable_baselines3.common.evaluation import evaluate_policy
26
+
27
+ # Retrieve the model from the hub
28
+ ## repo_id = id of the model repository from the Hugging Face Hub (repo_id = {organization}/{repo_name})
29
+ ## filename = name of the model zip file from the repository
30
+ checkpoint = load_from_hub(
31
+ repo_id="sb3/demo-hf-CartPole-v1",
32
+ filename="ppo-CartPole-v1",
33
+ )
34
+ model = PPO.load(checkpoint)
35
+
36
+ # Evaluate the agent and watch it
37
+ eval_env = gym.make("CartPole-v1")
38
+ mean_reward, std_reward = evaluate_policy(
39
+ model, eval_env, render=True, n_eval_episodes=5, deterministic=True, warn=False
40
+ )
41
+ print(f"mean_reward={mean_reward:.2f} +/- {std_reward}")
42
+ ```
43
+
44
+ ### Evaluation Results
45
+ Mean_reward: 500.0
46
+
47
+