forked from ProsusAI/finBERT
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
24 lines (21 loc) · 710 Bytes
/
main.py
File metadata and controls
24 lines (21 loc) · 710 Bytes
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
from flask_cors import CORS
import sys
import optparse
import time
from flask import request
import sys
from finbert.finbert import predict
from pytorch_pretrained_bert.modeling import BertForSequenceClassification
import nltk
nltk.download('punkt')
app = Flask(__name__)
CORS(app)
start = int(round(time.time()))
model = BertForSequenceClassification.from_pretrained('/src/models/classifier_model/finbert-sentiment', num_labels=3, cache_dir=None)
@app.route("/",methods=['POST'])
def score():
text=request.get_json()['text']
return(predict(text, model).to_json(orient='records'))
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8080, debug=False, threaded=True)