brain-tumor / model
sindhoorar's picture
Initial Commit
4744f93
raw
history blame contribute delete
No virus
580 Bytes
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()