Created
November 1, 2018 10:35
-
-
Save malnakli/c3f9aeb06e96117388d742709afbe371 to your computer and use it in GitHub Desktop.
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
from skimage.transform import resize | |
target_size = 96 | |
def preprocess_image(x): | |
# Resize the image to have the shape of (96,96) | |
x = resize(x, (target_size, target_size), | |
mode='constant', | |
anti_aliasing=False) | |
# convert to 3 channel (RGB) | |
x = np.stack((x,)*3, axis=-1) | |
# Make sure it is a float32, here is why | |
# https://www.quora.com/When-should-I-use-tf-float32-vs-tf-float64-in-TensorFlow | |
return x.astype(np.float32) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment