File size: 809 Bytes
3aabbb4 d7dda89 3aabbb4 dd551ac 3aabbb4 d7dda89 3aabbb4 |
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 |
# AUTOGENERATED! DO NOT EDIT! File to edit: catgradio.ipynb.
# %% auto 0
__all__ = ['learn', 'categories', 'image_input', 'label_output', 'iface', 'is_cat', 'classify_image']
# %% catgradio.ipynb 2
from fastai.vision.all import *
import gradio as gr
def is_cat(x):
return x[0].isupper()
# %% catgradio.ipynb 4
learn = load_learner('model.pkl')
# %% catgradio.ipynb 6
categories = ('Dog', 'Cat')
def classify_image(img):
print('hi')
pred,idx,probs = learn.predict(img)
return dict(zip(categories, map(float,probs)))
# %% catgradio.ipynb 8
image_input = gr.Image(height=192, width=192)
label_output = gr.Label()
iface = gr.Interface(
fn=classify_image,
inputs=image_input,
outputs=label_output,
examples=['dog.jpg', 'cat.jpg', 'dunno.jpg'],
)
iface.launch(inline=False)
|