|
from fastai import * |
|
from fastai.vision.all import * |
|
import gradio as gr |
|
import pathlib |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
learn = load_learner('bear.pkl') |
|
|
|
categories = ('black', 'grizzly', 'teddy') |
|
|
|
def classify_image(img): |
|
pred, idx, probs = learn.predict(img) |
|
return dict(zip(categories, map(float, probs))) |
|
|
|
image = gr.components.Image(type="pil", height=192, width=192) |
|
label = gr.Label() |
|
examples = ['bear.jpg', 'cat.jpg', 'dog.jpg'] |
|
|
|
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) |
|
intf.launch(inline=False) |