firstmodel / app.py
pbodsk's picture
styling
26c7c40
raw
history blame contribute delete
571 Bytes
from fastai.vision.all import *
import gradio as gr
learn = load_learner('model.pkl')
categories = ('Computer', 'Smartphone', 'Typewriter')
def classify_image(img):
pred,idx,probs = learn.predict(img)
return dict(zip(categories, map(float,probs)))
# Cell
image = gr.Image()
label = gr.Label()
examples = ['computer.jpg', 'smartphone.jpg', 'typewriter.jpg']
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples, title='Is it a computer, smartphone or typewriter?', theme=gr.themes.Soft())
intf.launch(inline=False, share=True)