|
|
|
|
|
|
|
__all__ = ['learn', 'image', 'label', 'examples', 'intf', 'classify_image'] |
|
|
|
|
|
from fastai.vision.all import * |
|
import gradio as gr |
|
|
|
|
|
def classify_image(img): |
|
pred,pred_idx,probs = learn.predict(img) |
|
return dict(zip(learn.dls.vocab, map(float, probs))) |
|
|
|
|
|
|
|
learn = load_learner('export.pkl') |
|
|
|
|
|
|
|
|
|
|
|
|
|
image = gr.components.Image(shape=(192,192)) |
|
label = gr.components.Label() |
|
examples = ['teddy.png', 'grizzly.jpg', 'black.jpeg'] |
|
|
|
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) |
|
intf.launch(inline=False) |