ledmands commited on
Commit
c75318b
1 Parent(s): 956eab4

Added videos of the best model from the most recent run

Browse files
record_video.py CHANGED
@@ -1,12 +1,12 @@
1
  import gymnasium as gym
2
  from stable_baselines3 import DQN
3
- from stable_baselines3.common.monitor import Monitor
4
  from stable_baselines3.common.vec_env import VecVideoRecorder, DummyVecEnv, VecEnv
5
 
6
  model_name = "agents/dqn_v2-8/best_model" # path to model, should be an argument
7
  env_id = "ALE/Pacman-v5"
8
  video_folder = "videos/"
9
- video_length = 100000 #steps by hard coding this, I can almost ensure only one episode is recorded...
10
 
11
  vec_env = DummyVecEnv([lambda: gym.make(env_id, render_mode="rgb_array")])
12
  model = DQN.load(model_name)
@@ -29,11 +29,11 @@ vec_env = VecVideoRecorder(vec_env,
29
  video_folder,
30
  record_video_trigger=lambda x: x == 0,
31
  video_length=video_length,
32
- name_prefix=f"video-{model_name}"
33
  )
34
  # Once I make the environment, now I need to walk through it...???
35
  # I want to act according to the policy that has been trained
36
- obs = vec_env.reset()
37
  print(vec_env)
38
  # for _ in range(video_length + 1):
39
  # action, states = model.predict(obs)
@@ -50,4 +50,5 @@ while end == True:
50
  print("exiting loop")
51
  end = False
52
  # # Save the video
 
53
  vec_env.close()
 
1
  import gymnasium as gym
2
  from stable_baselines3 import DQN
3
+ # from stable_baselines3.common.monitor import Monitor
4
  from stable_baselines3.common.vec_env import VecVideoRecorder, DummyVecEnv, VecEnv
5
 
6
  model_name = "agents/dqn_v2-8/best_model" # path to model, should be an argument
7
  env_id = "ALE/Pacman-v5"
8
  video_folder = "videos/"
9
+ video_length = 10000 #steps by hard coding this, I can almost ensure only one episode is recorded...
10
 
11
  vec_env = DummyVecEnv([lambda: gym.make(env_id, render_mode="rgb_array")])
12
  model = DQN.load(model_name)
 
29
  video_folder,
30
  record_video_trigger=lambda x: x == 0,
31
  video_length=video_length,
32
+ name_prefix="one-episode_v2-8_bestmodel"
33
  )
34
  # Once I make the environment, now I need to walk through it...???
35
  # I want to act according to the policy that has been trained
36
+ vec_env.reset()
37
  print(vec_env)
38
  # for _ in range(video_length + 1):
39
  # action, states = model.predict(obs)
 
50
  print("exiting loop")
51
  end = False
52
  # # Save the video
53
+
54
  vec_env.close()
videos/one-episode_v2-8_bestmodel-step-0-to-step-10000.meta.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"step_id": 0, "content_type": "video/mp4"}
videos/one-episode_v2-8_bestmodel-step-0-to-step-10000.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3884da6b0fbf91b475e9fa9bc9ea1d5a9771c89dba1ca699a22f6ec4cc5de6db
3
+ size 178260
videos/v2-8_bestmodel-step-0-to-step-10000.meta.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"step_id": 0, "content_type": "video/mp4"}
videos/v2-8_bestmodel-step-0-to-step-10000.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cf95394d8893382c21a7fa1f03a16ad1393fcb0804de19a076ef7adaaa032819
3
+ size 1458975