File size: 541 Bytes
31135b3
9659a98
0ebf6e8
 
 
 
 
9659a98
 
31135b3
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from fastai.vision.all import *
import gradio as gr
import pathlib


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


learn = load_learner('number_100.pkl')

categories = ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9')

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

inputs = gr.inputs.Image(shape=(192,192))
label = gr.outputs.Label()

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