|
import gradio as gr |
|
import tensorflow as tf |
|
from tensorflow.keras.preprocessing import image |
|
import numpy as np |
|
|
|
|
|
model = tf.keras.models.load_model("ItsEnder/demo_model_deploy/resolve/main/model_mobileNetV2_MAX_70batch.h5") |
|
|
|
|
|
def preprocess_image(img): |
|
img = img.resize((224, 224)) |
|
img = np.array(img) |
|
img = np.expand_dims(img, axis=0) |
|
img = img / 255.0 |
|
return img |
|
|
|
|
|
def predict(img): |
|
img_array = preprocess_image(img) |
|
prediction = model.predict(img_array) |
|
predicted_class = np.argmax(prediction) |
|
return predicted_class |
|
|
|
|
|
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." |
|
) |
|
|
|
|
|
interface.launch() |
|
|