代码拉取完成,页面将自动刷新
import os
import h5py
import argparse
from collections import defaultdict
from sim_env import make_sim_env
from utils import sample_box_pose, sample_insertion_pose
from sim_env import BOX_POSE
from constants import DT
from visualize_episodes import save_videos
import IPython
e = IPython.embed
def main(args):
dataset_path = args['dataset_path']
if not os.path.isfile(dataset_path):
print(f'Dataset does not exist at \n{dataset_path}\n')
exit()
with h5py.File(dataset_path, 'r') as root:
actions = root['/action'][()]
env = make_sim_env('sim_transfer_cube')
BOX_POSE[0] = sample_box_pose() # used in sim reset
ts = env.reset()
episode_replay = [ts]
for action in actions:
ts = env.step(action)
episode_replay.append(ts)
# saving
image_dict = defaultdict(lambda: [])
while episode_replay:
ts = episode_replay.pop(0)
for cam_name, image in ts.observation['images'].items():
image_dict[cam_name].append(image)
video_path = dataset_path.replace('episode_', 'replay_episode_').replace('hdf5', 'mp4')
save_videos(image_dict, DT, video_path=video_path)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--dataset_path', action='store', type=str, help='Dataset path.', required=True)
main(vars(parser.parse_args()))
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。