File size: 671 Bytes
f314ce9
 
 
 
 
e61cddc
 
 
b1d683f
51c5936
b1d683f
f314ce9
 
 
 
 
 
 
 
 
 
 
a88966c
f314ce9
a88966c
f314ce9
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
from fastai.vision.all import *
from fastai.text.all import *
from fastai.collab import *
from fastai.tabular.all import * 

# import pathlib
# temp = pathlib.PosixPath
# pathlib.PosixPath = pathlib.WindowsPath

import gradio as gr

learn = load_learner('model.pkl')   

categories = ('golden', 'not golden')

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


image = gr.inputs.Image(shape=(192, 192))
label = gr.outputs.label(num_top_classes=2)
#examples = ["golden_retriever.jpg", "cat.jpg", "dog.jpg"]

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