File size: 427 Bytes
3bfdc02 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
from flask import Flask, request, jsonify
import tensorflow as tf
import numpy as np
model = tf.keras.models.load_model("model2.keras")
app = Flask(__name__)
@app.route("/predict", methods=["POST"])
def predict():
data = request.json
inputs = np.array(data["features"]).reshape(1, -1)
prediction = model.predict(inputs)
return jsonify({"grade": int(prediction.argmax())})
app.run(host="0.0.0.0", port=7860)
|