1 Star 0 Fork 0

爱折腾智能机器人/act-plus-plus

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
replay_episodes.py 1.35 KB
一键复制 编辑 原始数据 按行查看 历史
Tony Zhao 提交于 2023-10-29 23:02 . fix bug and add mirroring
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()))
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ncnynl/act-plus-plus.git
git@gitee.com:ncnynl/act-plus-plus.git
ncnynl
act-plus-plus
act-plus-plus
main

搜索帮助