如何使用经过训练的 keras 模型?

时间:2021-03-10 08:10:12

标签: python keras image-classification

我想使用来自 https://www.kaggle.com/janeresh/imageprocess 的训练模型。我复制了笔记本并测试它完美运行。但是如果我下载 model.h5 并在 Google Colab 中使用它来预测屏蔽或非屏蔽它总是返回 0

我使用此代码进行预测:

from tensorflow.keras.models import load_model
from keras.preprocessing import image
import numpy as np
import cv2

model = load_model('model.h5',compile=True)
model.summary()

img = cv2.imread('masked_image.png')
img = cv2.resize(img,(75,75))
img = np.reshape(img,[1,75,75,3])

prediction = model.predict_classes(img)
prediction

而回报是

array([[0]], dtype=int32)

谢谢

0 个答案:

没有答案