| | |
| | |
| |
|
| | import gradio as gr |
| | from transformers import pipeline |
| |
|
| | |
| | clf = pipeline("sentiment-analysis") |
| |
|
| | def analisar(texto): |
| | if not texto.strip(): |
| | return "Digite um texto para analisar." |
| | result = clf(texto)[0] |
| | |
| | label = "Positivo" if "POS" in result["label"].upper() else "Negativo" |
| | conf = f"Confiança: {result['score']:.2f}" |
| | return f"{label} | {conf}" |
| |
|
| | demo = gr.Interface( |
| | fn=analisar, |
| | inputs=gr.Textbox(label="Digite um texto em inglês"), |
| | outputs=gr.Textbox(label="Resultado"), |
| | title="Classificador de Sentimentos (demo)", |
| | description="Exemplo didático no Hugging Face Spaces usando Gradio + Transformers." |
| | ) |
| |
|
| | if __name__ == "__main__": |
| | demo.launch() |
| |
|