Download app.py from Alexa17/sumary: direct link, hf CLI and curl.
- Browser
- Download file 657 Bytes
-
https://huggingface.co/spaces/Alexa17/sumary/resolve/main/app.py
- Command line
-
hf download hf://spaces/Alexa17/sumary/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Alexa17/sumary/resolve/main/app.py
657 Bytes
| 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() | |