question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Kaggle + VecVideoRecorder + VecFrameStack

See original GitHub issue

I am trying to record a video of a stacked VecEnv.

test_env = make_atari_env(atari_env_name, n_envs=1, seed=0)
test_env = VecFrameStack(test_env, n_stack=4)

This is the record_video function:

from stable_baselines3.common.vec_env import VecVideoRecorder, DummyVecEnv

def record_video(eval_env, model, video_length=500, prefix='', video_folder=video_folder):
  """
  :param env_id: (str)
  :param model: (RL model)
  :param video_length: (int)
  :param prefix: (str)
  :param video_folder: (str)
  """
  # Start the video at step=0 and record 500 steps
  eval_env = VecVideoRecorder(eval_env, video_folder=video_folder,
                              record_video_trigger=lambda step: step == 0, video_length=video_length,
                              name_prefix=prefix)

  obs = eval_env.reset()
  for _ in range(video_length):
    action, _ = model.predict(obs)
    obs, _, _, _ = eval_env.step(action)

  # Close the video recorder
  eval_env.close()

and I run

record_video(test_env, model, video_length=10000, prefix='a2c_pong')

VecVideoRecorder generates the mp4 file

Saving video to /kaggle/working/videos/a2c_pong-step-0-to-step-10000.mp4

but the file is always just 262 bytes long, regardles of video_length

total 16
drwxr-xr-x 2 root root 4096 Feb 12 16:37 .
drwxr-xr-x 5 root root 4096 Feb 12 16:37 ..
-rw-r--r-- 1 root root 1448 Feb 12 16:43 a2c_pong-step-0-to-step-10000.meta.json
-rw-r--r-- 1 root root  262 Feb 12 16:43 a2c_pong-step-0-to-step-10000.mp4

and the mp4 wont play. Is this an issue with the stacked VecEnv?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
araffincommented, Feb 12, 2021

Hello,

Please fill in the issue template completely (notably your gym version here, may be related to https://github.com/DLR-RM/stable-baselines3/issues/294).

Have you tried with the script from the rl zoo? https://github.com/DLR-RM/rl-baselines3-zoo

0reactions
araffincommented, Feb 15, 2021

solution as for now is to downgrade gym to 0.17.3

or to use gym master version.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Neur4 | Kaggle
Explore and run machine learning code with Kaggle Notebooks | Using data from No attached data sources.
Read more >
DLR-RM/stable-baselines3 - [Bug] Saved video empty - GitHub
Hello. Following this example from the documentation, a video file is generated, but it remains empty. Can you also reproduce the problem? Or...
Read more >
Vectorized Environments - Stable Baselines3 - Read the Docs
VecFrameStack (venv, n_stack, channels_order=None)[source]¶. Frame stacking wrapper for vectorized environment. Designed for image observations.
Read more >
Stable Baselines Documentation - Read the Docs
from stable_baselines.common.vec_env import VecFrameStack from stable_baselines import ACER ... env = VecVideoRecorder(env, video_folder,.
Read more >
README.md · ThomasSimonini/ppo ... - Hugging Face
Use dataset id from https://hf.co/datasets ... from stable_baselines3.common.vec_env import VecFrameStack.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found