File size: 786 Bytes
8af0813
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/app.ipynb.

# %% auto 0
__all__ = ['learn', 'image', 'lable', 'examples', 'intf', 'classify_image']

# %% ../nbs/app.ipynb 1
from fastai.vision.all import *
import gradio as gr

# %% ../nbs/app.ipynb 3
learn = load_learner('export.pkl')

# %% ../nbs/app.ipynb 7
def classify_image(img):
    pred,pred_idx,probs = learn.predict(img)
    return dict(zip(learn.dls.vocab, map(float, probs)))

# %% ../nbs/app.ipynb 10
#image = gr.inputs.Image(shape=(192,192))
image = gr.components.Image(shape=(192,192))
#lable = gr.outputs.Label()
lable = gr.components.Label()
examples = ['teddybear.jpg', 'grizzly.jpg', 'blackbear.jpg']

intf = gr.Interface(fn=classify_image, inputs=image, outputs=lable, examples=examples)
intf.launch(inline=False)