Spaces:
Running
Running
fix accuracy display
Browse files
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(
|
21 |
top_label = labels[top_index]
|
22 |
-
top_probability =
|
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 |
|