Ich habe abermals eine Frage. Aber hier erstmal der Code:
Code: Alles auswählen
import cv2
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
import os
CATEGORIES = ["null", "eins","zwei","drei","vier","fuenf","sechs","sieben","acht","neun"]
def prepare(filepath):
IMG_SIZE = 100
if os.path.isfile(filepath):
print(filepath)
img_array = cv2.imread(filepath, cv2.IMREAD_GRAYSCALE)
new_array = cv2.resize(img_array, (IMG_SIZE, IMG_SIZE))
return new_array.reshape(-1, IMG_SIZE, IMG_SIZE, 1)
else:
print("no")
model = tf.keras.models.load_model("OwnNumbers.model")
prediction = model.predict([prepare("Zwei.png")])
print(CATEGORIES[int(prediction[0][0])])
Code: Alles auswählen
File "C:/Users/Passi/PycharmProjects/Deep/Deep.py", line 23, in <module>
prediction = model.predict([prepare("Zwei.png")])
File "C:\Users\Passi\PycharmProjects\Deep\venv\lib\site-packages\tensorflow\python\keras\engine\training.py", line 1096, in predict
x, check_steps=True, steps_name='steps', steps=steps)
File "C:\Users\Passi\PycharmProjects\Deep\venv\lib\site-packages\tensorflow\python\keras\engine\training.py", line 2289, in _standardize_user_data
self._set_inputs(cast_inputs)
File "C:\Users\Passi\PycharmProjects\Deep\venv\lib\site-packages\tensorflow\python\training\checkpointable\base.py", line 442, in _method_wrapper
method(self, *args, **kwargs)
File "C:\Users\Passi\PycharmProjects\Deep\venv\lib\site-packages\tensorflow\python\keras\engine\training.py", line 2503, in _set_inputs
input_shape = (None,) + tuple(inputs.shape[1:])
AttributeError: 'list' object has no attribute 'shape'
Hätte jemand eine andere Idee und/oder eine Webseite, wo ich Infos dazu finde? Habe schon verzweifelt gesucht. Vielen Dank schon mal im Vorraus
Mfg Pedossi