File size: 528 Bytes
fc5dcde
e6609c2
 
f997537
68e639f
e6609c2
68e639f
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from fastai.learner import load_learner
import gradio as gr


learn = load_learner('modelcat_dog.pkl')

categories = ('Cat','Dog','Lion','None','Tiger','Wolf')

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


image = gr.inputs.Image(shape=(192,192))
label = gr.outputs.Label()
examples = ['cat.jpg','food.jpg','husky.jpg','tiger.jpg','cat_dog.jpg']
intf = gr.Interface(fn=classify_img, inputs=image, outputs=label, examples=examples)
intf.launch(inline=False)