OmgZomg 2 Report post Posted June 3, 2020 Всем доброго дня! Загружаю изображение в обученную модель from keras.models import load_model import numpy as np from keras.preprocessing import image model = load_model('my_model33-16.h5') img_path='/home/alexander/s_gray/3_39095_31718.png' img = image.load_img(img_path) img_tensor = image.img_to_array(img) img_tensor = np.expand_dims(img_tensor, axis=0) Выдает ошибку ValueError: Error when checking input: expected img to have shape (128, 128, 1) but got array with shape (128, 128, 3) Изображения уже переведены в grayscale import os from PIL import Image files = os.listdir('/home/alexander/s2/') for f in files: img=Image.open('/home/alexander/s2/'+f) gray = img.convert('L') im_resized = gray.resize((128, 128)) im_resized.save('/home/alexander/s_gray/'+f) Что не так?) Share this post Link to post Share on other sites
Smorodov 578 Report post Posted June 4, 2020 Так это, однослойное требует Проверьте shape загруженного изображения, если слоев 3, просто отцепите один, в сером они все одинаковые. 1 Share this post Link to post Share on other sites