cat_or_dog / app.py
chrwittm's picture
updated gradio image initialization
42f9018
raw
history blame contribute delete
676 Bytes
# AUTOGENERATED! DO NOT EDIT! File to edit: ../app.ipynb.
# %% auto 0
__all__ = ['learn', 'image', 'label', 'examples', 'intf', 'classify_image']
# %% ../app.ipynb 3
from fastai.vision.all import *
import gradio as gr
# %% ../app.ipynb 7
learn = load_learner('export.pkl')
# %% ../app.ipynb 13
def classify_image(img):
pred,pred_idx,probs = learn.predict(img)
return dict(zip(learn.dls.vocab, map(float, probs)))
# %% ../app.ipynb 18
image = gr.components.Image(height=192, width=192)
label = gr.components.Label()
examples = ['cat.jpg', 'dog.jpg']
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
intf.launch(inline=False)