ATE api update 2
This commit is contained in:
+6
-4
@@ -3,8 +3,9 @@ import torch
|
||||
import torch.nn.functional as F
|
||||
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
||||
|
||||
from utils import *
|
||||
from canonical_utils import *
|
||||
from .utils import *
|
||||
from .canonical_utils import *
|
||||
|
||||
from flask import Flask, request, jsonify
|
||||
from transformers import AutoTokenizer, AutoModelForTokenClassification
|
||||
|
||||
@@ -12,12 +13,13 @@ from transformers import AutoTokenizer, AutoModelForTokenClassification
|
||||
app = Flask(__name__)
|
||||
|
||||
label_list=["n", "B-T", "T"]
|
||||
tokenizer = AutoTokenizer.from_pretrained('./model/term_extractor/')
|
||||
model = AutoModelForTokenClassification.from_pretrained('./model/term_extractor/', num_labels=len(label_list)).to(device)
|
||||
tokenizer = AutoTokenizer.from_pretrained('/app/model/term_extractor/')
|
||||
model = AutoModelForTokenClassification.from_pretrained('/app/model/term_extractor/', num_labels=len(label_list)).to(device)
|
||||
|
||||
@app.route('/predict',methods=['POST'])
|
||||
def predict():
|
||||
frame = read_conll(request.files['file'])
|
||||
# print(frame)
|
||||
sequences = [' '.join(x) for x in frame.word]
|
||||
lemma, pos, msd = frame.lemma, frame.pos, frame.msd
|
||||
preds = []
|
||||
|
||||
Reference in New Issue
Block a user