Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
shapes=data['shapes'],
label_name_to_value=class_name_to_id,
)
labelme.utils.lblsave(out_png_file, lbl)
np.save(out_lbl_file, lbl)
if not args.noviz:
viz = imgviz.label2rgb(
label=lbl,
img=imgviz.rgb2gray(img),
font_size=15,
label_names=class_names,
loc='rb',
)
imgviz.io.imsave(out_viz_file, viz)
maker.xmax(str(xmax)),
maker.ymax(str(ymax)),
),
)
)
if not args.noviz:
captions = [class_names[l] for l in labels]
viz = imgviz.instances2rgb(
image=img,
labels=labels,
bboxes=bboxes,
captions=captions,
font_size=15,
)
imgviz.io.imsave(out_viz_file, viz)
with open(out_xml_file, 'wb') as f:
f.write(lxml.etree.tostring(xml, pretty_print=True))
type='instance',
)
ins[cls == -1] = 0 # ignore it.
# class label
labelme.utils.lblsave(out_clsp_file, cls)
np.save(out_cls_file, cls)
if not args.noviz:
clsv = imgviz.label2rgb(
label=cls,
img=imgviz.rgb2gray(img),
label_names=class_names,
font_size=15,
loc='rb',
)
imgviz.io.imsave(out_clsv_file, clsv)
# instance label
labelme.utils.lblsave(out_insp_file, ins)
np.save(out_ins_file, ins)
if not args.noviz:
instance_ids = np.unique(ins)
instance_names = [str(i) for i in range(max(instance_ids) + 1)]
insv = imgviz.label2rgb(
label=ins,
img=imgviz.rgb2gray(img),
label_names=instance_names,
font_size=15,
loc='rb',
)
imgviz.io.imsave(out_insv_file, insv)
imgviz.io.imsave(out_clsv_file, clsv)
# instance label
labelme.utils.lblsave(out_insp_file, ins)
np.save(out_ins_file, ins)
if not args.noviz:
instance_ids = np.unique(ins)
instance_names = [str(i) for i in range(max(instance_ids) + 1)]
insv = imgviz.label2rgb(
label=ins,
img=imgviz.rgb2gray(img),
label_names=instance_names,
font_size=15,
loc='rb',
)
imgviz.io.imsave(out_insv_file, insv)
def run_example(function):
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
parser.add_argument("--save", action="store_true", help="save image")
args = parser.parse_args()
img = function()
if args.save:
out_file = osp.join(here, ".readme/{}.jpg".format(function.__name__))
imgviz.io.imsave(out_file, img)
plt.imshow(img)
plt.axis("off")
plt.show()
# tile instance masks
insviz = [(rgb * m[:, :, None])[b[0] : b[2], b[1] : b[3]] for b, m in zip(bboxes, masks)]
insviz = imgviz.tile(imgs=insviz, border=(255, 255, 255))
# tile visualization
tiled = imgviz.tile(
[rgb, depthviz, labelviz, bboxviz, maskviz, insviz],
shape=(1, 6),
border=(255, 255, 255),
border_width=5,
)
# }} GETTING_STARTED
# -----------------------------------------------------------------------------
out_file = osp.join(here, ".readme/getting_started.jpg")
imgviz.io.imsave(out_file, tiled)
img = imgviz.io.imread(out_file)
plt.imshow(img)
plt.axis("off")
plt.show()