DavidD003's picture
Update app.py
f7d89c7
raw
history blame
555 Bytes
import gradio as gr
from fastai.vision.all import *
from PIL import Image
#
#learn = load_learner('export.pkl')
learn = torch.load('digit_classifier.pth')
labels = [str(x) for x in range(10)]
def predict(img):
#First take input and reduce it to 8x8 px as the dataset was
img = PILImage.create(img)
pred,pred_idx,probs = learn.predict(img)
return {labels[i]: float(probs[i]) for i in range(len(labels))}
gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3)).launch(share=True)