我想从POST请求接收图像,然后打印出图像形状。当我运行我的应用程序时,我会得到
对象没有属性“形状”
@app.route('/predict', methods=['POST'])
def take_image():
input_file = request.files.get('file')
image = input_file
return image.shape
有什么建议吗?
答案 0 :(得分:0)
您首先需要从输入文件中创建和图像对象
from PIL import Image
im = Image.open(input_file)
width, height = im.size
有关更多信息,请参见PIL documentation