RandomVerticalFlip¶
- class paddle.vision.transforms. RandomVerticalFlip ( prob=0.5, keys=None ) [source]
-
Vertically 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.
- Shape:
-
img(PIL.Image|np.ndarray|Paddle.Tensor): The input image with shape (H x W x C).
output(PIL.Image|np.ndarray|Paddle.Tensor): A vertical flipped image.
- Returns
-
A callable object of RandomVerticalFlip.
Examples
>>> import paddle >>> fake_img = paddle.to_tensor([[[0, 0, 1], [0, 0, 1], [1, 1, 1]]]) >>> print(fake_img) Tensor(shape=[1, 3, 3], dtype=int64, place=Place(gpu:0), stop_gradient=True, [[[0, 0, 1], [0, 0, 1], [1, 1, 1]]]) >>> transform = paddle.vision.transforms.RandomVerticalFlip(prob=1) >>> result = transform(fake_img) >>> print(result) Tensor(shape=[1, 3, 3], dtype=int64, place=Place(gpu:0), stop_gradient=True, [[[1, 1, 1], [0, 0, 1], [0, 0, 1]]])