File size: 654 Bytes
f2715d2
b6c6b81
f2715d2
b6c6b81
 
 
f2715d2
a8a9728
 
 
 
e7b84b5
b6c6b81
08d42b2
b6c6b81
 
 
 
 
08d42b2
50073b8
 
b6c6b81
 
 
50073b8
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 *

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

import pathlib
plt = platform.system()
if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath

learn = load_learner('bears_model.pkl')

categories = ( 'black bear','grizzly bear'  , 'teddy bear')


image = gr.inputs.Image(shape=(194,194))
label = gr.outputs.Label()
examples = [
    'teddy_bear.jpg' , 
    'grizzly_bear.jpg' ,
    'black_bear.jpg'
]

intf = gr.Interface(fn = classify_img , inputs = image , outputs = label , examples = examples)
intf.launch(inline = False)