我正在使用keras初始预训练模型(使用imagenet数据) https://github.com/fchollet/keras/blob/master/keras/applications/inception_v3.py
我的短节目是
model = InceptionV3(weights='imagenet')
img_path = 'data/rockcliff.jpg'
img = image.load_img(img_path, target_size=(299, 299))
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))
我尝试了3张图片,cropped_panda,rockcliff和投手。在每种情况下,预测都将起重机作为首选。确切的回报是
('预测:',[[(u' n03126707',u'起重机',0.77817649),(u' n04041544',u& #39; radio',0.098524272),(u' n03450230',u' gown',0.084664099),(u' n02128925',u' jaguar' ;,0.015732178),(u' n03459775',u' grille',0.011028509)]])
知道问题是什么?