提交 3930b90d 编写于 作者: K Kentaro Wada

Use npy in labelme2voc.py for -1 value in labels

PNG does not keep negative values.
上级 b3021823
......@@ -61,11 +61,11 @@ def main():
out_img_file = osp.join(
args.out_dir, 'JPEGImages', base + '.jpg')
out_cls_file = osp.join(
args.out_dir, 'SegmentationClass', base + '.png')
args.out_dir, 'SegmentationClass', base + '.npy')
out_clsv_file = osp.join(
args.out_dir, 'SegmentationClassVisualization', base + '.jpg')
out_ins_file = osp.join(
args.out_dir, 'SegmentationObject', base + '.png')
args.out_dir, 'SegmentationObject', base + '.npy')
out_insv_file = osp.join(
args.out_dir, 'SegmentationObjectVisualization', base + '.jpg')
......@@ -81,15 +81,16 @@ def main():
label_name_to_value=class_name_to_id,
type='instance',
)
ins[cls == -1] = 0 # ignore it.
PIL.Image.fromarray(cls).save(out_cls_file)
np.save(out_cls_file, cls)
label_names = ['%d: %s' % (cls_id, cls_name)
for cls_id, cls_name in enumerate(class_names)]
clsv = labelme.utils.draw_label(
cls, img, label_names, colormap=colormap)
PIL.Image.fromarray(clsv).save(out_clsv_file)
PIL.Image.fromarray(ins).save(out_ins_file)
np.save(out_ins_file, ins)
instance_ids = np.unique(ins)
instance_names = [str(i) for i in range(max(instance_ids) + 1)]
insv = labelme.utils.draw_label(
......
......@@ -59,7 +59,7 @@ def main():
out_img_file = osp.join(
args.out_dir, 'JPEGImages', base + '.jpg')
out_lbl_file = osp.join(
args.out_dir, 'SegmentationClass', base + '.png')
args.out_dir, 'SegmentationClass', base + '.npy')
out_viz_file = osp.join(
args.out_dir, 'SegmentationClassVisualization', base + '.jpg')
......@@ -75,11 +75,10 @@ def main():
label_name_to_value=class_name_to_id,
)
lbl_pil = PIL.Image.fromarray(lbl)
# Only works with uint8 label
# lbl_pil = PIL.Image.fromarray(lbl, mode='P')
# lbl_pil.putpalette((colormap * 255).flatten())
lbl_pil.save(out_lbl_file)
np.save(out_lbl_file, lbl)
label_names = ['%d: %s' % (cls_id, cls_name)
for cls_id, cls_name in enumerate(class_names)]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册