| import gradio as gr | |
| from transformers import pipeline | |
| MODEL_PATH = "lucsaa/classificador-de-emails" | |
| classifier = pipeline("text-classification", model=MODEL_PATH) | |
| def classificar_email(texto): | |
| """ | |
| Recebe um texto de e-mail e retorna a categoria: Produtivo ou Improdutivo. | |
| Limita o texto a 512 tokens para evitar estouro de memória. | |
| """ | |
| if not texto.strip(): | |
| return "Texto vazio" | |
| resultado = classifier(texto[:512])[0] | |
| return resultado["label"].capitalize() | |
| interface = gr.Interface( | |
| fn=classificar_email, | |
| inputs=gr.Textbox(lines=10, placeholder="Cole o texto do e-mail aqui..."), | |
| outputs=gr.Textbox(label="Categoria"), | |
| title="FocusMail - Classificador de E-mails", | |
| description="Classifique seus e-mails como Produtivo ou Improdutivo usando um modelo treinado.", | |
| allow_flagging="never" | |
| ) | |
| if __name__ == "__main__": | |
| interface.launch(share=True) | |