File size: 981 Bytes
811e05a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2860f02
811e05a
 
 
 
 
 
 
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('export (2).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 = "Oklahoma Snake Classifier"
description = "A snake classifier trained on pictures of Oklahoma Snakes 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 = ['cottonmouth.jpeg', 'rattlesnake.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()