MCPcopy
hub / github.com/OpenMotionLab/MotionGPT / motion_string_to_token

Method motion_string_to_token

mGPT/archs/mgpt_lm.py:414–434  ·  view source on GitHub ↗
(self, motion_string: List[str])

Source from the content-addressed store, hash-verified

412 return motion_string
413
414 def motion_string_to_token(self, motion_string: List[str]):
415 motion_tokens = []
416 output_string = []
417 for i in range(len(motion_string)):
418 string = self.get_middle_str(
419 motion_string[i], f'<motion_id_{self.m_codebook_size}>',
420 f'<motion_id_{self.m_codebook_size + 1}>')
421 string_list = string.split('><')
422 token_list = [
423 int(i.split('_')[-1].replace('>', ''))
424 for i in string_list[1:-1]
425 ]
426 if len(token_list) == 0:
427 token_list = [0]
428 token_list_padded = torch.tensor(token_list,
429 dtype=int).to(self.device)
430 motion_tokens.append(token_list_padded)
431 output_string.append(motion_string[i].replace(
432 string, '<Motion_Placeholder>'))
433
434 return motion_tokens, output_string
435
436 def placeholder_fulfill(self, prompt: str, length: int, motion_string: str,
437 text: str):

Callers 1

generate_directMethod · 0.95

Calls 2

get_middle_strMethod · 0.95
toMethod · 0.45

Tested by

no test coverage detected