Update app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,32 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
3 |
from transformers import pipeline
|
|
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
def predict(text):
|
8 |
-
return pipe(text)[0]["translation_text"]
|
9 |
-
|
10 |
-
title = "Detecci贸n de Fake news espa帽olas"
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
outputs='text',
|
16 |
-
title=title,
|
17 |
-
examples=[["La fiesta en Sevilla por el vuelco electoral se alarg贸 hasta casi las dos de la madrugada. La algarab铆颅a se desbord贸 en las calles de la capital andaluza. La marcha militar ""Soldadito espa帽ol"" de Jacinto Guerrero Torres puso la nota musical a la velada."]]
|
18 |
-
)
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from datasets import load_dataset
|
3 |
from transformers import pipeline
|
4 |
+
from presentation import main_title, examples
|
5 |
|
6 |
+
model_name= 'Marmoot/electricidad-base-generator-fake-news'
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
+
def clasificar_comentarios(comentario):
|
9 |
+
cls= pipeline("text-classification", model=model_name)
|
10 |
+
return cls(comentario)[0]['label']
|
|
|
|
|
|
|
|
|
11 |
|
12 |
+
if __name__ == "__main__":
|
13 |
+
gr.Interface(
|
14 |
+
fn=clasificar_comentarios,
|
15 |
+
inputs=[
|
16 |
+
gr.inputs.Textbox(
|
17 |
+
lines=10,
|
18 |
+
label="Comentario a analizar:",
|
19 |
+
placeholder="Ingrese el comentario por favor...",
|
20 |
+
optional=False,
|
21 |
+
),
|
22 |
+
],
|
23 |
+
outputs=[
|
24 |
+
gr.outputs.HTML(
|
25 |
+
label="Resultado:"
|
26 |
+
)
|
27 |
+
],
|
28 |
+
description=main_title,
|
29 |
+
examples=examples,
|
30 |
+
theme="seafoam",
|
31 |
+
thumbnail="None",
|
32 |
+
).launch()
|