Spaces:
Sleeping
Sleeping
File size: 953 Bytes
1335d7c 0519ac9 1335d7c bba1729 dc7601d 038a1fb bba1729 13b99bb 038a1fb 13b99bb 84fbdea |
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 26 27 |
# 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)
|