(file_name)
| 32 | |
| 33 | |
| 34 | def 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 | |
| 59 | def seg_prettify(file_name): |
no test coverage detected