335 Star 1.5K Fork 862

MindSpore / docs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
decode_image.md 1.57 KB
一键复制 编辑 原始数据 按行查看 历史
俞涵 提交于 2023-01-29 16:21 . add mindquantum and modify url

Function Differences with tf.io.decode_image

tf.io.decode_image

tf.io.decode_image(
    contents,
    channels=None,
    dtype=tf.dtypes.uint8,
    name=None,
    expand_animations=True
)

For more information, see tf.io.decode_image.

mindspore.dataset.vision.Decode

class mindspore.dataset.vision.Decode(
    to_pil=False
)

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

Differences

TensorFlow: Decode the raw image bytes into an image with the specified number of channels and data type. It supports decoding GIF images.

MindSpore: Decode the raw image bytes into a RGB image, to_pil decides that whether output in PIL format or NumPy Format.

Code Example

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

image = np.fromfile("/tmp/file.jpg", dtype=np.uint8)
result = ds.vision.Decode()(image)

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

raw = tf.io.read_file("/tmp/file.jpg")
result = tf.io.decode_image(raw, channels=3)
1
https://gitee.com/mindspore/docs.git
git@gitee.com:mindspore/docs.git
mindspore
docs
docs
r2.0.0-alpha

搜索帮助

53164aa7 5694891 3bd8fe86 5694891