hwberry2 commited on
Commit
c3d5e68
·
1 Parent(s): e9d74ac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -64,9 +64,12 @@ with gr.Blocks() as demo:
64
  # the image can be passed as a PIL or numpy
65
  # create the final model for production
66
  probability_model = tf.keras.Sequential([model, tf.keras.layers.Softmax()])
67
-
 
 
 
68
  # Make a prediction using the model
69
- prediction = probability_model.predict(img)
70
 
71
  # Postprocess the prediction and return it
72
  return np.argmax(predictions[0])
 
64
  # the image can be passed as a PIL or numpy
65
  # create the final model for production
66
  probability_model = tf.keras.Sequential([model, tf.keras.layers.Softmax()])
67
+
68
+ # Normalize the pixel values
69
+ img_normal = img / 255.0
70
+ img_normal = img_normal.reshape((1, 28, 28))
71
  # Make a prediction using the model
72
+ prediction = probability_model.predict(img_normal)
73
 
74
  # Postprocess the prediction and return it
75
  return np.argmax(predictions[0])