Spaces:
Build error
Build error
Download app.py from benfica306/grafo-api: direct link, hf CLI and curl.
- Browser
- Download file 966 Bytes
-
https://huggingface.co/spaces/benfica306/grafo-api/resolve/main/app.py
- Command line
-
hf download hf://spaces/benfica306/grafo-api/app.py
-
curl -L -o app.py https://huggingface.co/spaces/benfica306/grafo-api/resolve/main/app.py
966 Bytes
| 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() |