File size: 966 Bytes
f7f474d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
26
import gradio as gr
from transformers import pipeline

# Carrega do teu modelo público (para hackathon grátis serve)
classifier = pipeline("text-classification", model="benfica306/GrafoPropagation-v11-Pico-Multitask")

def classify(text):
    result = classifier(text)[0]
    label_map = {
        "LABEL_0": "🏛️ Mundo / World",
        "LABEL_1": "⚽ Desporto / Sports", 
        "LABEL_2": "💼 Negócios / Business",
        "LABEL_3": "🔬 Ciência & Tech / Sci/Tech"
    }
    label = label_map.get(result["label"], result["label"])
    return f"{label} (confiança: {result['score']:.1%})"

demo = gr.Interface(
    fn=classify,
    inputs=gr.Textbox(label="Notícia/Headline", placeholder="Cole aqui uma notícia..."),
    outputs=gr.Textbox(label="Categoria"),
    title="📰 GrafoPropagation-v11 (545k params - Ultra Rápido)",
    description="Classificador de notícias que corre em CPU a 75k tokens/seg. Zero GPU necessária."
)

demo.launch()