Created
November 13, 2018 13:47
-
-
Save weklund/c824b4dca3cd3e78a40a159a504dbeca to your computer and use it in GitHub Desktop.
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 path_to_tensor(path): | |
img = image.load_img(path, target_size = (224,224)) | |
x= image.img_to_array(img) | |
return np.expand_dims(x, axis=0) | |
def paths_to_tensor(paths): | |
list_of_tensors = [path_to_tensor(path) for path in tqdm(paths)] | |
return np.vstack(list_of_tensors) | |
train_tensors = paths_to_tensor(train_files).astype('float32')/255 | |
valid_tensors = paths_to_tensor(valid_files).astype('float32')/255 | |
test_tensors = paths_to_tensor(test_files).astype('float32')/255 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment