catsdogs / app.py
iamalos's picture
Add app
403c7fa
raw
history blame
No virus
614 Bytes
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
# %% auto 0
__all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'classify_image']
# %% app.ipynb 3
learn = load_learner('cats.pkl')
# %% app.ipynb 5
categories = ('Dog', 'Cat')
def classify_image(img):
pred, idx, probs = learn.predict(img)
return dict(zip(categories, map(float, probs)))
# %% app.ipynb 8
image = Image(shape=(192,192))
label = Label()
examples = ['dog.jpeg', 'cat.jpeg', 'lemon.jpg']
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
intf.launch(inline=True, share=True)