Здравствуйте, в настоящее время я получаю эту ошибку, когда пытаюсь проверить модель CNN.
import cv2
import tensorflow as tf
CATEGORIES = ["cats","dogs"]
def prepare(file):
IMG_SIZE = 50
img_array = cv2.imread(file, cv2.IMREAD_GRAYSCALE)
new_array = cv2.resize(img_array, (IMG_SIZE, IMG_SIZE))
return new_array.reshape(-1, IMG_SIZE, IMG_SIZE, 1)
model = tf.keras.models.load_model("CNN.model")
image = "datasets/test_set/dogs/dog.4001.jpg"
prediction = model.predict([image])
prediction = list(prediction[0])
print(CATEGORIES[prediction.index(max(prediction))])
Когда я запускаю код, я получаю сообщение об ошибке:
File "C:\Anaconda\lib\site-packages\tensorflow\python\keras\engine\training_utils.py", line 265, in standardize_single_array
if (x.shape is not None and len(x.shape) == 1 and
AttributeError: 'str' object has no attribute 'shape'
Кто-нибудь, кто может сказать мне мою ошибку?