Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,21 +1,26 @@
|
|
1 |
import gradio as gr
|
2 |
import re
|
3 |
|
4 |
-
from transformers import pipeline
|
5 |
|
6 |
-
|
7 |
-
classifier = pipeline("text-classification", model=model)
|
8 |
|
|
|
9 |
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
11 |
results = classifier(header + " [SEP] " + text)
|
12 |
return results[0]["label"], round(results[0]["score"], 5)
|
13 |
|
14 |
|
15 |
gradio_ui = gr.Interface(
|
16 |
-
fn=
|
17 |
title="Fake News Detector (Spanish)",
|
18 |
-
description="Enter some text and check if
|
19 |
inputs=[
|
20 |
gr.inputs.Textbox(lines=1, label="Type/Paste your headline here"),
|
21 |
gr.inputs.Textbox(lines=6, label="Type/Paste the article body here"),
|
|
|
1 |
import gradio as gr
|
2 |
import re
|
3 |
|
4 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
|
5 |
|
6 |
+
ckpt = "Narrativaai/fake-news-detection-spanish"
|
|
|
7 |
|
8 |
+
tokenizer = AutoTokenizer.from_pretrained(ckpt)
|
9 |
|
10 |
+
model = AutoModelForSequenceClassification.from_pretrained(ckpt)
|
11 |
+
|
12 |
+
classifier = pipeline("text-classification", model=model, tokenizer=tokenizer)
|
13 |
+
|
14 |
+
|
15 |
+
def prediction(header, text):
|
16 |
results = classifier(header + " [SEP] " + text)
|
17 |
return results[0]["label"], round(results[0]["score"], 5)
|
18 |
|
19 |
|
20 |
gradio_ui = gr.Interface(
|
21 |
+
fn=prediction,
|
22 |
title="Fake News Detector (Spanish)",
|
23 |
+
description="Enter some text and check if it is Real or Fake",
|
24 |
inputs=[
|
25 |
gr.inputs.Textbox(lines=1, label="Type/Paste your headline here"),
|
26 |
gr.inputs.Textbox(lines=6, label="Type/Paste the article body here"),
|