335 Star 1.5K Fork 862

MindSpore / docs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
central_crop.md 1.44 KB
一键复制 编辑 原始数据 按行查看 历史
luojianing 提交于 2023-07-21 15:16 . replace target=blank

Function Differences with tf.image.central_crop

View Source On Gitee

tf.image.central_crop

tf.image.central_crop(
    image,
    central_fraction
)

For more information, see tf.image.central_crop.

mindspore.dataset.vision.CenterCrop

class mindspore.dataset.vision.CenterCrop(
    size
)

For more information, see mindspore.dataset.vision.CenterCrop.

Differences

TensorFlow: Crop the central region of the image with desired crop ratio.

MindSpore: Crop the central region of the image with desired output size.

Code Example

# The following implements CenterCrop with MindSpore.
import numpy as np
import mindspore.dataset as ds

image = np.random.random((28, 28, 3))
result = ds.vision.CenterCrop((14, 14))(image)
print(result.shape)
# (14, 14, 3)

# The following implements central_crop with TensorFlow.
import tensorflow as tf

image = tf.random.normal((28, 28, 3))
result = tf.image.central_crop(image, 0.5)
print(result.shape)
# (14, 14, 3)
1
https://gitee.com/mindspore/docs.git
git@gitee.com:mindspore/docs.git
mindspore
docs
docs
r2.0

搜索帮助

53164aa7 5694891 3bd8fe86 5694891