forked from Stilwell-Git/Hindsight-Goal-Generation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
render.py
33 lines (26 loc) · 865 Bytes
/
render.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import numpy as np
import time
from common import get_args,experiment_setup
import panda_gym
import gymnasium
import imageio
from envs import make_env
args = get_args()
env, env_test, agent, buffer, learner, tester = experiment_setup(args)
agent.load_network('checkpoints/pap_task/modified_hgg/pretrained.bilel')
env = make_env(args,render_mode='rgb_array')
def render(name = 'MobileSlide - hssgg'):
images = []
observation = env.reset()
images.append(env.render())
print('rendering')
for _ in range(250):
action = agent.step(observation, explore=False)
observation, reward, terminated, info = env.step(action)
images.append(env.render())
if terminated :
observation, info = env.reset()
images.append(env.render())
break
imageio.mimsave(name+'.gif', images)
render()