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
inference_single_image.py 文件源码
python
阅读 30
收藏 0
点赞 0
评论 0
评论列表
文章目录