Spaces:
Sleeping
Sleeping
import tensorflow as tf | |
import gradio as gr | |
import numpy as np | |
from PIL import Image | |
# Load the model | |
model = tf.saved_model.load('./saved_model') | |
# Define the prediction function | |
def predict(image): | |
# Preprocess the image to the required input format | |
img = np.array(image).astype(np.float32) | |
img = np.expand_dims(img, axis=0) # Add batch dimension | |
img = tf.image.resize(img, (640, 640)) # Resize if needed | |
# Perform inference | |
predictions = model(img) | |
return predictions.numpy() # Adjust output processing as needed | |
# Set up the Gradio interface | |
interface = gr.Interface(fn=predict, inputs=gr.inputs.Image(type="pil"), outputs="label") | |
interface.launch() | |