如何修复python中的'无法将大小30233088的数组重塑为形状(1,64,64,3)'错误?

时间:2019-04-13 15:58:03

标签: python image reshape

我将图像转换为rgb格式,然后将其调整为我感兴趣的尺寸,但是出现以下错误 我尝试了以下功能:

ENVFILE=.env.dev

但是我无法摆脱这个错误

def predict(graph):
    im = Image.open("image.jpeg")
    mat = np.asarray(im.convert('RGB'))  
    mat = mat.reshape(1,64,64,3)
    mat = mat / 255.
    x = graph.get_tensor_by_name("input_x:0")
    outlayer = graph.get_tensor_by_name("outlayer:0")
    prob = graph.get_tensor_by_name("probability:0")
    predict = graph.get_tensor_by_name("predict:0")

    with tf.Session(graph=graph) as sess:
        np.set_printoptions(suppress=True)
        out, prob, pred = sess.run([outlayer, prob,predict],feed_dict={x:mat})
        print(out)
        print(prob)
        print(pred)

if __name__=="__main__":
    graph = load_model()
    predict(graph)

0 个答案:

没有答案