Spaces:
Runtime error
Runtime error
import tensorflow as tf | |
import gradio as gr | |
model = tf.keras.models.load_model('50epoch.48-0.06.h5') | |
labels = ['Diseased', 'Healthy'] | |
def classify_images(inp): | |
inp = inp[None, ...] | |
inp = tf.keras.applications.resnet.preprocess_input(inp) | |
prediction = model.predict(inp).flatten() | |
return {labels[i]: float(prediction[i]) for i in range(len(labels))} | |
image = gr.Image(shape=(224, 224)) | |
label = gr.Label(num_top_classes=3) | |
examples = [ | |
["aug_Durian diseased__0_9801.jpg"], | |
["aug_Durian healthy__0_163.jpg"], | |
["aug_Guava___diseased__0_596.jpg"], | |
["aug_Guava___healthy__0_1324.jpg"], | |
["aug_Mango___diseased__0_980.jpg"], | |
["aug_Mango___healthy__0_3867.jpg"], | |
["aug_Rambutan diseased__0_388.jpg"], | |
["aug_Rambutan healthy__0_3427.jpg"], | |
] | |
gr.Interface(fn=classify_images, inputs=image, outputs=label, interpretation="default",examples=examples).launch(share=False) |