Created
June 2, 2016 05:57
-
-
Save domluna/1b608861ea81111148842b28a152fca6 to your computer and use it in GitHub Desktop.
Tensorflow grayscale + resizing. Session + feed dict is for having a static op.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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