Kaggle + VecVideoRecorder + VecFrameStack
See original GitHub issueI 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:
- Created 3 years ago
- Comments:11 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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
or to use gym master version.