Spaces:
Sleeping
Sleeping
File size: 2,889 Bytes
56266ec aa87a91 53ac83e 3ff429e 22ad7f3 aa87a91 22ad7f3 53ac83e 22ad7f3 9a5dd56 4de9537 bf59c35 9a5dd56 56266ec 3ff429e 56266ec 2732528 3ff429e 3f656fb 6844ad4 3f656fb 880e759 aa87a91 3ff429e f97ddf1 |
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
from flask import Flask, request
from app import judge, judgePlus, judgeBert, tokenize, lstm_predict, gru_predict
from phoBERT import BERT_predict
from flask_cors import CORS
import threading
import time
app = Flask(__name__)
CORS(app)
@app.route("/")
def hello():
return {"hello":"Deploy success"}
@app.route("/test")
def test():
return "Test success"
@app.route("/test/<text>")
def returnText(text):
return f'The text is {text}'
@app.route("/check", methods=["POST"])
def check():
comment = request.json['comment']
result = judge(comment)
return result
@app.route("/checkplus", methods=["POST"])
def checkPlus():
comment = request.json['comment']
result = judgePlus(comment)
return result
@app.route("/checkbert", methods=["POST"])
def checkBert():
comment = request.json['comment']
result = judgeBert(comment)
return result
@app.route("/check_time")
def time():
l10 = []
l100 = []
l200 = []
t_lstm_10 = []
t_lstm_100 = []
t_lstm_200 = []
t_gru_10 = []
t_gru_100 = []
t_gru_200 = []
t_bert_10 = []
t_bert_100 = []
t_bert_200 = []
#LSTM
for com in l10:
com = tokenize(com)
t1 = time.time()
lstm_predict(com)
t2 = time.time()
t = t2-t1
t_lstm_10.append(t)
for com in l100:
com = tokenize(com)
t1 = time.time()
lstm_predict(com)
t2 = time.time()
t = t2-t1
t_lstm_100.append(t)
for com in l200:
com = tokenize(com)
t1 = time.time()
lstm_predict(com)
t2 = time.time()
t = t2-t1
t_lstm_200.append(t)
#GRU
for com in l10:
com = tokenize(com)
t1 = time.time()
gru_predict(com)
t2 = time.time()
t = t2-t1
t_gru_10.append(t)
for com in l100:
com = tokenize(com)
t1 = time.time()
gru_predict(com)
t2 = time.time()
t = t2-t1
t_gru_100.append(t)
for com in l200:
com = tokenize(com)
t1 = time.time()
gru_predict(com)
t2 = time.time()
t = t2-t1
t_gru_200.append(t)
#BERT
for com in l10:
com = tokenize(com)
t1 = time.time()
BERT_predict(com)
t2 = time.time()
t = t2-t1
t_bert_10.append(t)
for com in l100:
com = tokenize(com)
t1 = time.time()
BERT_predict(com)
t2 = time.time()
t = t2-t1
t_bert_100.append(t)
for com in l200:
com = tokenize(com)
t1 = time.time()
BERT_predict(com)
t2 = time.time()
t = t2-t1
t_bert_200.append(t)
return 'ok'
if __name__ == '__main__':
app.run(debug=False, threaded=True) |