inference_single_image.py 文件源码

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

项目:gong_an_pictures 作者: oukohou 项目源码 文件源码
def read_single_image(image_path):
    # image = cv2.imread(image_path, cv2.CV_LOAD_IMAGE_UNCHANGED)
    image = Image.open(image_path)
    image = tf.convert_to_tensor(np.asarray(image))
    # image =tf.contrib.keras.preprocessing.image.load_img(image_path)# [image_path]
    # image_queue = tf.train.string_input_producer(image)
    # reader = tf.WholeFileReader()
    # key , value = reader.read(image_queue)
    # image = tf.image.decode_jpeg(value,channels=3)
    assert image is not None
    image = tf.image.resize_image_with_crop_or_pad(
        image=image,
        target_height=height,
        target_width=width,
    )
    image = tf.cast(image, tf.float32) * (1. / 255) - 0.5

    image = tf.reshape(image, [-1, height, width, 3])
    return image
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号