lucasschott commited on
Commit
16bf9ed
·
verified ·
1 Parent(s): f8a96b8

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. README.md +14 -0
  2. record.py +25 -0
README.md CHANGED
@@ -30,6 +30,20 @@ This is a Soft Actor Critic (SAC) agent trained on the `HalfCheetah-v5` environm
30
 
31
  See `config.json` for details.
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  ## How to Load
34
 
35
  ```python
 
30
 
31
  See `config.json` for details.
32
 
33
+
34
+ ## Requirements
35
+
36
+ - **Python:** 3.10
37
+
38
+ ### Dependencies
39
+
40
+ ```txt
41
+ gymnasium==1.0.0
42
+ gymnasium[mujoco]
43
+ torch==2.4.0
44
+ stable_baselines3==2.4.1
45
+ ```
46
+
47
  ## How to Load
48
 
49
  ```python
record.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gymnasium as gym
2
+ from stable_baselines3 import SAC
3
+ import imageio
4
+
5
+ if __name__ == "__main__":
6
+
7
+ env = gym.make("HalfCheetah-v5", render_mode="rgb_array")
8
+
9
+ agent = SAC.load("model.zip")
10
+
11
+ frames = []
12
+
13
+ obs, _ = env.reset()
14
+ for _ in range(1000):
15
+ action, _ = agent.predict(obs)
16
+ obs, _, done, _, _ = env.step(action)
17
+ frame = env.render()
18
+ frames.append(frame)
19
+ if done:
20
+ break
21
+
22
+ env.close()
23
+
24
+ # Save as video
25
+ imageio.mimsave("replay.mp4", frames, fps=30)