|
import fastbook |
|
fastbook.setup_book() |
|
|
|
from fastbook import * |
|
from fastai.vision.widgets import * |
|
|
|
path = Path() |
|
path.ls(file_exts='.pkl') |
|
|
|
learn_inf = load_learner(path/'export.pkl') |
|
|
|
categories = ('grizzly', 'black', 'teddy') |
|
|
|
def classify_image(img): |
|
pred,idx,probs = learn_inf.predict(img) |
|
return dict(zip(categories, map(float,probs))) |
|
|
|
image = gr.inputs.Image(shape=(192,192)) |
|
label = gr.outputs.Label() |
|
examples = ['bear.jpg'] |
|
|
|
intf = gr.Interface(fn = classify_image, inputs=image, outputs=label, examples=examples) |
|
intf.launch(inline=False) |