Spaces:
Sleeping

Bernd Helzer
Fixed code
bd4fae2
Raw History Blame Contribute Delete
570 Bytes
from fastai.vision.all import *
import gradio as gr
# Cell
learn = load_learner('nordic_flags.pkl')
# Cell
categories = ('Denmark', 'Finland', 'Iceland', 'Norway', 'Other', 'Sweden')
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 = ['denmark.jpg', 'finland.jpg', 'iceland.jpg', 'norway.jpg', 'sweden.jpg', 'usa.jpg']
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
intf.launch(inline=False, share=True)