titu1994 / Keras-NASNet

"NASNet" models in Keras 2.0+ with weights
MIT License
200 stars 64 forks source link

prediction result varies from time to time #18

Closed suhmily closed 6 years ago

suhmily commented 6 years ago

Hi, thank you for fixing nasnet's low accuracy problem. But after I updated the code and weights follow your lead, I found that every time I predict on "elephant.jpg", it got a different score. Here is my prediction code and some results: input_img = image.load_img('elephant.jpg', target_size=(224,224)) img = image.img_to_array(input_img) img = np.expand_dims(img, axis=0) img = preprocess_input(img) x = tf.keras.applications.nasnet.NASNetMobile(include_top=True,dropout=0, weights='imagenet', input_tensor=None, input_shape=(224,224,3), )
preds = x.predict(img) print('Predicted:', decode_predictions(preds, top=3)[0])

Predicted: [('n02504458', 'African_elephant', 0.6310287), ('n02504013', 'Indian_elephant', 0.16810806), ('n01871265', 'tusker', 0.060016993)] Predicted: [('n02504458', 'African_elephant', 0.68221015), ('n02504013', 'Indian_elephant', 0.17037697), ('n01871265', 'tusker', 0.057558082)]

I would really appreciate it if you could help me with this problem.

Thanks in advance.