File size: 686 Bytes
bad1e90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: app.ipynb.

# %% auto 0
__all__ = ['learn', 'categories', 'image', 'label', 'interface', 'predict']

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

# %% app.ipynb 4
learn = load_learner('lamborghini_vs_mercedes_model.pkl')

# %% app.ipynb 5
categories = ('lamborghini', 'mercedes')

def predict(img):
    pred, idx, prob = learn.predict(img)
    return dict(zip(categories, map(float, prob)))

# %% app.ipynb 7
image = gr.inputs.Image(shape=(192,192))
label = gr.outputs.Label()

interface = gr.Interface(fn=predict, inputs=image, outputs=label, examples=['lambo1.jpg', 'mercedes1.jpg'])
interface.launch(inline=False)