alseambusher

Resnet50

Mar 24th, 2019
11,617
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. import tensorflow as tf
  2. from tensorflow.keras.preprocessing import image
  3. from tensorflow.keras.applications.resnet50 import ResNet50
  4. from tensorflow.keras.applications.resnet50 import preprocess_input, decode_predictions
  5. import numpy as np
  6.  
  7. tf.enable_eager_execution()
  8.  
  9. model = ResNet50(weights='imagenet')
  10. img_path = 'dog.jpg'
  11. img = image.load_img(img_path, target_size=(224, 224))
  12. x = image.img_to_array(img)
  13. x = np.expand_dims(x, axis=0)
  14. x = preprocess_input(x)
  15.  
  16. preds = model.predict(x)
  17. print('Predicted:', decode_predictions(preds, top=3)[0])
Add Comment
Please, Sign In to add comment