def make_cmap(N_CLASSES):
# Generate the colors for the classes (with background class being 0,0,0)
c_size = 2**N_CLASSES - 1
cmap = np.concatenate([[[0, 0, 0]], plt.cm.Set1(np.arange(c_size) / (c_size))[:, :3]])
cmap = (cmap * 255).astype(np.uint8)
assert N_CLASSES <= 8, "ARGH!! can not handle more than 8 classes"
c_full_label = np.unpackbits(np.arange(2 ** N_CLASSES).astype(np.uint8)[:, None], axis=-1)[:, -N_CLASSES:]
return cmap, c_full_label
layout_generate_dataset.py 文件源码
python
阅读 30
收藏 0
点赞 0
评论 0
评论列表
文章目录