MCPcopy Create free account
hub / github.com/MotrixLab/insactor / MotionDatasetRollout

Class MotionDatasetRollout

diffmimic/utils/data.py:112–152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110
111
112class MotionDatasetRollout(data.Dataset):
113 def __init__(self, motion_dir, seg_info=None):
114 if 'kit' in motion_dir:
115 list_path = 'data/kitml_datalist.txt'
116 elif 'human' in motion_dir:
117 list_path = 'data/humanml3d_datalist.txt'
118 else:
119 raise NotImplementedError
120 with open(list_path) as f:
121 self.motion_list = f.read().splitlines()
122 if 'kit' in motion_dir:
123 # self.motion_list = ['00586.npy', '00603.npy', '00606.npy', '02916.npy','02351.npy', '02593.npy']
124 # self.motion_list = ['02916.npy','02351.npy', '02593.npy'] # 360 jump
125 # self.motion_list = ['00607.npy', '00608.npy', '00609.npy', '00610.npy','00611.npy', '00612.npy', '01236.npy'] # kick
126 self.motion_list = ['03329.npy', '02797.npy', '00653.npy', '01317.npy', '02320.npy', '02772.npy', '02355.npy', '02625.npy', '02916.npy', '03299.npy'] # acrobatic
127 # self.motion_list = ['02285.npy', '02291.npy', '02292.npy', '02626.npy', '03449.npy', '03311.npy', '03304.npy', '02823.npy', '02628.npy', '02283.npy', '01234.npy'] # dance
128 else:
129 self.motion_list = ['000000.npy', '000002.npy', '000264.npy', '000499.npy']
130 # self.motion_list = [fname for fname in self.motion_list if not os.path.isfile(os.path.join('/mnt/lustre/share/jwren/cvae_kitml_traj_valid_v3/', fname))]
131 # self.motion_list = [fname for fname in self.motion_list if not os.path.isfile(os.path.join('/mnt/lustre/share/jwren/cvae_kitml_traj_invalid_v3/', fname))]
132
133
134 if seg_info is not None:
135 num, idx = seg_info
136 total_len = len(self.motion_list)
137 seg_len = (total_len // num) + 1
138 idx_start = seg_len * idx
139 idx_end = seg_len * (idx + 1)
140 self.motion_list = self.motion_list[idx_start:idx_end]
141 motion_path_list = [os.path.join(motion_dir, fname) for fname in self.motion_list]
142 self.motion_path_list = [x for x in motion_path_list if os.path.isfile(x)]
143 print(len(self.motion_path_list))
144
145 def __len__(self):
146 return len(self.motion_path_list)
147
148 def __getitem__(self, idx):
149 fpath, fname = self.motion_path_list[idx], self.motion_list[idx]
150 demo_traj = np.array(np.load(fpath))
151
152 return demo_traj, fname
153
154
155class InfiniteSampler(data.sampler.Sampler):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected