Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,16 +14,16 @@ emotion_labels = [
|
|
| 14 |
# Carga del modelo desde HuggingFace Hub
|
| 15 |
learn = from_pretrained_fastai("diribes/go_emotions")
|
| 16 |
|
| 17 |
-
# Funci贸n de predicci贸n
|
| 18 |
def clasificar_texto(texto):
|
| 19 |
-
pred,
|
| 20 |
|
| 21 |
-
# Si
|
| 22 |
-
if
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
| 27 |
return emotion_labels[int(pred)]
|
| 28 |
|
| 29 |
# Interfaz Gradio
|
|
|
|
| 14 |
# Carga del modelo desde HuggingFace Hub
|
| 15 |
learn = from_pretrained_fastai("diribes/go_emotions")
|
| 16 |
|
|
|
|
| 17 |
def clasificar_texto(texto):
|
| 18 |
+
pred, _, probs = learn.predict(texto)
|
| 19 |
|
| 20 |
+
# Si es MultiCategory (multietiqueta), convi茅rtelo a lista de strings
|
| 21 |
+
if hasattr(pred, 'items'):
|
| 22 |
+
indices_predichos = [i for i, val in enumerate(pred) if val == 1]
|
| 23 |
+
emociones = [emotion_labels[i] for i in indices_predichos]
|
| 24 |
+
return ", ".join(emociones) if emociones else "Sin emoci贸n detectada"
|
| 25 |
+
|
| 26 |
+
# Si es una 煤nica categor铆a (clasificaci贸n simple)
|
| 27 |
return emotion_labels[int(pred)]
|
| 28 |
|
| 29 |
# Interfaz Gradio
|