dieineb commited on
Commit
76bdd3d
1 Parent(s): 9dd6f49

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -1,14 +1,15 @@
1
 
2
  import gradio as gr
3
- import tensorflow as tf
4
 
5
- model = tf.keras.models.load_model("./digit-classifier.keras")
6
 
7
  classes = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
8
 
9
  def predict(img):
10
- prediction = model.predict(img.reshape(1, 28, 28, 1), verbose=0).tolist()[0]
11
- return {classes[i]: prediction[i] for i in range(10)}
 
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(share=True )
 
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()