images.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:dynamic-training-bench 作者: galeone 项目源码 文件源码
def read_image_png(image_path, depth=3, scale=True):
    """Reads the image from image_path (tf.string tensor) [jpg image].
    Cast the result to float32 and if scale=True scale it in [-1,1]
    using scale_image. Otherwise the values are in [0,1]
    Reuturn:
        the decoded jpeg image, casted to float32
    """
    image = tf.image.convert_image_dtype(
        tf.image.decode_png(tf.read_file(image_path), channels=depth),
        dtype=tf.float32)
    if scale:
        image = scale_image(image)
    return image
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号