Created
July 9, 2018 13:47
-
-
Save RomanSteinberg/c768b465d9bddda7780b673b92af148c to your computer and use it in GitHub Desktop.
preprocessing
This file contains hidden or 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
import tensorflow as tf | |
from imageio import imsave, imread | |
def read_and_preproc(): | |
inp_img_op = tf.placeholder(tf.float32, shape=[None, None, 3]) | |
image_size_before_crop, IMG_HEIGHT, IMG_WIDTH = 286, 256, 256 | |
# Preprocessing: | |
out = tf.image.resize_images(inp_img_op, [image_size_before_crop, image_size_before_crop]) | |
out = tf.random_crop(out, [IMG_HEIGHT, IMG_WIDTH, 3]) | |
out = tf.subtract(tf.div(out, 127.5), 1) | |
result_op = tf.train.batch([out], 1) | |
fn = '/home/roman/Data/avatars/in.jpg' | |
img = imread(fn) | |
with tf.Session() as sess: | |
print(111) | |
res_img = sess.run(result_op, feed_dict={inp_img_op: img}) | |
print(res_img.shape) | |
print('Complete!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment