Spaces:
Sleeping
Sleeping
File size: 988 Bytes
44c4e71 296a883 44c4e71 e6aa4d5 44c4e71 296a883 44c4e71 e6aa4d5 44c4e71 |
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 28 29 30 31 32 33 34 35 36 37 38 |
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
# %% auto 0
__all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'is_cat', 'classify_image']
# %% app.ipynb 2
import fastbook
fastbook.setup_book()
# %% app.ipynb 3
from fastbook import *
from fastai.vision.widgets import *
from fastai.vision.all import *
from urllib.request import urlopen
# %% app.ipynb 5
import gradio as gr
def is_cat(x): return x[0].issuper()
# %% app.ipynb 11
learn = load_learner('model.pkl')
# %% app.ipynb 13
categories = ('Dog', 'Cat')
def classify_image(img):
pref,idx,probs = learn.predict(img)
return dict(zip(categories, map(float, probs)))
# %% app.ipynb 16
image = gr.inputs.Image(shape=(192,192))
label = gr.outputs.Label()
examples = ['images/4d3b88ed-d0dc-43ec-bbaf-6babf6f310a7.jpg',
'images/5c283719-addd-4dbf-9847-eda74d0af8e7.jpg']
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
intf.launch(inline=False)
|