import gradio as gr from fastai.text.all import * learn = load_learner('modelo_emociones_fastai.pkl') categorias = learn.dls.vocab[1] def clasificar_emocion(texto): pred, pred_idx, probs = learn.predict(texto) return dict(zip(categorias, map(float, probs))) interfaz = gr.Interface( fn=clasificar_emocion, inputs=gr.Textbox(lines=3, placeholder="Escribe un texto en inglés aquí..."), outputs=gr.Label(num_top_classes=3), title="🤖 Analizador de Emociones", description="Modelo de Deep Learning entrenado con Fastai (ULMFiT) capaz de detectar 6 emociones distintas en texto.", examples=["I just got a promotion at work, this is amazing!", "I feel so lonely and cold today.", "Don't you dare talk to me like that!"] ) interfaz.launch()