Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Carga un modelo preentrenado para clasificar texto
|
5 |
+
classifier = pipeline("text-classification", model="joeddav/xlm-roberta-large-xnli")
|
6 |
+
|
7 |
+
def classify_text(text):
|
8 |
+
result = classifier(text, candidate_labels=["videojuegos", "películas"])
|
9 |
+
return result[0]['label']
|
10 |
+
|
11 |
+
# Interfaz de Gradio
|
12 |
+
iface = gr.Interface(
|
13 |
+
fn=classify_text,
|
14 |
+
inputs=gr.Textbox(lines=2, placeholder="Pega la noticia aquí..."),
|
15 |
+
outputs="text",
|
16 |
+
title="Filtro de Noticias: ¿Videojuego o Película?"
|
17 |
+
)
|
18 |
+
iface.launch()
|