File size: 630 Bytes
702824a
 
 
f821a29
06bdfef
 
702824a
f821a29
 
702824a
552c8eb
702824a
 
 
f821a29
702824a
 
f821a29
 
 
702824a
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
__all__ = ['learn', 'categories', 'image', 'label', 'examples', 'inf', 'classify_images']

# %% testing.ipynb 3
from fastai.vision.all import *
import gradio as gr

# %% testing.ipynb 4
learn = load_learner('export.pkl')

# %% testing.ipynb 9
categories = learn.dls.vocab
def classify_images(img):
    pred, pred_idx, probs = learn.predict(img)
    return dict(zip(categories, map(float, probs)))

# %% testing.ipynb 12
image = gr.inputs.Image(shape=(192, 192))
label = gr.outputs.Label()
examples = ['polarbear.jpg']

inf = gr.Interface(fn=classify_images, inputs=image, outputs=label, examples=examples)
inf.launch(inline=False)