Skip to content

A question about placeholder_fulfill function #39

Description

@Vincent-2017

`
def placeholder_fulfill(self, prompt: str, length: int, motion_string: str,
text: str):

    seconds = math.floor(length / self.framerate)
    motion_splited = motion_string.split('>')
    token_length = length / self.down_t
    predict_head = int(token_length * self.predict_ratio + 1)
    masked_head = int(token_length * self.inbetween_ratio + 1)
    masked_tail = int(token_length * (1 - self.inbetween_ratio) + 1)
    
    motion_predict_head = '>'.join(
        motion_splited[:predict_head]
    ) + f'><motion_id_{self.m_codebook_size+1}>'
    motion_predict_last = f'<motion_id_{self.m_codebook_size}>' + '>'.join(
        motion_splited[predict_head:])

    motion_masked = '>'.join(
        motion_splited[:masked_head]
    ) + '>' + f'<motion_id_{self.m_codebook_size+2}>' * (
        masked_tail - masked_head) + '>'.join(motion_splited[masked_tail:])

    if random.random() < self.quota_ratio:
        text = f'\"{text}\"'

    prompt = prompt.replace('<Caption_Placeholder>', text).replace(
        '<Motion_Placeholder>',
        motion_string).replace('<Frame_Placeholder>', f'{length}').replace(
            '<Second_Placeholder>', '%.1f' % seconds).replace(
                '<Motion_Placeholder_s1>', motion_predict_head).replace(
                    '<Motion_Placeholder_s2>',
                    motion_predict_last).replace(
                        '<Motion_Placeholder_Masked>', motion_masked)

    return prompt

`

in the code, motion_splited length is 4x for token_length, you use token_length to calculate the mask and then apply the mask in motion_splited, is it correct? I have this question in MotionGPT project.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions