Update app.py
Browse files
app.py
CHANGED
@@ -23,9 +23,11 @@ label_mapping = {
|
|
23 |
}
|
24 |
|
25 |
# Función de predicción
|
26 |
-
def predict(
|
27 |
-
img =
|
28 |
-
|
|
|
|
|
29 |
pred_emotion, pred_emotion_idx, probs_emotion = learn_emotion.predict(img)
|
30 |
pred_sentiment, pred_sentiment_idx, probs_sentiment = learn_sentiment.predict(img)
|
31 |
|
@@ -53,7 +55,7 @@ examples = [
|
|
53 |
|
54 |
iface = gr.Interface(
|
55 |
fn=predict,
|
56 |
-
inputs=gr.Image(
|
57 |
outputs=[gr.Label(label='Emoción'), gr.Label(label='Sentimiento')],
|
58 |
title=title,
|
59 |
examples=examples,
|
@@ -63,5 +65,3 @@ iface = gr.Interface(
|
|
63 |
)
|
64 |
|
65 |
iface.launch(enable_queue=True)
|
66 |
-
|
67 |
-
|
|
|
23 |
}
|
24 |
|
25 |
# Función de predicción
|
26 |
+
def predict(img):
|
27 |
+
img = img.convert('L') # Convertir la imagen a escala de grises
|
28 |
+
img = img.resize((48, 48)) # Redimensionar la imagen a (48, 48)
|
29 |
+
img = PILImage.create(img) # Convertir a PILImage
|
30 |
+
|
31 |
pred_emotion, pred_emotion_idx, probs_emotion = learn_emotion.predict(img)
|
32 |
pred_sentiment, pred_sentiment_idx, probs_sentiment = learn_sentiment.predict(img)
|
33 |
|
|
|
55 |
|
56 |
iface = gr.Interface(
|
57 |
fn=predict,
|
58 |
+
inputs=gr.Image(type='pil'), # Eliminar el argumento 'shape'
|
59 |
outputs=[gr.Label(label='Emoción'), gr.Label(label='Sentimiento')],
|
60 |
title=title,
|
61 |
examples=examples,
|
|
|
65 |
)
|
66 |
|
67 |
iface.launch(enable_queue=True)
|
|
|
|