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))) | |
image = gr.Image() | |
label = gr.Label() | |
examples = ['kentish_plover.png', 'white-faced_plover.png'] | |
intf = gr.Interface(fn=classify_images, inputs=image, outputs=label, examples=examples) | |
intf.launch() | |