Skip to content

Instantly share code, notes, and snippets.

@FBosler
Last active October 5, 2019 16:35
Show Gist options
  • Save FBosler/509db9476be14e42a1eec979d2cdda4f to your computer and use it in GitHub Desktop.
Save FBosler/509db9476be14e42a1eec979d2cdda4f to your computer and use it in GitHub Desktop.
import numpy as np
def load_image(img_file, target_size=(224,224)):
X = np.zeros((1, *target_size, 3))
X[0, ] = np.asarray(tf.keras.preprocessing.image.load_img(
img_file,
target_size=target_size)
)
X = tf.keras.applications.mobilenet.preprocess_input(X)
return X
import os
def ensure_folder_exists(folder):
if not os.path.exists(folder):
os.makedirs(folder)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment