RandomHorizontalFlip

class paddle.vision.transforms. RandomHorizontalFlip ( prob=0.5, keys=None ) [source]

Horizontally flip the input data randomly with a given probability.

Parameters
  • prob (float, optional) – Probability of the input data being flipped. Default: 0.5

  • keys (list[str]|tuple[str], optional) – Same as BaseTransform. Default: None.

Examples

import numpy as np
from PIL import Image
from paddle.vision.transforms import RandomHorizontalFlip

transform = RandomHorizontalFlip(224)

fake_img = Image.fromarray((np.random.rand(300, 320, 3) * 255.).astype(np.uint8))

fake_img = transform(fake_img)
print(fake_img.size)