Spaces:
Sleeping
Sleeping
File size: 810 Bytes
8813410 2c37334 8813410 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
from flask import Flask, request, jsonify
import joblib
import numpy as np
print("Hello")
# Load the scaler and models
scaler = joblib.load('scaler.joblib')
models = {target: joblib.load(f'svm_model_{target}.joblib') for target in ['processing', 'perception', 'input', 'understanding']}
app = Flask(__name__)
@app.route('/predict', methods=['POST'])
def predict():
data = request.json.get('user_input')
if not data:
return jsonify({"error": "No input provided"}), 400
user_input_array = np.array(data).reshape(1, -1)
user_input_scaled = scaler.transform(user_input_array)
predictions = {target: model.predict(user_input_scaled)[0] for target, model in models.items()}
return jsonify(predictions)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)
|