Skip to content

Instantly share code, notes, and snippets.

@dipanjanS
Created August 15, 2019 09:17
Show Gist options
  • Save dipanjanS/a9aa63c0cc322562f86aa77d52be76cf to your computer and use it in GitHub Desktop.
Save dipanjanS/a9aa63c0cc322562f86aa77d52be76cf to your computer and use it in GitHub Desktop.
# load imagenet id to class label mappings
import requests
response = requests.get('https://storage.googleapis.com/download.tensorflow.org/data/imagenet_class_index.json')
imgnet_map = response.json()
imgnet_map = {v[1]: k for k, v in imgnet_map.items()}
# make model predictions
img = tf.keras.applications.xception.preprocess_input(img)
predictions = model.predict(np.array([img]))
decode_predictions(predictions, top=5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment