mrm8488 commited on
Commit
77e8bd1
1 Parent(s): b9777f8

First commit

Browse files
Files changed (2) hide show
  1. app.py +31 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import re
3
+
4
+ from transformers import pipeline
5
+
6
+ model = "Narrativaai/fake-news-detection-spanish"
7
+ classifier = pipeline("text-classification", model=model)
8
+
9
+
10
+ def predict(header, text):
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=predict,
17
+ title="Fake News Detector (Spanish)",
18
+ description="Enter some text and check if model detects bullying.",
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"),
22
+ ],
23
+ outputs=[
24
+ gr.outputs.Textbox(label="Label"),
25
+ gr.outputs.Textbox(label="Score"),
26
+ ],
27
+ examples=[
28
+ ],
29
+ )
30
+
31
+ gradio_ui.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ torch
2
+ transformers