GameNewsFilter / app.py
Lorefielle's picture
Update app.py
268afb1 verified
raw
history blame contribute delete
725 Bytes
import gradio as gr
from transformers import pipeline
# Carga el modelo
classifier = pipeline(
"text-classification",
model="finiteautomata/bertweet-base-sentiment-analysis",
device=-1
)
# Función de clasificación
def classify_text(text):
result = classifier(text)
return "videojuegos" if result[0]['label'] == 'POS' else "películas"
# Configuración de Gradio con endpoints API
app = gr.Interface(
fn=classify_text,
inputs=gr.Textbox(lines=2, placeholder="Pega la noticia aquí..."),
outputs="text",
title="Filtro de Noticias: ¿Videojuego o Película?",
api_name="predict" # <--- ¡Clave para exponer la API!
)
app.launch(show_api=True) # Muestra la documentación de la API