agrimsomani's picture
added another category
9429e33
raw
history blame contribute delete
541 Bytes
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)