mindspore.ops.ResizeBicubic

class mindspore.ops.ResizeBicubic(align_corners=False, half_pixel_centers=False)[source]

Resize images to size using bicubic interpolation.

Warning

This is an experimental API that is subject to change or deletion.

Parameters
  • align_corners (bool, optional) – If true, the centers of the 4 corner pixels of the input and output tensors are aligned, preserving the values at the corner pixels.Default: False.

  • half_pixel_centers (bool, optional) – Whether to use half-pixel center alignment. If set to True, align_corners should be False. Default: False.

Inputs:
  • images (Tensor) - The input image must be a 4-D tensor of shape \((batch, channels, height, width)\). The format must be NCHW. Types allowed: float16, float32, float64.

  • size (Tensor) - A 1-D tensor with 2 elements: new_height, new_width. Types allowed: int32.

Outputs:

A 4-D tensor with shape \((batch, channels, new\_height, new\_width)\) whose dtype is the same as images .

Raises
  • TypeError – If the type of images is not allowed.

  • TypeError – If the type of size is not int32.

  • TypeError – If the type of align_corners is not bool.

  • TypeError – If the type of half_pixel_centers is not bool.

  • ValueError – If the dim of images is not 4.

  • ValueError – If the dim of size is not 1.

  • ValueError – If the number of elements in size is not 2.

  • ValueError – If any value of size is not positive.

  • ValueError – If the values of align_corners and half_pixel_centers are both True .

Supported Platforms:

Ascend GPU CPU

Examples

>>> class NetResizeBicubic(nn.Cell):
...     def __init__(self):
...         super(NetResizeBicubic, self).__init__()
...         align_corners = False
...         half_pixel_centers = False
...         self.resize = ops.ResizeBicubic(align_corners, half_pixel_centers)
...
...     def construct(self, images, size):
...         return self.resize(images, size)
...
>>> images = Tensor(np.array([1, 2, 3, 4]).reshape(1, 1, 2, 2).astype(np.float32))
>>> size = Tensor([1, 4], mindspore.int32)
>>> resizebicubic = NetResizeBicubic()
>>> output = resizebicubic(images, size)
>>> print(output)
    [[[[1. 1.5 2. 2.09375]]]]