参考mmdetection代码
地址:https://github.com/open-mmlab/mmdetection/blob/master/mmdet/core/visualization/image.py:
state = np.random.get_state()
# random color
np.random.seed(42)
mask_colors = [
np.random.randint(0, 256, (1, 3), dtype=np.uint8)[0].tolist()
for _ in range(len(categories))
]
np.random.set_state(state)