File size: 471 Bytes
9dfb913
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from fastai.vision.all import *
import gradio as gr

learn = load_learner('instrument_model.pkl');

def vocab = ['clarinet', 'french horn', 'oboe', 'oboe d amore', 'saxophone', 'trombone', 'trumpet']

def classify_image(image):
    pre, idx, probs = learn.predict(image)
    return dict(zip(vocab, probs))

image = gr.inputs.Image(shape=(250, 250))
label = gr.outputs.Label()

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