为什么keras.com不认识我的大象?

为什么keras.com不认识我的大象?,keras,Keras,我刚刚开始尝试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

我刚刚开始尝试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','跑车',0.58716565),('n04041544','收音机',0.19915217),('n03535780','水平杆',0.11363289),('n03691459','扬声器',0.059153806),('n01669191','箱龟',0.012588425),('n04286575','聚光灯',0.0068869498),('n03594945','吉普',0.005987139),('n01728920','环颈蛇','0.0050685192),('n03637318','lampshade',0.0020551293),('n03000134','chainlink_-fence',0.00168875)]

我是个白痴。剪切并粘贴导入内容,包括来自resnet50示例的预处理和解码预测。需要从inception_v3导入这些内容。

我是个白痴。剪切并粘贴导入内容,包括来自resnet50示例的预处理和解码预测。需要从inception_v3导入这些内容。

你问题的标题让我咯咯笑了。你也应该检查一下你的跑车,里面可能有条蛇。如果有什么帮助的话:你问题的标题让我咯咯笑了。你也应该检查一下你的跑车,里面可能有条蛇。