Spaces:
Build error
Build error
File size: 703 Bytes
5e2a370 fdc5f47 5e2a370 8ba6efb 5e2a370 4d358dc 5e2a370 25da73d 5e2a370 |
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 |
import gradio as gr
from fastai.vision.all import *
__all__ = ['NumberClass', 'learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
def get_y(r):
number = ''.join(filter(str.isdigit, str(r)))
return train_y[int(number)]
def NumberClass(x): return x[0].isupper()
learn = load_learner('model.pkl')
categories = ('0','1','2','3','4','5','6','7','8','9')
def classify_image(img):
pred, idx, probs = learn.predict(img)
return pred
image = gr.inputs.Image(shape=(28,28))
label = gr.outputs.Label()
examples = ['Number_3.png', 'Number_5.png']
intf = gr.Interface(fn=classify_image, inputs="sketchpad", outputs=label, examples=examples)
intf.launch(inline=False) |