MCPcopy Create free account
hub / github.com/NVlabs/prismer / obj_detection_prettify

Function obj_detection_prettify

demo_vis.py:34–56  ·  view source on GitHub ↗
(file_name)

Source from the content-addressed store, hash-verified

32
33
34def obj_detection_prettify(file_name):
35 label_path = get_label_path(file_name, 'obj_detection')
36 save_path = get_label_path(file_name, 'obj_detection', True)
37
38 rgb = plt.imread(file_name)
39 obj_labels = plt.imread(label_path)
40 obj_labels_dict = json.load(open(label_path.replace('.png', '.json')))
41
42 plt.imshow(rgb)
43
44 num_objs = np.unique(obj_labels)[:-1].max()
45 plt.imshow(obj_labels, cmap='terrain', vmax=num_objs + 1 / 255., alpha=0.5)
46
47 for i in np.unique(obj_labels)[:-1]:
48 obj_idx_all = np.where(obj_labels == i)
49 obj_idx = random.randint(0, len(obj_idx_all[0]))
50 x, y = obj_idx_all[1][obj_idx], obj_idx_all[0][obj_idx]
51 obj_name = obj_label_map[obj_labels_dict[str(int(i * 255))]]
52 plt.text(x, y, obj_name, c='white', horizontalalignment='center', verticalalignment='center')
53
54 plt.axis('off')
55 plt.savefig(save_path, bbox_inches='tight', transparent=True, pad_inches=0)
56 plt.close()
57
58
59def seg_prettify(file_name):

Callers 1

demo_vis.pyFile · 0.85

Calls 2

get_label_pathFunction · 0.85
loadMethod · 0.80

Tested by

no test coverage detected