Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tensorflow as tf
- from tensorflow.keras.preprocessing import image
- from tensorflow.keras.applications.resnet50 import ResNet50
- from tensorflow.keras.applications.resnet50 import preprocess_input, decode_predictions
- import numpy as np
- tf.enable_eager_execution()
- model = ResNet50(weights='imagenet')
- img_path = 'dog.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('Predicted:', decode_predictions(preds, top=3)[0])
Add Comment
Please, Sign In to add comment