我有一张图片 (480,640,3),我正在尝试将其调整为 (150,150,1)。由于我的 Keras 模型已经接受了形状图像 (150,150,1) 的训练,不幸的是我似乎无法使用 PIL 库调整它的大小。对于如何解决这个问题,有任何的建议吗?
这是我现在使用的代码:
错误是在线引起的image5.resize()
stream.seek(0)
data = numpy.fromstring(stream.getvalue() , dtype = numpy.uint8)
image5 = cv.imdecode(data , 1)
print(image5.shape)
#cv.imwrite('uhhu.png',image5)
img = image5.resize((150,150,1 ), Image.ANTIALIAS)
cv.imwrite('hhh.png',img)
x = img_to_array(img)
x = x.reshape((1,) + x.shape)
x = x/255
x = numpy.array(x)
print(x.shape)
#score = loaded_model.predict(img)
#print(score)