// Returns newly instantiated matplotlib.axes.Axes object if ax is None
ax = vis_image(img, ax=ax)
canvas_img = np.zeros((mask.shape[1], mask.shape[2], 4), dtype=np.uint8)
for i, (color, bb, msk) in enumerate(zip(colors, bbox, mask)):
rgba = np.append(color, alpha * 255)
bb = np.round(bb).astype(np.int32)
After Change
n_inst = len(bbox)
colors = np.array([_default_cmap(l) for l in range(1, n_inst + 1)])
canvas_img = img.transpose((1, 2, 0)).copy()
for i, (color, bb, msk) in enumerate(zip(colors, bbox, mask)):
bb = np.round(bb).astype(np.int32)
y_min, x_min, y_max, x_max = bb
if y_max > y_min and x_max > x_min:
canvas_img[msk] = alpha * color + canvas_img[msk] * (1 - alpha)
caption = []
if label is not None and label_names is not None:
lb = label[i]