File size: 571 Bytes
e658425
ef00af5
 
e658425
ef00af5
e658425
 
 
 
 
 
 
 
 
 
 
26c7c40
e658425
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from fastai.vision.all import *
import gradio as gr

learn = load_learner('model.pkl')

categories = ('Computer', 'Smartphone', 'Typewriter')

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

# Cell
image = gr.Image()
label = gr.Label()
examples = ['computer.jpg', 'smartphone.jpg', 'typewriter.jpg']

intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples, title='Is it a computer, smartphone or typewriter?', theme=gr.themes.Soft())
intf.launch(inline=False, share=True)