ValueError:检查输入时出错:预期density_18_input具有形状(128,)但具有形状(1,)的数组

时间:2020-07-03 21:02:50

标签: python machine-learning deep-learning artificial-intelligence classification

我将tensorflow版本从最新版本更改为2.0.1,现在错误在上面:有人可以帮助我吗?

import cv2
import numpy as np
import tensorflow as tf

Categories = ["Badshahi Masjid", "Minare Pakistan", "ShahiQila(Lahore Fort)"]

sift = cv2.xfeatures2d.SIFT_create()

print(tf.__version__)

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])])

0 个答案:

没有答案