Spaces:
Sleeping
Sleeping
JDomingoDelgadoAlonso
commited on
Commit
·
e20469b
1
Parent(s):
63ba7a8
si
Browse files- app.py +17 -4
- requirements.txt +3 -0
app.py
CHANGED
@@ -1,7 +1,20 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
7 |
-
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
clasificador = pipeline("sentiment-analysis", model="pysentimiento/robertuito-sentiment-analysis")
|
5 |
+
|
6 |
+
def puntuacion_sentimientos(texto):
|
7 |
+
resultado = clasificador(texto)
|
8 |
+
print(resultado)
|
9 |
+
etiqueta = resultado[0]["label"]
|
10 |
+
if(etiqueta == "POS" ):
|
11 |
+
respuesta = "Tu frase es muy positiva"
|
12 |
+
elif etiqueta == "NEG":
|
13 |
+
respuesta = "Tu frase es muy negativa"
|
14 |
+
else:
|
15 |
+
respuesta = "ni fu ni fa"
|
16 |
+
return respuesta
|
17 |
+
|
18 |
+
demo = gr.Interface(fn=puntuacion_sentimientos, inputs="text", outputs="text")
|
19 |
+
demo.launch()
|
20 |
|
|
|
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
gradio==5.20.0
|
2 |
+
transformers==4.49.0
|
3 |
+
torch==2.6.0
|