File size: 908 Bytes
3f84a22
 
 
 
 
9bf50d5
c70ff79
9bf50d5
 
 
 
c70ff79
 
 
 
 
 
 
 
1d1dda3
256f266
c70ff79
1d1dda3
9bf50d5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os

os.system("pip uninstall -y gradio")
os.system("pip install gradio==2.6.4")

import gradio as gr
from fastai.vision.all import *

def greet(name):
    return "Hello " + name + "!!"

learn = load_learner('export.pkl')

def pre(image):
  pilim= PILImageBW.create(image)
  t = learn.dls.test_dl([pilim], rm_type_tfms=None, num_workers=0)
  p,_,d= learn.get_preds(dl=t,with_decoded=True)
  return p.argmax().item()

title = "Hand written Digit Classifier"
description = " A Basic CNN trained on MNSIT Dataset using Pytorch and Fast.ai. It achieved an accuracy of 99.2 %.<br> This is my first app so i could not properly convert the image from the sketchpad to a proper 28*28 pixel image as in MNSIT database. Hence, please try to draw the digits big and in center for best accuracy. "

iface = gr.Interface(fn=pre, inputs="sketchpad", outputs="text",title=title,description=description)
iface.launch()