Я пытаюсь предсказать набор данных изображения с уже обученной сетью. Но, как ни странно, я получаю это сообщение об ошибке:
ValueError: Error when checking input: expected title to have 4 dimensions, but got array with shape (64, 64, 3)
Однако мой набор данных должен иметь 5000 изображений внутри. Я запутался ... Вот мой код:
def preprocess_image(path):
image=tf.io.read_file(path)
image=tf.image.decode_jpeg(image,channels=3)
image=tf.image.resize(image,[64,64])
image/=255.0
return image
def gen_image_dataset(path):
img_path=[]
for root,dirs,files in os.walk(path):
for name in files:
img_path.append(name)
path_ds=tf.data.Dataset.from_tensor_slices(img_path)
image_ds=path_ds.map(preprocess_image,num_parallel_calls=AUTOTUNE)
return image_ds
PlateData(5000,273,76,1)
test_dataset=gen_image_dataset("/home/ly0kos/Car/temp/")
result=model.predict(test_dataset)
Большое вам спасибо за ваше время!