machine learning - Keras pretrained Xception model always gives the prediction 'sewing_machine' -
i'm using keras pretrained model 'xception' image recognition. however, no matter picture give xception, predictions always:
predicted: [[('n04179913', 'sewing_machine', 1.0), ('n15075141, toilet_tissue', 0.0), ('n02317335', 'starfish', 0.0), ('n02389026, sorrel', 0.0), ('n02364673', 'guinea_pig', 0.0)]]
is there wrong code?
my code is:
from tensorflow.contrib.keras import applications app tensorflow.contrib.keras import preprocessing pp import numpy np model = app.xception(weights='imagenet', include_top=true) img_path = 'test123.jpg' img = pp.image.load_img(path=img_path, target_size=(299, 299)) x = pp.image.img_to_array(img) x = np.expand_dims(x, axis=0) x = app.xception.preprocess_input(x) preds = model.predict(x) print('predicted:', app.xception.decode_predictions(preds))
Comments
Post a Comment