HMPhuoc commited on
Commit
5a9d314
1 Parent(s): 3ff429e

bert option

Browse files

bert param use to indicate whether to use bert model

Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -14,7 +14,7 @@ import unicodedata as ud
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,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
- for i in range(6):
97
- result.append((result_lstm[i]+result_gru[i])/2)
 
 
 
 
 
 
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)