| 297 | |
| 298 | |
| 299 | class MMGeneratedDataset(Dataset): |
| 300 | def __init__(self, opt, motion_dataset, w_vectorizer): |
| 301 | self.opt = opt |
| 302 | self.dataset = motion_dataset.mm_generated_motion |
| 303 | self.w_vectorizer = w_vectorizer |
| 304 | |
| 305 | def __len__(self): |
| 306 | return len(self.dataset) |
| 307 | |
| 308 | def __getitem__(self, item): |
| 309 | data = self.dataset[item] |
| 310 | mm_motions = data['mm_motions'] |
| 311 | m_lens = [] |
| 312 | motions = [] |
| 313 | for mm_motion in mm_motions: |
| 314 | m_lens.append(mm_motion['length']) |
| 315 | motion = mm_motion['motion'] |
| 316 | if len(motion) < self.opt.max_motion_length: |
| 317 | motion = np.concatenate([motion, |
| 318 | np.zeros((self.opt.max_motion_length - len(motion), motion.shape[1])) |
| 319 | ], axis=0) |
| 320 | motion = motion[None, :] |
| 321 | motions.append(motion) |
| 322 | m_lens = np.array(m_lens, dtype=np.int) |
| 323 | motions = np.concatenate(motions, axis=0) |
| 324 | sort_indx = np.argsort(m_lens)[::-1].copy() |
| 325 | # print(m_lens) |
| 326 | # print(sort_indx) |
| 327 | # print(m_lens[sort_indx]) |
| 328 | m_lens = m_lens[sort_indx] |
| 329 | motions = motions[sort_indx] |
| 330 | return motions, m_lens |
| 331 | |
| 332 | |
| 333 | |