Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
from keras.applications.inception_v3 import preprocess_input
from keras.preprocessing.image import img_to_array, load_img
import numpy as np
from pyspark.sql.types import StringType
from sparkdl import KerasImageFileTransformer
def loadAndPreprocessKerasInceptionV3(uri):
# this is a typical way to load and prep images in keras
image = img_to_array(load_img(uri, target_size=(299, 299))) # image dimensions for InceptionV3
image = np.expand_dims(image, axis=0)
return preprocess_input(image)
transformer = KerasImageFileTransformer(inputCol="uri", outputCol="predictions",
modelFile='model-full.h5', # local file path for model
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment