Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python OpenAI gym monitor creates json files in the recording directory

I am implementing value iteration on the gym CartPole-v0 environment and would like to record the video of the agent's actions in a video file. I have been trying to implement this using the Monitor wrapper but it generates json files instead of a video file in the recording directory. This is my code:

env = gym.make('FrozenLake-v0')
env = gym.wrappers.Monitor(env, 'recording', force=True)
env.seed(0)
optimalValue = valueIteration(env)
st = time.time()
policy = cal_policy(optimalValue)
policy_score = evaluate_policy(env, policy)
et = time.time()
env.close()
print('Best score: %.2f  Time: %4.4f sec' % (policy_score, et-st))

monitoring json files

I have followed this tutorial but not sure what is wrong. I have Googled a lot but haven't come across anything that could be useful.

like image 291
AKuro Avatar asked Oct 03 '18 23:10

AKuro


1 Answers

Last time I checked, this was working fine:

env = gym.wrappers.Monitor(env, "./vid", video_callable=lambda episode_id: True,force=True)

This will record the video for all the episodes. You can use episode_id to choose which episode to record.

like image 112
Tejas Avatar answered Oct 12 '22 15:10

Tejas