Created
October 20, 2020 08:04
-
-
Save shashankprasanna/4735affebd0f78421e86cf4433f6dff8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def image_preprocess(img, reps=1): | |
img = np.asarray(img.resize((224, 224))) | |
img = np.stack([img]*reps) | |
img = tf.keras.applications.resnet50.preprocess_input(img) | |
return img | |
from PIL import Image | |
import numpy as np | |
import json | |
img= Image.open('kitten.jpg') | |
img = image_preprocess(img, 5) | |
response = predictor_gpu.predict(data=img) | |
probs = np.array(response['predictions'][0]) | |
tf.keras.applications.resnet.decode_predictions(np.expand_dims(probs, axis=0), top=5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment