MCPcopy Create free account
hub / github.com/MotrixLab/MotionDiffuse / __getitem__

Method __getitem__

text2motion/datasets/evaluator.py:308–330  ·  view source on GitHub ↗
(self, item)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected