elif all(isinstance(x, tuple) for x in colors):
for i in range(0, len(masks)):
mask = np.copy(masks[i])
mask = cv2.cvtColor(mask, cv2.COLOR_GRAY2BGR)
mask[masks[i] > 0] = colors[i]
colored_img = colored_img + mask
else:
fatal_error("All elements of the "colors" list must be the same type (all str or all tuples)")
After Change
for i in range(0, len(masks)):
mask = np.copy(masks[i])
mask = cv2.cvtColor(mask, cv2.COLOR_GRAY2BGR)
if isinstance(colors[i], tuple):
mask[masks[i] > 0] = colors[i]
elif isinstance(colors[i], str):
mask[masks[i] > 0] = color_dict[colors[i]]