Spaces:
Sleeping
Sleeping
change prediction display
Browse files
app.py
CHANGED
|
@@ -15,13 +15,11 @@ def predict_image(image):
|
|
| 15 |
image_array = np.expand_dims(image_array, axis=0)
|
| 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(
|
| 23 |
top_label = labels[top_index]
|
| 24 |
-
top_probability =
|
| 25 |
|
| 26 |
return {top_label:top_probability}
|
| 27 |
|
|
|
|
| 15 |
image_array = np.expand_dims(image_array, axis=0)
|
| 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]
|
| 23 |
|
| 24 |
return {top_label:top_probability}
|
| 25 |
|