Hantr commited on
Commit
6874750
ยท
1 Parent(s): 6d1120a
Files changed (1) hide show
  1. app.py +5 -21
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.figure(figsize=(20, 15))
63
-
64
- grid_spec = gridspec.GridSpec(1, 2, width_ratios=[6, 1])
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
- FULL_LABEL_MAP = np.arange(len(LABEL_NAMES)).reshape(len(LABEL_NAMES), 1)
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
- draw.text((x, y), label_name, fill=tuple(color), fontsize=20)
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