Skip to content

Instantly share code, notes, and snippets.

@domluna
Created June 2, 2016 05:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save domluna/1b608861ea81111148842b28a152fca6 to your computer and use it in GitHub Desktop.
Save domluna/1b608861ea81111148842b28a152fca6 to your computer and use it in GitHub Desktop.
Tensorflow grayscale + resizing. Session + feed dict is for having a static op.
def rgb2y_resize(input_shape, new_height, new_width, session):
img = tf.placeholder(tf.float32, shape=input_shape)
reshaped = tf.reshape(img, [1] + list(input_shape))
rgb2y = tf.image.rgb_to_grayscale(reshaped)
bilinear = tf.image.resize_bilinear(rgb2y, [new_height, new_width])
squeezed = tf.squeeze(bilinear)
return lambda x: session.run(squeezed, feed_dict={img: x})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment