sgonzalezsilot
commited on
Commit
•
de25c83
1
Parent(s):
77f7bba
Update app.py
Browse files
app.py
CHANGED
@@ -8,6 +8,9 @@ from transformers import AutoTokenizer
|
|
8 |
m = from_pretrained_keras('sgonzalezsilot/FakeNews-Detection-Twitter-Thesis')
|
9 |
# model = from_pretrained_keras("keras-io/cct")
|
10 |
|
|
|
|
|
|
|
11 |
def bert_encode(tokenizer,data,maximum_length) :
|
12 |
input_ids = []
|
13 |
attention_masks = []
|
@@ -29,18 +32,16 @@ def bert_encode(tokenizer,data,maximum_length) :
|
|
29 |
|
30 |
return np.array(input_ids),np.array(attention_masks)
|
31 |
|
32 |
-
train_encodings = tokenizer(train_texts, truncation=True, padding=True)
|
33 |
-
test_encodings = tokenizer(test_texts, truncation=True, padding=True)
|
|
|
34 |
|
35 |
-
MODEL = "digitalepidemiologylab/covid-twitter-bert-v2"
|
36 |
-
tokenizer = AutoTokenizer.from_pretrained(MODEL)
|
37 |
|
38 |
-
sentence_length = 110
|
39 |
-
train_input_ids,train_attention_masks = bert_encode(tokenizer,train_texts,sentence_length)
|
40 |
-
test_input_ids,test_attention_masks = bert_encode(tokenizer,test_texts,sentence_length)
|
41 |
|
42 |
def get_news(input_text):
|
43 |
-
|
|
|
|
|
44 |
|
45 |
iface = gr.Interface(fn = get_news,
|
46 |
inputs = "text",
|
|
|
8 |
m = from_pretrained_keras('sgonzalezsilot/FakeNews-Detection-Twitter-Thesis')
|
9 |
# model = from_pretrained_keras("keras-io/cct")
|
10 |
|
11 |
+
MODEL = "digitalepidemiologylab/covid-twitter-bert-v2"
|
12 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL)
|
13 |
+
|
14 |
def bert_encode(tokenizer,data,maximum_length) :
|
15 |
input_ids = []
|
16 |
attention_masks = []
|
|
|
32 |
|
33 |
return np.array(input_ids),np.array(attention_masks)
|
34 |
|
35 |
+
# train_encodings = tokenizer(train_texts, truncation=True, padding=True)
|
36 |
+
# test_encodings = tokenizer(test_texts, truncation=True, padding=True)
|
37 |
+
|
38 |
|
|
|
|
|
39 |
|
|
|
|
|
|
|
40 |
|
41 |
def get_news(input_text):
|
42 |
+
sentence_length = 110
|
43 |
+
train_input_ids,train_attention_masks = bert_encode(tokenizer,input_text,sentence_length)
|
44 |
+
return m([train_input_ids,train_attention_masks])
|
45 |
|
46 |
iface = gr.Interface(fn = get_news,
|
47 |
inputs = "text",
|