#!/usr/bin/env python # coding: utf-8 # In[1]: #|default_exp app # ## **Which bear is it?** # In[ ]: #|export from fastai.vision.all import * import gradio as gr # In[ ]: #|export learn = load_learner('export.pkl') # In[ ]: #|export categories = ('black', 'grizzly', 'teddy') def classify_image(img): pred, idx, prob = learn.predict(img) return dict(zip(categories, map(float, prob))) # In[ ]: #|export inputs = gr.Image(shape = (224, 224)) outputs = gr.Label() examples = ['./black_bear.jpg', './grizzly_bear.jpg', './teddy_bear.jpg'] intf = gr.Interface(inputs = inputs, outputs = outputs, fn = classify_image, examples = examples) intf.launch(inline = False, share = True)