File size: 675 Bytes
7ba9378 2e23211 84de8c5 d96116f cf73210 fdcf510 1f29cc4 c7b4b03 44675a8 db17981 d96116f db17981 84de8c5 fdcf510 1f29cc4 2e23211 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
from flask import Flask, render_template, request, jsonify
import model
app = Flask(__name__)
# Load data and train the model globally
df = model.load_data('AI_Human.csv') # Make sure this path is correct
x_train, x_test, y_train, y_test = model.split_data(df)
pipeline = model.create_pipeline(x_train, y_train)
@app.route('/', methods=['GET', 'POST'])
def home():
if request.method == 'POST':
data = request.json
user_input = data['text']
prediction = model.predict_text(user_input, pipeline)
return jsonify({'classification': prediction})
return render_template('home.html')
if __name__ == '__main__':
app.run(debug=True)
|