Skip to content

Instantly share code, notes, and snippets.

@dipanjanS
Created August 15, 2019 07:54
Show Gist options
  • Save dipanjanS/ca7cbe2ca20c45cb3706d9028e21caeb to your computer and use it in GitHub Desktop.
Save dipanjanS/ca7cbe2ca20c45cb3706d9028e21caeb to your computer and use it in GitHub Desktop.
# get imagenet id to label name mappings
url = "https://s3.amazonaws.com/deep-learning-models/image-models/imagenet_class_index.json"
fname = shap.datasets.cache(url)
with open(fname) as f:
class_names = json.load(f)
# make model predictions
predictions = model.predict(preprocess_input(to_predict.copy()))
# get prediction labels
predicted_labels = [class_names.get(str(pred)) for pred in np.argmax(predictions, axis=1)]
print(predicted_labels)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment