Skip to content

Instantly share code, notes, and snippets.

@daniellerch
Created February 13, 2018 18:33
Show Gist options
  • Save daniellerch/02979def8d10bd239b475f921418271e to your computer and use it in GitHub Desktop.
Save daniellerch/02979def8d10bd239b475f921418271e to your computer and use it in GitHub Desktop.
Keras/InceptionResNetV2
from keras.applications.inception_resnet_v2 import InceptionResNetV2
from keras.preprocessing import image
from keras.applications.inception_resnet_v2 import preprocess_input, decode_predictions
import numpy as np
model = InceptionResNetV2(weights='imagenet')
img_path = 'aguila.jpg'
img = image.load_img(img_path, target_size=(224, 224))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = preprocess_input(x)
preds = model.predict(x)
print 'Prediction:', decode_predictions(preds, top=1)[0][0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment