Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
|
|
|
| 7 |
try:
|
| 8 |
-
if
|
| 9 |
-
|
| 10 |
-
except:
|
| 11 |
-
print(k.shape)
|
| 12 |
-
k = k / 255.
|
| 13 |
model = create_model()
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
|