app.py
CHANGED
|
@@ -79,11 +79,22 @@ def draw_plot(pred_img, seg):
|
|
| 79 |
FULL_LABEL_MAP = np.arange(len(LABEL_NAMES)).reshape(len(LABEL_NAMES), 1)
|
| 80 |
FULL_COLOR_MAP = label_to_color_image(FULL_LABEL_MAP)
|
| 81 |
|
|
|
|
| 82 |
unique_labels = np.unique(seg.astype("uint8"))
|
|
|
|
|
|
|
| 83 |
ax = plt.subplot(grid_spec[1])
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
plt.xticks([], [])
|
| 88 |
ax.tick_params(width=0.0, labelsize=25)
|
| 89 |
return fig
|
|
|
|
| 79 |
FULL_LABEL_MAP = np.arange(len(LABEL_NAMES)).reshape(len(LABEL_NAMES), 1)
|
| 80 |
FULL_COLOR_MAP = label_to_color_image(FULL_LABEL_MAP)
|
| 81 |
|
| 82 |
+
# Limit unique_labels to be within the range of colormap
|
| 83 |
unique_labels = np.unique(seg.astype("uint8"))
|
| 84 |
+
unique_labels = unique_labels[unique_labels < len(colormap)]
|
| 85 |
+
|
| 86 |
ax = plt.subplot(grid_spec[1])
|
| 87 |
+
|
| 88 |
+
if len(unique_labels) > 0:
|
| 89 |
+
plt.imshow(FULL_COLOR_MAP[unique_labels].astype(np.uint8), interpolation="nearest")
|
| 90 |
+
ax.yaxis.tick_right()
|
| 91 |
+
plt.yticks(range(len(unique_labels)), LABEL_NAMES[unique_labels])
|
| 92 |
+
else:
|
| 93 |
+
# Handle case when there are no unique labels
|
| 94 |
+
plt.imshow(np.zeros((1, 1, 3), dtype=np.uint8))
|
| 95 |
+
ax.yaxis.tick_right()
|
| 96 |
+
plt.yticks([], [])
|
| 97 |
+
|
| 98 |
plt.xticks([], [])
|
| 99 |
ax.tick_params(width=0.0, labelsize=25)
|
| 100 |
return fig
|