上传图片以使用Python在文件中发表文章

时间:2020-04-10 16:34:57

标签: python flask

我正在尝试上传图像,然后评估机器学习模型,但收到的帖子为空。

我的代码

#Basic libraries
import os
from flask import Flask, jsonify, request
from flask_restful import Api, Resource

#Image libraries
import matplotlib.image as mpimg
from skimage import color


app = Flask(__name__)
api = Api(app)


class MakePrediction(Resource):
    @staticmethod
    def post():
        orig_img = request.get_json()
        
        #Here I have to read the image from post or save the image also
        #orig_img=mpimg.imread(orig_img.file)
       
        
        print(orig_img)
        return orig_img
    
api.add_resource(MakePrediction, '/predict')


if __name__ == '__main__':
    app.run(port='8050')

例如,当我尝试从邮递员发表帖子时,我得到的是null。有没有办法发布帖子,获取文件然后进行处理?

enter image description here

0 个答案:

没有答案
相关问题