Spaces:
Sleeping
Sleeping
File size: 961 Bytes
b9e8f84 d15cad2 b9e8f84 862f042 b9e8f84 d15cad2 b9e8f84 d15cad2 b9e8f84 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import gradio as gr
import tensorflow as tf
import numpy as np
model = tf.keras.models.load_model('JaviSwift/cifar10_simple.keras')
def predict_image(img):
"""
Realiza la predicción sobre la imagen dada usando el modelo Keras.
"""
img = tf.image.resize(img, (32, 32))
img = img / 255.0
img = np.expand_dims(img, axis=0)
prediction = model.predict(img)
predicted_class = np.argmax(prediction)
class_names = ['airplane', 'automobile', 'bird', 'cat', 'deer', 'dog', 'frog', 'horse', 'ship', 'truck']
predicted_label = class_names[predicted_class]
return predicted_label
iface = gr.Interface(
fn=predict_image,
inputs=gr.Image(shape=(32, 32), image_mode="RGB", source="upload", tool="editor"),
outputs=gr.Label(num_top_classes=3),
title="Clasificador de Imágenes con Keras",
description="Cargue una imagen para clasificarla usando un modelo Keras entrenado en CIFAR-10."
)
iface.launch()
|