Update app.py
Browse files
app.py
CHANGED
|
@@ -1,32 +1,21 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
| 3 |
from transformers import pipeline
|
| 4 |
-
from presentation import main_title, examples
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
|
| 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()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
|
| 3 |
from transformers import pipeline
|
|
|
|
| 4 |
|
| 5 |
+
pipe = pipeline("text-classification", model="hackathon-pln-es/electricidad-base-generator-fake-news")
|
| 6 |
+
|
| 7 |
+
def predict(text):
|
| 8 |
+
return pipe(text)[0]["text-classification_text"]
|
| 9 |
+
|
| 10 |
+
title = "Detección de FakeNews en Español"
|
| 11 |
+
|
| 12 |
+
iface = gr.Interface(
|
| 13 |
+
fn=predict,
|
| 14 |
+
inputs=[gr.inputs.Textbox(label="text", lines=3)],
|
| 15 |
+
outputs='text',
|
| 16 |
+
title=title,
|
| 17 |
+
examples=[["España desaparece"]]
|
| 18 |
+
)
|
| 19 |
|
| 20 |
+
iface.launch(debug=True)
|
|
|
|
|
|
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|