Spaces:
Runtime error
Runtime error
File size: 798 Bytes
9901a12 |
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
from tensorflow import keras
from skimage.transform import resize
# def greet(name):
# return "Hello " + name + "!!"
# iface = gr.Interface(fn=greet, inputs="text", outputs="text")
# iface.launch()
oc_resnet50_model = keras.models.load_model('oc_model.h5')
labels = ['Malignant Lesion', 'Benign Lesion']
def classify_image(inp):
inp =resize(inp, (300, 300, 3))
inp = inp.reshape((-1, 300, 300, 3))
# inp = tf.keras.applications.mobilenet_v2.preprocess_input(inp)
prediction = oc_resnet50_model.predict(inp).flatten()
confidences = {labels[i]: float(prediction[i]) for i in range(2)}
return confidences
gr.Interface(fn=classify_image,
inputs=gr.Image(shape=(300, 300)),
outputs=gr.Label(num_top_classes=2),
).launch() |