Gym: FAQ should explain how to export to video

Created on 7 Dec 2018  路  3Comments  路  Source: openai/gym

I've read through the whole readme and the docs and the FAQ and I can't actually find an explanation of how to export the render to a video file.

I don't even know where to look for help on this. Is this a gym thing? If I'm running a keras-rl example then is this a Keras thing? Or is this something for the particular algorithm I'm choosing from keras? Or is this something for each environment (e.g. cartpole)? The FAQ or README should explain the interaction between these libraries better. I'm quite lost.

A lot of issues for gym seem to be about exporting video, but none of them contain MWEs.

This part of the README is too brief. (e.g. how do I specify a filename?)

Most helpful comment

@mlda065 It's kinda lengthy but I found a way to export as video. To your training code add:
(I've done this for CartPole-v0)
env_to_wrap = gym.make('CartPole-v0')
env = wrappers.Monitor(env_to_wrap, 'your directory here', force = True)
observation = env.reset()

env.close()
env_to_wrap.close()

Writing force = True replaces your existing recording with current recording in the mentioned directory.

Hope that clears :)

All 3 comments

Ah, I kind of figured it out. A bit. (It only exports some runs, and I don't know how to export as a GIF)

I just updated the FAQ with what I know.

Can someone check what I wrote, or add to it?

@mlda065 It's kinda lengthy but I found a way to export as video. To your training code add:
(I've done this for CartPole-v0)
env_to_wrap = gym.make('CartPole-v0')
env = wrappers.Monitor(env_to_wrap, 'your directory here', force = True)
observation = env.reset()

env.close()
env_to_wrap.close()

Writing force = True replaces your existing recording with current recording in the mentioned directory.

Hope that clears :)

Thanks for updating the wiki @mlda065!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Ettrig picture Ettrig  路  3Comments

reaIws picture reaIws  路  4Comments

RuofanKong picture RuofanKong  路  3Comments

Kallin picture Kallin  路  4Comments

Spiral-Galaxy picture Spiral-Galaxy  路  3Comments