Spaces:
Running
Running
Upload 2 files
Browse files- app.py +22 -0
- pipeline.pkl +3 -0
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import Flask, request, jsonify, render_template
|
| 2 |
+
import pickle
|
| 3 |
+
|
| 4 |
+
app = Flask(__name__)
|
| 5 |
+
|
| 6 |
+
# Load the pickled pipeline
|
| 7 |
+
with open('pipeline.pkl', 'rb') as file:
|
| 8 |
+
pipeline = pickle.load(file)
|
| 9 |
+
|
| 10 |
+
@app.route('/')
|
| 11 |
+
def home():
|
| 12 |
+
return render_template('index.html')
|
| 13 |
+
|
| 14 |
+
@app.route('/predict', methods=['POST'])
|
| 15 |
+
def predict():
|
| 16 |
+
data = request.get_json(force=True)
|
| 17 |
+
text = data['text']
|
| 18 |
+
prediction = pipeline.predict([text])[0]
|
| 19 |
+
return jsonify({'prediction': prediction})
|
| 20 |
+
|
| 21 |
+
if __name__ == '__main__':
|
| 22 |
+
app.run(debug=True)
|
pipeline.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:47353d80964045db447dbbace5fb083063999222c5dfebe062fd90c27454eb9c
|
| 3 |
+
size 178039931
|