File size: 790 Bytes
cc0bcc8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2aba2f8
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
# AUTOGENERATED! DO NOT EDIT! File to edit: classify.ipynb.

# %% auto 0
__all__ = ['learn', 'image', 'label', 'examples', 'intf', 'classify_car']

# %% classify.ipynb 1
from fastbook import *
import gradio as gr

# %% classify.ipynb 3
learn=load_learner('models/car_classifier.pkl')

# %% classify.ipynb 5
def classify_car(img):
    img = PILImage.create(img)
    pred, pred_idx, probs = learn.predict(img)
    
    return {learn.dls.vocab[i]: probs[i].item() for i in range(len(learn.dls.vocab))}

# %% classify.ipynb 6
image=gr.components.Image()
label=gr.components.Label()
examples=[['examples/example_0.png'], ['examples/example_1.png'], ['examples/example_2.png']]
intf=gr.Interface(fn=classify_car, inputs=image, outputs=label, examples=examples).launch()
intf.launch(inline=False)