stationary / app.py
anirudh-sub's picture
Update app.py
36fa620
from fastai.vision.all import *
import gradio as gr
learn = load_learner('model_v5_87_percent_final.pkl')
categories = ('binder clip', 'calculator', 'crayon', 'eraser', 'glue', 'marker', 'pen', 'pencil', 'paper', 'tape')
def classify_image(img):
pred, idx, probs = learn.predict(img)
return dict(zip(categories, map(float, probs)))
image = gr.inputs.Image(shape=(192, 192))
label = gr.outputs.Label()
examples = ['pencil.jpg', 'pen.jpg', 'eraser.jpg', 'calculator.jpg', 'binder_clip.jpg', 'marker.jpg', 'glue.jpg', 'tape.jpg', 'crayon.jpg', 'paper.jpg']
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples, cache_examples=False)
intf.launch()