rohitzach's picture
lets try this again
371d65a
raw
history blame contribute delete
948 Bytes
# AUTOGENERATED! DO NOT EDIT! File to edit: ../Loading model.ipynb.
# %% auto 0
__all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'is_cat', 'classify_image']
# %% ../Loading model.ipynb 4
from fastai.vision.all import *
# %% ../Loading model.ipynb 5
import gradio as gr
# %% ../Loading model.ipynb 6
def is_cat(x): return x[0].isupper()
# %% ../Loading model.ipynb 7
learn = load_learner('model.pkl')
# %% ../Loading model.ipynb 17
categories = ('Is not a cat', 'Is a cat')
def classify_image(img):
pref,idx,probs = learn.predict(img)
return dict(zip(categories, map(float,probs)))
# %% ../Loading model.ipynb 24
image = gr.inputs.Image(shape=(196,196))
label = gr.outputs.Label()
examples = ['cat.jpeg', 'dog.jpeg', 'cow.jpeg']
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
#inline = false just tells gradio not to display the website here
intf.launch(inline=False)