update colorize mask

#1
by johnnv - opened
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -13,9 +13,10 @@ def visualize_instance_seg_mask(mask):
13
  image = np.zeros((mask.shape[0], mask.shape[1], 3))
14
  labels = np.unique(mask)
15
  label2color = {label: (random.randint(0, 1), random.randint(0, 255), random.randint(0, 255)) for label in labels}
16
- for i in range(image.shape[0]):
17
- for j in range(image.shape[1]):
18
- image[i, j, :] = label2color[mask[i, j]]
 
19
  image = image / 255
20
  return image
21
 
 
13
  image = np.zeros((mask.shape[0], mask.shape[1], 3))
14
  labels = np.unique(mask)
15
  label2color = {label: (random.randint(0, 1), random.randint(0, 255), random.randint(0, 255)) for label in labels}
16
+
17
+ for id in labels:
18
+ image[mask == id] = label2color[id]
19
+
20
  image = image / 255
21
  return image
22