Spaces:
Sleeping
Sleeping
File size: 970 Bytes
77f2493 094ec05 77f2493 7499d49 77f2493 7499d49 af6f04f 2ec2784 7499d49 77f2493 2ec2784 7499d49 77f2493 7499d49 |
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 |
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) |