DK-Jang / motion_puzzle

Motion Puzzle - Official PyTorch implementation
MIT License
108 stars 13 forks source link

Bug when dividing clips of small lengths #9

Open tevkhieu opened 12 months ago

tevkhieu commented 12 months ago

Hello,

I found a bug when handling small clips. In the data preprocessing:

def divide_clip(input, window, window_step, divide):
    if not divide:  # return the whole clip
        t = ((input.shape[0]) // 4) * 4 + 4
        t = max(t, 12)
        if len(input) < t:
            input = pad_to_window(input, t)

        return [input]

    """ Slide over windows """
    windows = []
    for j in range(0, len(input)-window//4, window_step):
        """ If slice too small pad out by repeating start and end poses """
        slice = input[j:j+window]
        if len(slice) < window:
            left = slice[:1].repeat(
                (window-len(slice))//2 + (window-len(slice)) % 2, axis=0)
            left[..., -3:] = 0.0
            right = slice[-1:].repeat((window-len(slice))//2, axis=0)
            right[..., -3:] = 0.0
            slice = np.concatenate([left, slice, right], axis=0)

        if len(slice) != window:
            raise Exception()

        windows.append(slice)

The issue is that if the input has a length under window // 4 (e.g. a 30 frame clip like 106_01.bvh in the CMU dataset) it won't enter the loop thus not padding the data and return an empty list.