Flip the video clip along the horizontal direction with a given probability Args: p (float): probability of the clip being flipped. Default value is 0.5
| 423 | |
| 424 | |
| 425 | class RandomHorizontalFlipVideo: |
| 426 | """ |
| 427 | Flip the video clip along the horizontal direction with a given probability |
| 428 | Args: |
| 429 | p (float): probability of the clip being flipped. Default value is 0.5 |
| 430 | """ |
| 431 | |
| 432 | def __init__(self, p=0.5): |
| 433 | self.p = p |
| 434 | |
| 435 | def __call__(self, clip): |
| 436 | """ |
| 437 | Args: |
| 438 | clip (torch.tensor): Size is (T, C, H, W) |
| 439 | Return: |
| 440 | clip (torch.tensor): Size is (T, C, H, W) |
| 441 | """ |
| 442 | if random.random() < self.p: |
| 443 | clip = hflip(clip) |
| 444 | return clip |
| 445 | |
| 446 | def __repr__(self) -> str: |
| 447 | return f"{self.__class__.__name__}(p={self.p})" |
| 448 | |
| 449 | |
| 450 | # ------------------------------------------------------------ |
no outgoing calls
no test coverage detected