Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Resize and 0 padding using tensorflow
tf_image = tf.io.decode_image(image, channels=3)
tf_image = tf.compat.v1.image.resize_image_with_pad(tf_image, 256, 512)
out = tf.cast(tf_image, tf.uint8)
out = tf.image.encode_jpeg(out, format="rgb", quality=100)
# out = tf.io.write_file("test.jpeg", out)
with tf.Session() as sess:
jpeg_byte = sess.run(out)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.