Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,15 @@
|
|
1 |
|
2 |
import gradio as gr
|
3 |
-
|
4 |
|
5 |
-
model =
|
6 |
|
7 |
classes = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
|
8 |
|
9 |
def predict(img):
|
10 |
-
|
11 |
-
|
|
|
12 |
|
13 |
title = "Digit Classifier - By Teeny-Tiny Castle 🏰"
|
14 |
|
@@ -19,11 +20,11 @@ head = (
|
|
19 |
"</center>"
|
20 |
)
|
21 |
|
|
|
22 |
ref = (
|
23 |
"<center>"
|
24 |
"Return to the <a href='https://github.com/Nkluge-correa/teeny-tiny_castle)'>castle</a>."
|
25 |
-
"</center>"
|
26 |
-
)
|
27 |
|
28 |
# create interface
|
29 |
demo = gr.Interface(fn=predict,
|
@@ -35,4 +36,4 @@ demo = gr.Interface(fn=predict,
|
|
35 |
article=ref)
|
36 |
|
37 |
# launch interface
|
38 |
-
demo.launch(
|
|
|
1 |
|
2 |
import gradio as gr
|
3 |
+
from huggingface_hub import from_pretrained_keras
|
4 |
|
5 |
+
model = from_pretrained_keras("AiresPucrs/digit-classifier")
|
6 |
|
7 |
classes = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
|
8 |
|
9 |
def predict(img):
|
10 |
+
img = img.reshape(1, 28, 28, 1)
|
11 |
+
prediction = model.predict(img, verbose=0).tolist()[0]
|
12 |
+
return {classes[i]: prediction[i] for i in range(10)}
|
13 |
|
14 |
title = "Digit Classifier - By Teeny-Tiny Castle 🏰"
|
15 |
|
|
|
20 |
"</center>"
|
21 |
)
|
22 |
|
23 |
+
|
24 |
ref = (
|
25 |
"<center>"
|
26 |
"Return to the <a href='https://github.com/Nkluge-correa/teeny-tiny_castle)'>castle</a>."
|
27 |
+
"</center>")
|
|
|
28 |
|
29 |
# create interface
|
30 |
demo = gr.Interface(fn=predict,
|
|
|
36 |
article=ref)
|
37 |
|
38 |
# launch interface
|
39 |
+
demo.launch()
|