File size: 422 Bytes
a42f963
68b3403
a42f963
68b3403
a42f963
1f08ab2
68b3403
1f08ab2
68b3403
 
 
 
 
1f08ab2
 
68b3403
1f08ab2
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 *

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

learn = load_learner('model2.pkl')

categories = ['dog', 'cat']

def predict_image(img):
    pred, pred_idx, probs = learn.predict(img)
    return dict(zip(categories, map(float, probs)))

image = gr.Image()
label = gr.Label()		
examples = ["cat.jpg", "dog.jpg"]
gr.Interface(fn=predict_image, inputs=image, outputs=label).launch()