# AUTOGENERATED! DO NOT EDIT! File to edit: gdrive/MyDrive/Colab Notebooks/Untitled8.ipynb. # %% auto 0 __all__ = ['learn_inf', 'lbl_pred', 'image', 'label', 'examples', 'intf', 'classify_image'] # %% gdrive/MyDrive/Colab Notebooks/Untitled8.ipynb 25 from fastai.vision.all import * import gradio as gr # %% gdrive/MyDrive/Colab Notebooks/Untitled8.ipynb 27 learn_inf = load_learner('bears/export.pkl') # %% gdrive/MyDrive/Colab Notebooks/Untitled8.ipynb 33 lbl_pred = learn_inf.dls.vocab def classify_image(img): img = img.to_thumb(128,128) pred,pred_idx,probs = learn_inf.predict(img) return dict(zip(lbl_pred, map(float, probs))) # %% gdrive/MyDrive/Colab Notebooks/Untitled8.ipynb 34 image = gr.Image(type="pil") label = gr.Label() examples = ['images/black.jpg', 'images/grizzly.jpg', 'images/teddy.jpg'] intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) intf.launch(inline=False, share=True)