Alexa17 commited on
Commit
bb3e31a
verified
1 Parent(s): 4847378

Upload 3 files

Browse files
Files changed (3) hide show
  1. Dockerfile.txt +17 -0
  2. app.py +23 -0
  3. requirements.txt +3 -0
Dockerfile.txt ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Usar una imagen base de Python
2
+ FROM python:3.9-slim
3
+
4
+ # Establecer el directorio de trabajo en el contenedor
5
+ WORKDIR /app
6
+
7
+ # Copiar los archivos del proyecto
8
+ COPY . .
9
+
10
+ # Instalar las dependencias
11
+ RUN pip install -r requirements.txt
12
+
13
+ # Exponer el puerto para Gradio
14
+ EXPOSE 7860
15
+
16
+ # Comando para ejecutar la aplicaci贸n
17
+ CMD ["python", "app.py"]
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Cargar el modelo de Hugging Face
5
+ emotion_classifier = pipeline("text-classification", model="j-hartmann/emotion-english-distilroberta-base")
6
+
7
+ # Funci贸n para procesar el texto y devolver la emoci贸n
8
+ def predict_emotion(text):
9
+ result = emotion_classifier(text)
10
+ return result[0]['label']
11
+
12
+ # Crear la interfaz con Gradio
13
+ iface = gr.Interface(
14
+ fn=predict_emotion, # Funci贸n de predicci贸n
15
+ inputs=gr.Textbox(label="Texto"), # Entrada de texto
16
+ outputs=gr.Label(label="Emoci贸n"), # Salida de la emoci贸n detectada
17
+ title="Detector de Emociones",
18
+ description="Ingresa un texto para detectar su emoci贸n (alegr铆a, tristeza, enojo, etc.)."
19
+ )
20
+
21
+ # Ejecutar la aplicaci贸n
22
+ if __name__ == "__main__":
23
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ transformers
3
+ torch