我刚开始尝试使用keras应用程序。 resnet50的示例工作正常。然而,inception_v3模型认为我的大象是一辆跑车。我哪里错了?
from keras.applications.inception_v3 import InceptionV3
from keras.layers import Input
from keras.preprocessing import image
from keras.applications.resnet50 import preprocess_input, decode_predictions
import numpy as np
model = InceptionV3(weights='imagenet', include_top=True)
img_path = 'elephant.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)
# decode the results into a list of tuples (class, description, probability)
# (one such list for each sample in the batch)
print('\nPredicted:', decode_predictions(preds, top=10)[0])
预测:[('n04285008','sports_car',0.58716565),('n04041544','radio',0.19915217),('n03535780','horizontal_bar',0.11363289),('n03691459','loudspeaker' ,0.059153806),('n01669191','box_turtle',0.012588425),('n04286575','spotlight',0.0068869498),('n03594945','jeep',0.005987139),('n01728920','ringneck_snake',0.0050685192 ),('n03637318','lamphade',0.0020551293),('n03000134','chainlink_fence',0.00168875)]
答案 0 :(得分:0)