File size: 725 Bytes
9e6ddb0
 
 
268afb1
e705bff
 
268afb1
e705bff
 
9e6ddb0
268afb1
9e6ddb0
e705bff
268afb1
9e6ddb0
268afb1
 
9e6ddb0
 
 
268afb1
 
9e6ddb0
268afb1
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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