File size: 580 Bytes
4744f93 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import gradio as gr
from tensorflow.keras.models import load_model
from tensorflow.keras.preprocessing import image
import numpy as np
# Load the model
model = load_model('best_model.h5')
def classify_image(inp):
inp = inp.reshape((-1, 224, 224, 3))
inp = preprocess_input(inp)
prediction = model.predict(inp).flatten()
return {f"Class {i}": float(prediction[i]) for i in range(2)}
image = gr.inputs.Image(shape=(224, 224))
label = gr.outputs.Label(num_top_classes=2)
gr.Interface(fn=classify_image, inputs=image, outputs=label, capture_session=True).launch()
|