File size: 468 Bytes
1e114fb 244da41 1e114fb 244da41 1e114fb 244da41 1e114fb 244da41 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | import gradio as gr
from fastai.vision.all import *
# logic
learn = load_learner('model.pkl')
categories = ('Dog', 'Cat')
def classify_image(img):
pred,idx,probs = learn.predict(img)
return dict(zip(categories, map(float, probs)))
# UI
image = gr.Image(height=192, width=192)
label = gr.Label(num_top_classes=2)
examples = ['dog.jpg','cat.jpg', 'dunno.jpg']
gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples).launch(share=True)
|