我已经训练了一个猫狗分类模型的小数据集,但我预测新图片只输出两个值,或1或0。
from keras.models import load_model
from keras.preprocessing import image
from keras.applications.vgg16 import preprocess_input,
decode_predictions
import numpy as np
img_path = 'mitosis.140.jpg'
img = image.load_img(img_path, target_size=(150, 150))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = preprocess_input(x)
model =load_model('mitosis_.h5')
classes = model.predict_classes(x)
print classes
答案 0 :(得分:0)
您正在使用predict_classes()
功能。正如它清楚地说的,它预测了类。
请尝试:
probs = model.predict(x)