Muhammad Abdullahi
removed the shape function
af6f04f
raw
history blame contribute delete
970 Bytes
import gradio as gr
from fastai.vision.all import *
learner = load_learner('model.pkl')
categories = ('Kentish plover', 'White-faced plover')
def classify_images(img):
pred, index, probs = learner.predict(img)
return dict(zip(categories, map(float, probs)))
# return {learner.dls.vocab[i]: float(probs[i]) for i in range(len(learner.dls.vocab))}
image = gr.Image()
# label = gr.outputs.Label()
examples = ['kentish.png', 'white-faced.png']
intf = gr.Interface(fn=classify_images, inputs=image, outputs='label', examples=examples)
intf.launch(inline=False)
# intface = gr.Interface(fn=classify_images, inputs=gr.inputs.Image(type='pil'),
# outputs=gr.outputs.Label(num_top_classes=2),
# title="Kentish plover vs White-faced plover Classifier",
# description="Upload an image of either Kentish plover and White-faced plover."
# )
# intface.launch(share=True)