resize

paddle.vision.transforms. resize ( img, size, interpolation='bilinear' ) [source]

Resizes the image to given size

Parameters
  • input (PIL.Image|np.ndarray|paddle.Tensor) – Image to be resized.

  • size (int|list|tuple) – Target size of input data, with (height, width) shape.

  • interpolation (int|str, optional) – Interpolation method. when use pil backend, support method are as following: - “nearest”: Image.NEAREST, - “bilinear”: Image.BILINEAR, - “bicubic”: Image.BICUBIC, - “box”: Image.BOX, - “lanczos”: Image.LANCZOS, - “hamming”: Image.HAMMING when use cv2 backend, support method are as following: - “nearest”: cv2.INTER_NEAREST, - “bilinear”: cv2.INTER_LINEAR, - “area”: cv2.INTER_AREA, - “bicubic”: cv2.INTER_CUBIC, - “lanczos”: cv2.INTER_LANCZOS4

Returns

Resized 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)
>>> converted_img = F.resize(fake_img, 224)
>>> print(converted_img.size)
(262, 224)

>>> converted_img = F.resize(fake_img, (200, 150))
>>> print(converted_img.size)
(150, 200)