File size: 538 Bytes
7287d12
 
 
029c862
7287d12
029c862
7287d12
 
 
 
 
 
 
 
70956a7
7287d12
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import gradio as gr
from fastai.vision.all import *

def is_cat(x): return x[0].isupper() 

learn = load_learner("model.pkl")
categories = ("Dog", "Cat")

def image_classifier(im):
    pred, idx, probs = learn.predict(im)
    return dict(zip(categories, map(float, probs)))

input = gr.inputs.Image(shape=(192, 192))
output = gr.outputs.Label()
examples = ["dog1.jpeg", "dog2.jpeg", "cat.jpeg", "catdog.jpeg", "otter.jpeg"]

interface = gr.Interface(fn=image_classifier, inputs=input, outputs=output, examples=examples)
interface.launch()