File size: 544 Bytes
a42f963
68b3403
a42f963
68b3403
a42f963
b413ac9
68b3403
1f08ab2
68b3403
 
 
 
 
29d8965
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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 predict_image(img):
    pred, pred_idx, probs = learn.predict(img)
    return dict(zip(categories, map(float, probs)))

with gr.Blocks() as demo:
    gr.Markdown("# Cat or Dog Classifier Demo FastAI By Donald and Elvis")
    image = gr.Image()
    label = gr.Label()		
    examples = ["cat.jpg", "dog.jpg"]
    gr.Interface(fn=predict_image, inputs=image, outputs=label)

demo.launch()