File size: 708 Bytes
31135b3
9659a98
0ebf6e8
 
 
 
d98c8b5
9659a98
 
31135b3
 
 
 
 
 
 
 
 
 
9040fd1
31135b3
9040fd1
31135b3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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()
examples = ['0.jpg', '1.jpg', '2.png', '3.jpg', '4.jpg', '5.jpeg', '6.png', '7.jpg', '8.jpeg', '9.jpg',]

iface = gr.Interface(fn=classify_img, inputs=inputs, outputs=label, examples=examples, title="Insert an image of any number 0-9")
iface.launch(inline=False)