codecamp

TensorFlow函数教程:tf.io.decode_image

tf.io.decode_image函数

别名:

  • tf.image.decode_image
  • tf.io.decode_image
tf.io.decode_image(
    contents,
    channels=None,
    dtype=tf.dtypes.uint8,
    name=None
)

定义在:tensorflow/python/ops/image_ops_impl.py。

decode_bmp,decode_gif,decode_jpeg和decode_png的便捷函数。

检测图像是BMP,GIF,JPEG还是PNG,并执行适当的操作将输入字节string转换为dtype类型的Tensor。

注意:decode_gif返回一个4-D数组[num_frames, height, width, 3],而不是decode_bmp,decode_jpeg和decode_png,它们返回3-D数组[height,width,num_channels]。如果要将GIF文件与BMP,JPEG或PNG文件混合,请确保在构建图形时考虑到这一点。

参数:

  • contents:0-D string。编码图像字节。
  • channels:可选的int。默认为0。解码图像的颜色通道数。
  • dtype:返回的Tensor所需的DType。
  • name:操作的名称(可选)

返回:

dtype类型的Tensor,对于BMP,JPEG和PNG图像其shape为[height, width, num_channels],对于GIF图像,其shape为[num_frames, height, width, 3]。

可能引发的异常:

  • ValueError:不正确的通道数。
TensorFlow函数教程:tf.io.decode_gif
TensorFlow函数教程:tf.io.decode_jpeg
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

TensorFlow 函数介绍

TensorFlow 函数模块:tf

TensorFlow的image模块

TensorFlow使用之tf.io

TensorFlow使用之tf.keras

TensorFlow函数教程:tf.keras.applications

TensorFlow函数教程:tf.keras.backend

TensorFlow使用之tf.metrics

TensorFlow使用之tf.nn

TensorFlow使用之tf.python_io

TensorFlow 功能函数

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }