crobbi commited on
Commit
1751d3f
·
1 Parent(s): 7e7548e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -12
app.py CHANGED
@@ -1,18 +1,21 @@
1
  import gradio as gr
2
- import pickle
3
  import numpy as np
4
  from modelutil import create_model
5
 
6
- def test(k):
 
7
  try:
8
- if k == None:
9
- pass
10
- except:
11
- print(k.shape)
12
- k = k / 255.
13
  model = create_model()
14
- return np.argmax(model.predict(k.reshape(-1,28,28)))
15
- gr.Interface(inputs=gr.Sketchpad(),
16
- outputs="number",
17
- fn=test,
18
- live=True).launch()
 
 
 
 
 
 
 
1
  import gradio as gr
 
2
  import numpy as np
3
  from modelutil import create_model
4
 
5
+
6
+ def predict_digit(image):
7
  try:
8
+ if image == None: pass
9
+ except:
 
 
 
10
  model = create_model()
11
+ predictions = model.predict(image.reshape(1, 28, 28))
12
+ return np.argmax(predictions)
13
+
14
+ gr.Interface(
15
+ title="MNIST Digit Classifier",
16
+ fn=predict_digit,
17
+ inputs=gr.Sketchpad(input_shape=(28, 28), label="Draw a digit"),
18
+ outputs="number",
19
+ live=True
20
+ ).launch()
21
+