I read an image from file and call predict method of Keras Inception v3 model. And I found two different results from one input.
from keras.applications.inception_v3 import InceptionV3, decode_predictions
from keras.preprocessing import image
import numpy as np
def model():
model = InceptionV3(weights='imagenet')
def predict(x):
x *= 2
x -= 1
return model.predict(np.array([x]))[0]
return predict
img = image.load_img("2.jpg", target_size=(299, 299))
img = image.img_to_array(img)
img /= 255.
p = model()
print('Predicted:', decode_predictions(np.array([p(img)]), top=3)[0])
print('Predicted:', decode_predictions(np.array([p(img)]), top=3)[0])
The output is
Predicted: [('n01443537', 'goldfish', 0.98162466), ('n02701002', 'ambulance', 0.0010537759), ('n01440764', 'tench', 0.00027527584)]
Predicted: [('n02606052', 'rock_beauty', 0.69015616), ('n01990800', 'isopod', 0.039278224), ('n01443537', 'goldfish', 0.03365362)]
where the first result is correct.