File size: 541 Bytes
04eb825
e2d2bee
 
04eb825
e2d2bee
9429e33
e2d2bee
04eb825
 
 
 
 
f474931
04eb825
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from fastai.vision.all import *
import gradio as gr

learner = load_learner('model.pkl')

categories = ('code', 'diagrams','graph', 'linked-list', 'math', 'table')

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


image = gr.inputs.Image(shape=(192, 192))
label = gr.outputs.Label()
examples = ['linked-list.png', 'code.png',
            'table.png', 'graph.png', 'math.png']

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