Niqull commited on
Commit
29196b3
1 Parent(s): 40c38d1

Testing george shakan tutorial

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -3,9 +3,9 @@ from fastbook import load_learner
3
  from fast.ai.vision.all import *
4
 
5
  def predict(im):
6
- im = PILImage.create(im)
7
- pred, pred_idx, probs = model.predict(im)
8
- return {labels[i]: float(probs[i]) for i in range (len(labels))}
9
 
10
  labels = learn.dls.vocab
11
 
@@ -13,7 +13,7 @@ model = load_learner('./dr_model.pkl')
13
 
14
  demo = gr.Interface(
15
  fn=predict,
16
- inputs=gr.inputs.Image(shape=(28,28),invert_colors=True, source="canvas"),
17
- outputs=gr.outputs.Label(num_top_classes=3),
18
- interpretation="default")
19
  demo.launch()
 
3
  from fast.ai.vision.all import *
4
 
5
  def predict(im):
6
+ im = im.reshape(1, 28*28)/255.0
7
+ pred = model.predict(im)[0]
8
+ return int(pred)
9
 
10
  labels = learn.dls.vocab
11
 
 
13
 
14
  demo = gr.Interface(
15
  fn=predict,
16
+ inputs="sketchpad",
17
+ outputs = "label")
18
+
19
  demo.launch()