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.c_transforms.Decode
class mindspore.dataset.vision.c_transforms.Decode(
rgb=True
)
For more information, see mindspore.dataset.vision.c_transforms.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.
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.c_transforms.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)