(self, motion_string: List[str])
| 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): |
no test coverage detected