c-walls commited on
Commit
8129b78
·
1 Parent(s): 563b592

troubleshoot prediction

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -3,6 +3,8 @@ import tensorflow as tf
3
  import numpy as np
4
 
5
  model = tf.saved_model.load("/home/user/app/model")
 
 
6
 
7
  def mnist_classifier(img):
8
  img_tensor = tf.convert_to_tensor(img['composite'], dtype=tf.float32)
@@ -12,9 +14,9 @@ def mnist_classifier(img):
12
  img_tensor /= 255.0
13
  img_tensor = tf.expand_dims(img_tensor, 0)
14
 
15
- prediction = model.signatures['serving_default'](img_tensor)
16
- print(model.signatures['serving_default'].structured_outputs)
17
- return str(tf.argmax(prediction['output_0'], axis=1).numpy()[0])
18
 
19
  demo = gr.Interface(fn=mnist_classifier, inputs="sketchpad", outputs="text", title="MNIST Checker", description="Draw a number 0-9 to see if the model can classify it.")
20
  demo.launch()
 
3
  import numpy as np
4
 
5
  model = tf.saved_model.load("/home/user/app/model")
6
+ # Print available signatures to find the correct one
7
+ print("Available signatures:", list(model.signatures.keys()))
8
 
9
  def mnist_classifier(img):
10
  img_tensor = tf.convert_to_tensor(img['composite'], dtype=tf.float32)
 
14
  img_tensor /= 255.0
15
  img_tensor = tf.expand_dims(img_tensor, 0)
16
 
17
+ #prediction = model.signatures['serving_default'](img_tensor)
18
+ #print(model.signatures['serving_default'].structured_outputs)
19
+ #return str(tf.argmax(prediction['output_0'], axis=1).numpy()[0])
20
 
21
  demo = gr.Interface(fn=mnist_classifier, inputs="sketchpad", outputs="text", title="MNIST Checker", description="Draw a number 0-9 to see if the model can classify it.")
22
  demo.launch()