File size: 704 Bytes
9f38b11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import gradio as gr
from fastai.vision.all import load_learner

model = load_learner('export.pkl')

categories = ('george', 'not_george')

def classify_bird(img):
    pred, idx, probs = model.predict(img)
    return dict(zip(categories, map(float, probs)))

image = gr.inputs.Image(shape=(256, 256))
label = gr.outputs.Label(num_top_classes=5)

examples = ['george1.jpeg', 'george2.jpg', 'george3.jpeg', 'not_george1.jpg', 'not_george2.jpg', 'not_george3.jpg']

iface = gr.Interface(
    fn=classify_bird,
    inputs=image, 
    outputs=label, 
    examples=examples, 
    title='George Classifier', 
    description='Determines whether an image is of george',
    allow_flagging='never'
)
iface.launch()