File size: 950 Bytes
4c5579b
 
406195b
 
8968010
4c5579b
406195b
4c5579b
0266199
406195b
 
 
4c5579b
 
 
5ebbdb0
00e86d9
 
406195b
f96c627
406195b
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr
from fastai.vision.all import *
from fastai.vision.widgets import *
from fastai.callback.preds import load_learner
import skimage

learner = load_learner('model.pkl')

labels = learner.dls.vocab
def classify_image(img):
    pred, idx, probs = learner.predict(img)
    return dict(zip(learner.dls.vocab, map(float, probs)))
title = "Pet Breed Classifier"
description = "A pet breed classifier trained on the Oxford Pets dataset with fastai. Created as a demo for Gradio and HuggingFace Spaces."
article="<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
examples = ['siamese.jpg', 'dog.jpg']
interpretation='default'
enable_queue=True
image = gr.inputs.Image(shape=(192, 192))
label = gr.outputs.Label(num_top_classes=3)
out_pl = widgets.Output()
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
intf.launch()