def get_image(filepath, height, width, preprocess_fn, queue=None):
png = filepath.lower().endswith('png')
if queue is None:
img_bytes = tf.read_file(filepath)
else:
reader = tf.WholeFileReader()
_, img_bytes = reader.read(queue)
image = tf.image.decode_png(img_bytes, channels=3) if png else tf.image.decode_jpeg(img_bytes, channels=3)
return preprocess_fn(image, height, width)
评论列表
文章目录