Views
No views yet
1pip install stable-baselines3 huggingface_sb3 panda_gym shimmy
2
3Then you can load and evaluate the model:
4
5```python
6from huggingface_sb3 import load_from_hub
7from stable_baselines3 import A2C
8from stable_baselines3.common.vec_env import DummyVecEnv, VecNormalize
9
10# Load the model and statistics
11repo_id = "LuckLin/a2c-PandaReachDense-v3"
12filename = "a2c-PandaReachDense-v3.zip"
13
14checkpoint = load_from_hub(repo_id, filename)
15model = A2C.load(checkpoint)
16
17# Load the normalization statistics
18stats_path = load_from_hub(repo_id, "vec_normalize.pkl")
19env = DummyVecEnv([lambda: gym.make("PandaReachDense-v3")])
20env = VecNormalize.load(stats_path, env)
21
22# At test time, we don't update the stats
23env.training = False
24env.norm_reward = False
25
26# Evaluate
27obs = env.reset()
28for _ in range(1000):
29 action, _states = model.predict(obs, deterministic=True)
30 obs, rewards, dones, info = env.step(action)
31 env.render()
32