Spaces:
No application file
No application file
Download app.py from FCBXD/Detector_Emo: direct link, hf CLI and curl.
- Browser
- Download file 649 Bytes
-
https://huggingface.co/spaces/FCBXD/Detector_Emo/resolve/main/app.py
- Command line
-
hf download hf://spaces/FCBXD/Detector_Emo/app.py
-
curl -L -o app.py https://huggingface.co/spaces/FCBXD/Detector_Emo/resolve/main/app.py
649 Bytes
| from fastapi import FastAPI | |
| from pydantic import BaseModel | |
| from transformers import pipeline | |
| import uvicorn | |
| app = FastAPI() | |
| # Carga el modelo de Hugging Face para el análisis de emociones | |
| emotion_model = pipeline("text-classification", model="j-hartmann/emotion-english-distilroberta-base") | |
| class TextInput(BaseModel): | |
| text: str | |
| def predict_emotion(input_data: TextInput): | |
| result = emotion_model(input_data.text) | |
| return {"emotion": result[0]['label'], "score": result[0]['score']} | |
| if __name__ == "__main__": | |
| # Ejecuta el servidor Uvicorn en el puerto 8000 | |
| uvicorn.run(app, host="0.0.0.0", port=8000) | |