Spaces:
Running
Running
bert option
Browse filesbert param use to indicate whether to use bert model
app.py
CHANGED
@@ -14,7 +14,7 @@ import unicodedata as ud
|
|
14 |
|
15 |
from underthesea import word_tokenize
|
16 |
|
17 |
-
|
18 |
|
19 |
# Load tokenizer
|
20 |
# fp = Path(__file__).with_name('tokenizer.pkl')
|
@@ -76,7 +76,7 @@ def plot(result):
|
|
76 |
return p
|
77 |
pass
|
78 |
|
79 |
-
def judge(x):
|
80 |
|
81 |
label = ['độc hại', 'cực kì độc hại', 'tục tĩu', 'đe dọa', 'xúc phạm', 'thù ghét cá nhân']
|
82 |
result = []
|
@@ -93,7 +93,13 @@ def judge(x):
|
|
93 |
result_lstm = np.round(lstm_pred, 2)
|
94 |
result_gru = np.round(gru_pred, 2)
|
95 |
#result_bert = np.round(bert_pred, 2)
|
96 |
-
|
97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
|
99 |
return (result)
|
|
|
14 |
|
15 |
from underthesea import word_tokenize
|
16 |
|
17 |
+
from phoBERT import BERT_predict
|
18 |
|
19 |
# Load tokenizer
|
20 |
# fp = Path(__file__).with_name('tokenizer.pkl')
|
|
|
76 |
return p
|
77 |
pass
|
78 |
|
79 |
+
def judge(x, bert=False):
|
80 |
|
81 |
label = ['độc hại', 'cực kì độc hại', 'tục tĩu', 'đe dọa', 'xúc phạm', 'thù ghét cá nhân']
|
82 |
result = []
|
|
|
93 |
result_lstm = np.round(lstm_pred, 2)
|
94 |
result_gru = np.round(gru_pred, 2)
|
95 |
#result_bert = np.round(bert_pred, 2)
|
96 |
+
if bert == True:
|
97 |
+
bert_pred = BERT_predict(x)
|
98 |
+
result_bert = np.round(bert_pred, 2)
|
99 |
+
for i in range(6):
|
100 |
+
result.append((result_lstm[i]+result_gru[i]+result_bert[i])/3)
|
101 |
+
else:
|
102 |
+
for i in range(6):
|
103 |
+
result.append((result_lstm[i]+result_gru[i])/2)
|
104 |
|
105 |
return (result)
|