dielz commited on
Commit
3dd911a
·
verified ·
1 Parent(s): 823e3a4

fix accuracy display

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -16,10 +16,12 @@ def predict_image(image):
16
 
17
  predictions = model.signatures['serving_default'](tf.convert_to_tensor(image_array, dtype=tf.float32))['output_0']
18
 
 
 
19
  # Highest prediction
20
- top_index = np.argmax(predictions.numpy(), axis=1)[0]
21
  top_label = labels[top_index]
22
- top_probability = predictions.numpy()[0][top_index] * 100
23
 
24
  return {top_label:top_probability}
25
 
 
16
 
17
  predictions = model.signatures['serving_default'](tf.convert_to_tensor(image_array, dtype=tf.float32))['output_0']
18
 
19
+ probabilities = tf.nn.softmax(predictions, axis=1).numpy()
20
+
21
  # Highest prediction
22
+ top_index = np.argmax(probabilities.numpy(), axis=1)[0]
23
  top_label = labels[top_index]
24
+ top_probability = probabilities.numpy()[0][top_index] * 100
25
 
26
  return {top_label:top_probability}
27