Closed kevinushey closed 7 years ago
I'm seeing the same behavior when executing from Python:
# use keras
from keras.applications.resnet50 import ResNet50
from keras.preprocessing import image
from keras.applications.resnet50 import preprocess_input, decode_predictions
# use tensorflow.contrib.keras
# from tensorflow.contrib.keras.python.keras.applications.resnet50 import ResNet50
# from tensorflow.contrib.keras.python.keras.preprocessing import image
# from tensorflow.contrib.keras.python.keras.applications.resnet50 import preprocess_input, decode_predictions
import numpy as np
model = ResNet50(weights='imagenet')
img_path = 'elephant.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])
('Predicted:', [(u'n02504013', u'Indian_elephant', 0.91937912),
(u'n01871265', u'tusker', 0.070962951),
(u'n02504458', u'African_elephant', 0.0095201703)])
('Predicted:', [(u'n02098286', u'West_Highland_white_terrier', 1.0),
(u'n15075141', u'toilet_tissue', 0.0),
(u'n02319095', u'sea_urchin', 0.0)])
Reported to tensorflow here: https://github.com/tensorflow/tensorflow/issues/11868
I've resolved this for the Keras R package by switching the default implementation to "keras" rather than "tensorflow" here: https://github.com/rstudio/keras/pull/88
Given this code:
TensorFlow Keras
Stand-alone Keras
Any idea what might be going on here?