Spaces:
Runtime error
Runtime error
Commit
·
3f3b7d6
1
Parent(s):
a796eab
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ from huggingface_hub import from_pretrained_keras
|
|
| 3 |
from huggingface_hub import KerasModelHubMixin
|
| 4 |
import transformers
|
| 5 |
from transformers import AutoTokenizer
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
m = from_pretrained_keras('sgonzalezsilot/FakeNews-Detection-Twitter-Thesis')
|
|
@@ -41,8 +42,16 @@ def bert_encode(tokenizer,data,maximum_length) :
|
|
| 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 |
-
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
iface = gr.Interface(fn = get_news,
|
| 48 |
inputs = "text",
|
|
|
|
| 3 |
from huggingface_hub import KerasModelHubMixin
|
| 4 |
import transformers
|
| 5 |
from transformers import AutoTokenizer
|
| 6 |
+
import numpy as np
|
| 7 |
|
| 8 |
|
| 9 |
m = from_pretrained_keras('sgonzalezsilot/FakeNews-Detection-Twitter-Thesis')
|
|
|
|
| 42 |
def get_news(input_text):
|
| 43 |
sentence_length = 110
|
| 44 |
train_input_ids,train_attention_masks = bert_encode(tokenizer,input_text,sentence_length)
|
| 45 |
+
|
| 46 |
+
pred = m.predict([train_input_ids,train_attention_masks])
|
| 47 |
+
pred = np.round(pred)
|
| 48 |
+
pred = pred.flatten()
|
| 49 |
+
|
| 50 |
+
if pred == 1:
|
| 51 |
+
result = "Fake News"
|
| 52 |
+
else:
|
| 53 |
+
result = "True News"
|
| 54 |
+
return result
|
| 55 |
|
| 56 |
iface = gr.Interface(fn = get_news,
|
| 57 |
inputs = "text",
|