Merge pull request #37558 from Angus-Luo:master
PiperOrigin-RevId: 301172077 Change-Id: Id2a2d3dd49f198fb463eef7838d38d62c49adb6b
This commit is contained in:
commit
f46ac90866
@ -21,6 +21,6 @@ uncompressed by running:
|
|||||||
convert $src.gif -coalesce $dst.gif
|
convert $src.gif -coalesce $dst.gif
|
||||||
|
|
||||||
This op also supports decoding JPEGs and PNGs, though it is cleaner to use
|
This op also supports decoding JPEGs and PNGs, though it is cleaner to use
|
||||||
`tf.image.decode_image`.
|
`tf.io.decode_image`.
|
||||||
END
|
END
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,6 @@ downscaling the image later.
|
|||||||
|
|
||||||
|
|
||||||
This op also supports decoding PNGs and non-animated GIFs since the interface is
|
This op also supports decoding PNGs and non-animated GIFs since the interface is
|
||||||
the same, though it is cleaner to use `tf.image.decode_image`.
|
the same, though it is cleaner to use `tf.io.decode_image`.
|
||||||
END
|
END
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,6 @@ If needed, the PNG-encoded image is transformed to match the requested number
|
|||||||
of color channels.
|
of color channels.
|
||||||
|
|
||||||
This op also supports decoding JPEGs and non-animated GIFs since the interface
|
This op also supports decoding JPEGs and non-animated GIFs since the interface
|
||||||
is the same, though it is cleaner to use `tf.image.decode_image`.
|
is the same, though it is cleaner to use `tf.io.decode_image`.
|
||||||
END
|
END
|
||||||
}
|
}
|
||||||
|
@ -317,8 +317,8 @@ class DecodeImageOp : public OpKernel {
|
|||||||
} else {
|
} else {
|
||||||
status = errors::InvalidArgument(
|
status = errors::InvalidArgument(
|
||||||
"Got ", num_frames, " frames, but animated gifs ",
|
"Got ", num_frames, " frames, but animated gifs ",
|
||||||
"can only be decoded by tf.image.decode_gif or ",
|
"can only be decoded by tf.io.decode_gif or ",
|
||||||
"tf.image.decode_image");
|
"tf.io.decode_image");
|
||||||
}
|
}
|
||||||
if (!status.ok()) {
|
if (!status.ok()) {
|
||||||
VLOG(1) << status;
|
VLOG(1) << status;
|
||||||
|
@ -44,15 +44,13 @@ def read_tensor_from_image_file(file_name,
|
|||||||
output_name = "normalized"
|
output_name = "normalized"
|
||||||
file_reader = tf.read_file(file_name, input_name)
|
file_reader = tf.read_file(file_name, input_name)
|
||||||
if file_name.endswith(".png"):
|
if file_name.endswith(".png"):
|
||||||
image_reader = tf.image.decode_png(
|
image_reader = tf.io.decode_png(file_reader, channels=3, name="png_reader")
|
||||||
file_reader, channels=3, name="png_reader")
|
|
||||||
elif file_name.endswith(".gif"):
|
elif file_name.endswith(".gif"):
|
||||||
image_reader = tf.squeeze(
|
image_reader = tf.squeeze(tf.io.decode_gif(file_reader, name="gif_reader"))
|
||||||
tf.image.decode_gif(file_reader, name="gif_reader"))
|
|
||||||
elif file_name.endswith(".bmp"):
|
elif file_name.endswith(".bmp"):
|
||||||
image_reader = tf.image.decode_bmp(file_reader, name="bmp_reader")
|
image_reader = tf.io.decode_bmp(file_reader, name="bmp_reader")
|
||||||
else:
|
else:
|
||||||
image_reader = tf.image.decode_jpeg(
|
image_reader = tf.io.decode_jpeg(
|
||||||
file_reader, channels=3, name="jpeg_reader")
|
file_reader, channels=3, name="jpeg_reader")
|
||||||
float_caster = tf.cast(image_reader, tf.float32)
|
float_caster = tf.cast(image_reader, tf.float32)
|
||||||
dims_expander = tf.expand_dims(float_caster, 0)
|
dims_expander = tf.expand_dims(float_caster, 0)
|
||||||
|
@ -250,7 +250,7 @@
|
|||||||
"# Function to load an image from a file, and add a batch dimension.\n",
|
"# Function to load an image from a file, and add a batch dimension.\n",
|
||||||
"def load_img(path_to_img):\n",
|
"def load_img(path_to_img):\n",
|
||||||
" img = tf.io.read_file(path_to_img)\n",
|
" img = tf.io.read_file(path_to_img)\n",
|
||||||
" img = tf.image.decode_image(img, channels=3)\n",
|
" img = tf.io.decode_image(img, channels=3)\n",
|
||||||
" img = tf.image.convert_image_dtype(img, tf.float32)\n",
|
" img = tf.image.convert_image_dtype(img, tf.float32)\n",
|
||||||
" img = img[tf.newaxis, :]\n",
|
" img = img[tf.newaxis, :]\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
@ -605,7 +605,7 @@ class Tensor(_TensorLike):
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
_, image_data = tf.compat.v1.TFRecordReader(...).read(...)
|
_, image_data = tf.compat.v1.TFRecordReader(...).read(...)
|
||||||
image = tf.image.decode_png(image_data, channels=3)
|
image = tf.io.decode_png(image_data, channels=3)
|
||||||
|
|
||||||
# The height and width dimensions of `image` are data dependent, and
|
# The height and width dimensions of `image` are data dependent, and
|
||||||
# cannot be computed without executing the op.
|
# cannot be computed without executing the op.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user