Skip to content

Instantly share code, notes, and snippets.

@GeorgeSeif
Last active August 27, 2019 23:18
Show Gist options
  • Select an option

  • Save GeorgeSeif/8262b86ee7b57dc1207f29f8b4bf4ec2 to your computer and use it in GitHub Desktop.

Select an option

Save GeorgeSeif/8262b86ee7b57dc1207f29f8b4bf4ec2 to your computer and use it in GitHub Desktop.
from keras.applications.nasnet import Xception, preprocess_input
from keras.models import Sequential, Model
from keras.layers.core import Lambda
from keras.backend import tf as ktf
# Initialize a Xception model
Xception_model = Xception(include_top=True, weights='imagenet', input_tensor=None, input_shape=None)
# Any required pre-processing should be baked into the model
input_tensor = Input(shape=(None, None, 3))
x = Lambda(lambda image: ktf.image.resize_images(image, (299, 299)))(input_tensor)
x = Lambda(lambda image: preprocess_input(image))(x)
output_tensor = Xception_model(x)
final_Xception_model = Model(input_tensor, output_tensor)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment