Код: Выделить всё
from tensorflow.preprocessing import image
# Other imports for tensorlfow etc.
#...
# Sample image
img_path = "./Model/data/brain/train/Glioma/images/gg (2).jpg"
img = image.load_img(img_path,target_size=(256,256))
arr = image.img_to_array(img)
t_img = tf.convert_to_tensor(arr)
print(t_img.shape) # Returns (256,256,3)
# Client testing
client = Client("brain") # Custom Class. Contains model: Sequential (compiled and trained)
client.predict(img=t_img) # Calls self.model.predict(t_img)
Неверная форма ввода для ввода Tensor("data:0", shape =(32, 256, 3), dtype=float32). Ожидаемая форма (Нет, 256, 256, 3), но входные данные имеют несовместимую форму (32, 256, 3)
У меня есть входной слой в обученная модель, имеющая input_shape=[256,256,3] (полученная на основе значений ширины, высоты и RGB изображения)
Можете ли вы помочь мне понять проблему и решить ее?
Подробнее здесь: https://stackoverflow.com/questions/791 ... nput-shape