forked from MarkFzp/mobile-aloha
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathget_episode_len.py
executable file
·46 lines (37 loc) · 1.14 KB
/
get_episode_len.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
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python3
import argparse
import os
import h5py
import IPython
e = IPython.embed
def main(args):
dataset_dir = args['dataset_dir']
episode_idx = args['episode_idx']
dataset_name = f'episode_{episode_idx}'
dataset_path = os.path.join(dataset_dir, dataset_name + '.hdf5')
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:
# is_sim = root.attrs['sim']
# compressed = root.attrs.get('compress', False)
qpos = root['/observations/qpos'][()]
print(f'dataset_name: {dataset_name}, episode {episode_idx}, len: {len(qpos)}')
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument(
'--dataset_dir',
action='store',
type=str,
help='Dataset dir.',
required=True,
)
parser.add_argument(
'--episode_idx',
action='store',
type=int,
help='Episode index.',
required=False,
)
parser.add_argument('--ismirror', action='store_true')
main(vars(parser.parse_args()))