Spaces:
Running
Running
File size: 817 Bytes
fd7ac62 |
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 |
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../Untitled-1.ipynb.
# %% auto 0
__all__ = ['model_path', 'learn', 'categories', 'is_cat', 'classify_image']
# %% ../../Untitled-1.ipynb 0
import gradio as gr
from fastai.vision.all import *
def is_cat(x): return x[0].isupper()
# %% ../../Untitled-1.ipynb 2
model_path = Path('model.pkl')
learn = load_learner(model_path)
# %% ../../Untitled-1.ipynb 4
categories = ('dog', 'cat')
def classify_image(img):
pred,idx,probs = learn.predict(img)
return dict(zip(categories, map(float,probs)))
# %% ../../Untitled-1.ipynb 6
gr.Interface(fn = classify_image,
inputs="image",
outputs="label",
title = "Dog or Cat",
description="Sample workflow",
examples = ['dog.jpg']
).launch()
|