Spaces:
Runtime error
Runtime error
finish
Browse files
app.py
CHANGED
|
@@ -59,29 +59,13 @@ def label_to_color_image(label):
|
|
| 59 |
|
| 60 |
|
| 61 |
def draw_plot_with_labels(pred_img, seg):
|
| 62 |
-
fig = plt.
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
plt.subplot(grid_spec[0])
|
| 67 |
-
plt.imshow(pred_img)
|
| 68 |
-
plt.axis('off')
|
| 69 |
|
| 70 |
# ๋ผ๋ฒจ ์ด๋ฆ์ ์ถ๊ฐํ๊ธฐ ์ํ ์ฝ๋
|
| 71 |
LABEL_NAMES = np.asarray(labels_list)
|
| 72 |
-
|
| 73 |
-
FULL_COLOR_MAP = label_to_color_image(FULL_LABEL_MAP)
|
| 74 |
-
|
| 75 |
-
unique_labels = np.unique(seg.numpy().astype("uint8"))
|
| 76 |
-
ax = plt.subplot(grid_spec[1])
|
| 77 |
-
plt.imshow(FULL_COLOR_MAP[unique_labels].astype(np.uint8), interpolation="nearest")
|
| 78 |
-
ax.yaxis.tick_right()
|
| 79 |
-
plt.yticks(range(len(unique_labels)), LABEL_NAMES[unique_labels])
|
| 80 |
-
plt.xticks([], [])
|
| 81 |
-
ax.tick_params(width=0.0, labelsize=25)
|
| 82 |
-
|
| 83 |
-
# ๋ผ๋ฒจ ์ด๋ฆ ํ
์คํธ ์ถ๊ฐ
|
| 84 |
-
draw = ImageDraw.Draw(pred_img)
|
| 85 |
for label, color in enumerate(colormap):
|
| 86 |
mask = seg.numpy() == label
|
| 87 |
if np.any(mask):
|
|
@@ -89,7 +73,7 @@ def draw_plot_with_labels(pred_img, seg):
|
|
| 89 |
y = np.mean(y).astype(int)
|
| 90 |
x = np.mean(x).astype(int)
|
| 91 |
label_name = LABEL_NAMES[label]
|
| 92 |
-
|
| 93 |
|
| 94 |
return fig
|
| 95 |
|
|
|
|
| 59 |
|
| 60 |
|
| 61 |
def draw_plot_with_labels(pred_img, seg):
|
| 62 |
+
fig, ax = plt.subplots(1, 1, figsize=(20, 15))
|
| 63 |
+
ax.imshow(pred_img)
|
| 64 |
+
ax.axis('off')
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
# ๋ผ๋ฒจ ์ด๋ฆ์ ์ถ๊ฐํ๊ธฐ ์ํ ์ฝ๋
|
| 67 |
LABEL_NAMES = np.asarray(labels_list)
|
| 68 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
for label, color in enumerate(colormap):
|
| 70 |
mask = seg.numpy() == label
|
| 71 |
if np.any(mask):
|
|
|
|
| 73 |
y = np.mean(y).astype(int)
|
| 74 |
x = np.mean(x).astype(int)
|
| 75 |
label_name = LABEL_NAMES[label]
|
| 76 |
+
ax.text(x, y, label_name, fontsize=20, color=tuple(color))
|
| 77 |
|
| 78 |
return fig
|
| 79 |
|