Alexa17's picture
Upload 3 files
bb3e31a verified
raw
history blame
836 Bytes
import gradio as gr
from transformers import pipeline
# Cargar el modelo de Hugging Face
emotion_classifier = pipeline("text-classification", model="j-hartmann/emotion-english-distilroberta-base")
# Funci贸n para procesar el texto y devolver la emoci贸n
def predict_emotion(text):
result = emotion_classifier(text)
return result[0]['label']
# Crear la interfaz con Gradio
iface = gr.Interface(
fn=predict_emotion, # Funci贸n de predicci贸n
inputs=gr.Textbox(label="Texto"), # Entrada de texto
outputs=gr.Label(label="Emoci贸n"), # Salida de la emoci贸n detectada
title="Detector de Emociones",
description="Ingresa un texto para detectar su emoci贸n (alegr铆a, tristeza, enojo, etc.)."
)
# Ejecutar la aplicaci贸n
if __name__ == "__main__":
iface.launch()