CNN预测模型如何

时间:2019-05-27 08:55:08

标签: python tensorflow keras

前辈们请指导我预测部分不能正常工作

prediction = model.predict([prepare('Cat.jpg')])

in predict  x, check_steps=True, steps_name='steps', steps=steps)
# testing the traind model
import cv2
import tensorflow as tf
from keras.models import load_model
CATEGORIES = ["Dog", "Cat"]  # will use this to convert prediction num to string value


def prepare(filepath):
   IMG_SIZE = 70  # 50 in txt-based
   img_array = cv2.imread(filepath, cv2.IMREAD_GRAYSCALE)  # read in the image, convert to grayscale
   new_array = cv2.resize(img_array, (IMG_SIZE, IMG_SIZE))  # resize image to match model's expected sizing
   return new_array.reshape(-1, IMG_SIZE, IMG_SIZE, 1)
model = tf.keras.models.load_model("64x3-CNN.model")




prediction = model.predict([prepare('Cat.jpg')])
print(prediction)  # will be a list in a list.
print(CATEGORIES[int(prediction[0][0])])

0 个答案:

没有答案
相关问题