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
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 | |
imageLoader=loadAndPreprocessKerasInceptionV3, | |
outputMode="vector") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment