Spaces:
Runtime error
Runtime error
File size: 575 Bytes
eb46e21 304210b eb46e21 304210b eb46e21 304210b eb46e21 304210b | 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 | import gradio as gr
import tensorflow as tf
import numpy as np
from PIL import Image
# Load your model
model = tf.keras.models.load_model("best_model.keras")
# Prediction function
def predict(img: Image.Image):
img = img.resize((224, 224)) # adjust size to match your model
img = np.array(img) / 255.0
img = np.expand_dims(img, axis=0)
pred = model.predict(img)
return {"prediction": pred.tolist()}
# Gradio interface
demo = gr.Interface(
fn=predict,
inputs=gr.Image(type="pil"), # <-- ensures PIL Image
outputs="json"
)
demo.launch()
|