abramprz's picture
Changes gradio interface launch
6ac6a27
Raw
History Blame Contribute Delete
836 Bytes
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
# %% auto 0
__all__ = ['learn', 'categories', 'image', 'label', 'examples', 'interface', 'classify_image']
# %% app.ipynb 1
from fastai.vision.all import *
import gradio as gr
# %% app.ipynb 3
learn = load_learner('pug_or_not.pkl')
# %% app.ipynb 5
categories = ['pug', 'chihuahua', 'french bulldog']
categories.sort()
def classify_image(img):
pred, idx, probs = learn.predict(img)
return {categories[i]: float(probs[i]) for i in range(len(categories))}
# %% app.ipynb 7
image = gr.Image(label="Upload an image of a dog")
label = gr.Label()
examples = ['images/chihuahua.jpg', 'images/french_bulldog.jpg', 'images/pug.jpg']
interface = gr.Interface(fn=classify_image, inputs=image, outputs=label, title='Pug or Not', examples=examples)
interface.launch(share=True)