import gradio as gr import tensorflow as tf from tensorflow.keras.preprocessing import image import numpy as np # Cargar el modelo desde Hugging Face model = tf.keras.models.load_model("ItsEnder/demo_model_deploy/resolve/main/model_mobileNetV2_MAX_70batch.h5") # Función para preprocesar las imágenes def preprocess_image(img): img = img.resize((224, 224)) img = np.array(img) img = np.expand_dims(img, axis=0) img = img / 255.0 # Normalización return img # Función para hacer predicciones def predict(img): img_array = preprocess_image(img) prediction = model.predict(img_array) predicted_class = np.argmax(prediction) return predicted_class # Crear la interfaz con Gradio interface = gr.Interface( fn=predict, inputs="image", outputs="label", title="Clasificación de imágenes con MobileNetV2", description="Sube una imagen y obtén la clase predicha." ) # Ejecutar la interfaz interface.launch()