Spaces:
Runtime error
Runtime error
Upload with huggingface_hub
Browse files- README.md +6 -7
- __pycache__/run.cpython-36.pyc +0 -0
- requirements.txt +1 -0
- run.py +33 -0
- screenshot.png +0 -0
README.md
CHANGED
@@ -1,12 +1,11 @@
|
|
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.6
|
8 |
-
app_file:
|
9 |
pinned: false
|
10 |
---
|
11 |
-
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
+
|
2 |
---
|
3 |
+
title: digit_classifier_main
|
4 |
+
emoji: 🔥
|
5 |
+
colorFrom: indigo
|
6 |
+
colorTo: indigo
|
7 |
sdk: gradio
|
8 |
sdk_version: 3.6
|
9 |
+
app_file: run.py
|
10 |
pinned: false
|
11 |
---
|
|
|
|
__pycache__/run.cpython-36.pyc
ADDED
Binary file (1.13 kB). View file
|
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
tensorflowhttps://gradio-main-build.s3.amazonaws.com/c3bec6153737855510542e8154391f328ac72606/gradio-3.6-py3-none-any.whl
|
run.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from urllib.request import urlretrieve
|
3 |
+
|
4 |
+
import tensorflow as tf
|
5 |
+
|
6 |
+
import gradio
|
7 |
+
import gradio as gr
|
8 |
+
|
9 |
+
urlretrieve(
|
10 |
+
"https://gr-models.s3-us-west-2.amazonaws.com/mnist-model.h5", "mnist-model.h5"
|
11 |
+
)
|
12 |
+
model = tf.keras.models.load_model("mnist-model.h5")
|
13 |
+
|
14 |
+
|
15 |
+
def recognize_digit(image):
|
16 |
+
image = image.reshape(1, -1)
|
17 |
+
prediction = model.predict(image).tolist()[0]
|
18 |
+
return {str(i): prediction[i] for i in range(10)}
|
19 |
+
|
20 |
+
|
21 |
+
im = gradio.Image(shape=(28, 28), image_mode="L", invert_colors=False, source="canvas")
|
22 |
+
|
23 |
+
demo = gr.Interface(
|
24 |
+
recognize_digit,
|
25 |
+
im,
|
26 |
+
gradio.Label(num_top_classes=3),
|
27 |
+
live=True,
|
28 |
+
interpretation="default",
|
29 |
+
capture_session=True,
|
30 |
+
)
|
31 |
+
|
32 |
+
if __name__ == "__main__":
|
33 |
+
demo.launch()
|
screenshot.png
ADDED