hflip

paddle.vision.transforms. hflip ( img ) [source]

Horizontally flips the given Image or np.array or paddle.Tensor.

Parameters

img (PIL.Image|np.array|Tensor) – Image to be flipped.

Returns

Horizontally flipped image.

Return type

PIL.Image|np.array|paddle.Tensor

Examples

>>> import numpy as np
>>> from PIL import Image
>>> from paddle.vision.transforms import functional as F
>>> fake_img = (np.random.rand(256, 300, 3) * 255.).astype('uint8')
>>> fake_img = Image.fromarray(fake_img)
>>> flipped_img = F.hflip(fake_img)
>>> print(flipped_img.size)
(300, 256)