Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -36,8 +36,9 @@ labels = [
|
|
36 |
]
|
37 |
|
38 |
def classify_image(image):
|
|
|
39 |
image = tf.image.resize(image, (224, 224))
|
40 |
-
image = tf.expand_dims(image, axis=0)
|
41 |
prediction = model.predict(image).flatten()
|
42 |
confidences = {labels[i]: float(prediction[i]) for i in range(len(labels))}
|
43 |
return confidences
|
@@ -97,7 +98,8 @@ gr.Interface(
|
|
97 |
title=title,
|
98 |
article=article,
|
99 |
description=description,
|
100 |
-
inputs=gr.Image(
|
101 |
outputs=gr.Label(num_top_classes=4),
|
102 |
examples=examples
|
103 |
).launch()
|
|
|
|
36 |
]
|
37 |
|
38 |
def classify_image(image):
|
39 |
+
# Redimensionar la imagen a (224, 224) antes de la predicción
|
40 |
image = tf.image.resize(image, (224, 224))
|
41 |
+
image = tf.expand_dims(image, axis=0) # Añadir una dimensión para el batch
|
42 |
prediction = model.predict(image).flatten()
|
43 |
confidences = {labels[i]: float(prediction[i]) for i in range(len(labels))}
|
44 |
return confidences
|
|
|
98 |
title=title,
|
99 |
article=article,
|
100 |
description=description,
|
101 |
+
inputs=gr.Image(),
|
102 |
outputs=gr.Label(num_top_classes=4),
|
103 |
examples=examples
|
104 |
).launch()
|
105 |
+
|