XAI-Medical / .ipynb_checkpoints /app-checkpoint.py
Muhusystem
Add Gradio app and requirements
b64070e
raw
history blame contribute delete
539 Bytes
from flask import Flask, request, jsonify
from inference import load_model, classify_text
app = Flask(__name__)
# 加载模型
model, tokenizer = load_model()
@app.route('/predict', methods=['POST'])
def predict():
data = request.json
text = data.get("text", "")
if not text:
return jsonify({"error": "No text provided"}), 400
# 进行推理
prediction = classify_text(text, model, tokenizer)
return jsonify({"result": prediction})
if __name__ == '__main__':
app.run(debug=True)