Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
maker.name(shape['label']),
maker.pose(),
maker.truncated(),
maker.difficult(),
maker.bndbox(
maker.xmin(str(xmin)),
maker.ymin(str(ymin)),
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))
def instances2rgb():
data = imgviz.data.voc()
captions = [data["class_names"][l] for l in data["labels"]]
insviz1 = imgviz.instances2rgb(
image=data["rgb"],
bboxes=data["bboxes"],
labels=data["labels"],
captions=captions,
)
insviz2 = imgviz.instances2rgb(
image=data["rgb"],
masks=data["masks"] == 1,
labels=data["labels"],
captions=captions,
)
# -------------------------------------------------------------------------
plt.figure(dpi=200)
data = imgviz.data.arc2017()
# colorize depth image with JET colormap
depth = data["depth"]
depthviz = imgviz.depth2rgb(depth, min_value=0.3, max_value=1)
# colorize label image
class_label = data["class_label"]
labelviz = imgviz.label2rgb(class_label, label_names=data["class_names"])
# instance bboxes
rgb = data["rgb"]
bboxes = data["bboxes"].astype(int)
labels = data["labels"]
captions = [data["class_names"][l] for l in labels]
bboxviz = imgviz.instances2rgb(image=rgb, bboxes=bboxes, labels=labels, captions=captions)
# instance masks
masks = data["masks"] == 1
maskviz = imgviz.instances2rgb(image=rgb, masks=masks, labels=labels, captions=captions)
# 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,
)
def instances2rgb():
data = imgviz.data.voc()
captions = [data["class_names"][l] for l in data["labels"]]
insviz1 = imgviz.instances2rgb(
image=data["rgb"],
bboxes=data["bboxes"],
labels=data["labels"],
captions=captions,
)
insviz2 = imgviz.instances2rgb(
image=data["rgb"],
masks=data["masks"] == 1,
labels=data["labels"],
captions=captions,
)
# -------------------------------------------------------------------------
plt.figure(dpi=200)
plt.subplot(131)
plt.title("rgb")
plt.imshow(data["rgb"])
plt.axis("off")
plt.subplot(132)
depthviz = imgviz.depth2rgb(depth, min_value=0.3, max_value=1)
# colorize label image
class_label = data["class_label"]
labelviz = imgviz.label2rgb(class_label, label_names=data["class_names"])
# instance bboxes
rgb = data["rgb"]
bboxes = data["bboxes"].astype(int)
labels = data["labels"]
captions = [data["class_names"][l] for l in labels]
bboxviz = imgviz.instances2rgb(image=rgb, bboxes=bboxes, labels=labels, captions=captions)
# instance masks
masks = data["masks"] == 1
maskviz = imgviz.instances2rgb(image=rgb, masks=masks, labels=labels, captions=captions)
# 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")