Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,13 +3,13 @@ import tensorflow as tf
|
|
| 3 |
import numpy as np
|
| 4 |
from tensorflow.keras.preprocessing import image
|
| 5 |
|
| 6 |
-
# Cargar el modelo (
|
| 7 |
def load_model():
|
| 8 |
-
return tf.keras.models.load_model("modelo_frutas_transfer.
|
| 9 |
|
| 10 |
model = load_model()
|
| 11 |
|
| 12 |
-
#
|
| 13 |
class_names = ['Manzana', 'Banana', 'Naranja', 'Pera', 'Uva']
|
| 14 |
|
| 15 |
# Funci贸n de predicci贸n
|
|
@@ -18,10 +18,10 @@ def predict_image(image_input):
|
|
| 18 |
img_array = image.img_to_array(img) / 255.0
|
| 19 |
img_array = np.expand_dims(img_array, axis=0)
|
| 20 |
pred = model.predict(img_array)
|
| 21 |
-
predicted_class = np.argmax(pred, axis=1)
|
| 22 |
-
return class_names[predicted_class
|
| 23 |
|
| 24 |
-
# Interfaz
|
| 25 |
iface = gr.Interface(
|
| 26 |
fn=predict_image,
|
| 27 |
inputs=gr.Image(type="file", label="Cargar imagen de fruta"),
|
|
|
|
| 3 |
import numpy as np
|
| 4 |
from tensorflow.keras.preprocessing import image
|
| 5 |
|
| 6 |
+
# Cargar el modelo (.keras)
|
| 7 |
def load_model():
|
| 8 |
+
return tf.keras.models.load_model("modelo_frutas_transfer.keras")
|
| 9 |
|
| 10 |
model = load_model()
|
| 11 |
|
| 12 |
+
# Clases del modelo (ajusta si es necesario)
|
| 13 |
class_names = ['Manzana', 'Banana', 'Naranja', 'Pera', 'Uva']
|
| 14 |
|
| 15 |
# Funci贸n de predicci贸n
|
|
|
|
| 18 |
img_array = image.img_to_array(img) / 255.0
|
| 19 |
img_array = np.expand_dims(img_array, axis=0)
|
| 20 |
pred = model.predict(img_array)
|
| 21 |
+
predicted_class = np.argmax(pred, axis=1)[0]
|
| 22 |
+
return class_names[predicted_class]
|
| 23 |
|
| 24 |
+
# Interfaz Gradio
|
| 25 |
iface = gr.Interface(
|
| 26 |
fn=predict_image,
|
| 27 |
inputs=gr.Image(type="file", label="Cargar imagen de fruta"),
|