XinyiYing / D3Dnet

Repository for "Deformable 3D Convolution for Video Super-Resolution", SPL, 2020
Apache License 2.0
305 stars 43 forks source link

about class augumentation code #18

Closed reminayano closed 3 years ago

reminayano commented 3 years ago

I would like to ask about the augmentation code. The conditions of the three if statements are the same, but what is being done in the first if statement after all?

class augumentation(object):
    def __call__(self, input, target):
        if random.random()<0.5:
            input = input[::-1, :, :]
            target = target[::-1, :, :]
        if random.random()<0.5:
            input = input[:, ::-1, :]
            target = target[:, ::-1, :]
        if random.random()<0.5:
            input = input.transpose(0, 1, 3, 2)#C N H W
            target = target.transpose(0, 1, 3, 2)
        return input, target

https://github.com/XinyiYing/D3Dnet/blob/f3ca2483d37430d113a0b920030d37d8b50c5006/code/dataset.py#L182

XinyiYing commented 3 years ago

"random.random()" produces a random decimal between 0 and 1. Therefore, the probability of “random.random()”>0.5 and “random.random()”<0.5 are both 50%. For the whole data augmentation process, each “if” judgment sentence is sequentially performed to achieve horizontal flipping, vertical flipping and channel transposition randomly.

reminayano commented 3 years ago

I understand, thank you very much.