2.4K Star 8.2K Fork 4.4K

GVPMindSpore / mindspore

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
resize_bicubic_doc.yaml 2.72 KB
一键复制 编辑 原始数据 按行查看 历史
俞涵 提交于 2024-03-07 10:41 . modify API examples import error
resize_bicubic:
description: |
Resize images to size using bicubic interpolation.
.. warning::
This is an experimental API that is subject to change or deletion.
Args:
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 :math:`(batch, channels, height, width)`.
The format must be NCHW. Types allowed: float16, float32, float64.
- **size** (Union[tuple[int], Tensor[int]]) - A 1-D tensor or tuple with 2 elements: new_height, new_width. Besides, tuple[int] is recommended.
Outputs:
A 4-D tensor with shape :math:`(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 `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 when `size` is a tensor.
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:
>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, ops, nn
>>> 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]]]]
Python
1
https://gitee.com/mindspore/mindspore.git
git@gitee.com:mindspore/mindspore.git
mindspore
mindspore
mindspore
master

搜索帮助