MCPcopy Create free account
hub / github.com/CompVis/zigma / RandomHorizontalFlipVideo

Class RandomHorizontalFlipVideo

datasets/video_utils.py:425–447  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

423
424
425class 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# ------------------------------------------------------------

Callers 1

get_transforms_videoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected