File size: 657 Bytes
aa81d8f cc0b273 aa81d8f cc0b273 aa81d8f cc0b273 aa81d8f cc0b273 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import gradio as gr
from transformers import pipeline
# Cargar el modelo de Hugging Face para an谩lisis de emociones
classifier = pipeline("text-classification", model="j-hartmann/emotion-english-distilroberta-large")
# Funci贸n para predecir la emoci贸n
def detect_emotion(text):
result = classifier(text)
emotion = result[0]['label']
return emotion
# Crear la interfaz con Gradio
interface = gr.Interface(
fn=detect_emotion,
inputs="text",
outputs="text",
live=True,
title="Detector de Emociones",
description="Introduce un texto para detectar la emoci贸n que expresa."
)
# Lanzar la interfaz
interface.launch()
|