我正在尝试对单个图像进行预测,并且正在训练输入形状= 128的模型,但是当我尝试仅对单个图像进行预测时,虽然输入形状也是128,但它给了我错误,我看到了 。有人能详细说明这个错误吗?
import cv2
import numpy as np
import tensorflow as tf
Categories = ["Badshahi Masjid", "Minare Pakistan", "ShahiQila(Lahore Fort)"]
sift = cv2.xfeatures2d.SIFT_create()
def prepare(filepath):
IMG_SIZE = (124,124)
img_array = cv2.imread(filepath, cv2.IMREAD_GRAYSCALE)
new_array = cv2.resize(img_array, IMG_SIZE)
keyImage, desImage = sift.detectAndCompute(new_array, None)
feat = np.sum(desImage, axis=0)
return feat
model = tf.keras.models.load_model("SuperClassPredictions.h5")
prediction = model.predict([prepare('E:\Python Telusko\OpenCv\download.jpg')])
print(prediction)
print(Categories[int(prediction[0][0])])