Slackbot
03/03/2023, 7:28 AMKrisztián Szabó
03/03/2023, 7:28 AMapp = flask.Flask(__name__, static_url_path="", static_folder="static")
@app.route("/v1/analyse", methods=["POST"])
def analyse():
"""
Analyses an image
Expects POST parameter 'image'
"""
global model
# get uploaded photos
uploaded_files = flask.request.files.getlist("image")
out_json = {
# API response scheme
# .......
"predictions": []
}
with tempfile.TemporaryDirectory() as tmp:
# store images temporarily
# read image and do classification / prediction
out_json["predictions"].append(data)
return flask.jsonify(out_json)
if __name__ == "__main__":
load_model(os.getenv("MODEL_FOLDER_PATH", "../model"))
app.run(
host=os.getenv("HOST", "0.0.0.0"),
port=int(os.getenv("PORT", "9000")),
use_reloader=False,
)
larme (shenyang)
03/03/2023, 8:31 AMKrisztián Szabó
03/03/2023, 8:42 AMlarme (shenyang)
03/03/2023, 8:49 AMyolo_v5_runner = bentoml.Runner(Yolov5Runnable)