im = Image.open(“ / Users / shalinsavalia / Desktop / CNN_Numbers / Number_7.jpg”) 即时通讯 im = im.resize(((28,28),Image.ANTIALIAS)#调整图像大小 im = np.array(im)#转换为数组 打印(im) im2 = im / np.max(im).astype(float)#标准化输入 test_image1 = np.reshape(im2,[1,784])#将其重塑为输入的占位符形状
pred =(sess.run(y_predicted, feed_dict = { x:test_image1 })) projection_class = np.argmax(pred) 打印“预测类别:{}”。format(predicted_class)
结果错误是:
Traceback (most recent call last)
<ipython-input-161-782995cc25e1> in <module>()
----> 1 im = im.resize((28, 28), Image.ANTIALIAS)
2 im = np.array(im)
3 im2 = im//np.max(im).astype(float)
4 test_image1 = np.reshape(im2, [784,4])
TypeError: 'tuple' object cannot be interpreted as an integer