agrimsomani's picture
Update app.py
e93fe0e
raw
history blame
530 Bytes
from fastai.vision.all import *
import gradio as gr
learner = load_learner('model.pkl')
categories = ('code', '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)