本文整理汇总了Python中visualize.display_instances方法的典型用法代码示例。如果您正苦于以下问题:Python visualize.display_instances方法的具体用法?Python visualize.display_instances怎么用?Python visualize.display_instances使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类visualize
的用法示例。
在下文中一共展示了visualize.display_instances方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: visualize_instance_segmentation
# 需要导入模块: import visualize [as 别名]
# 或者: from visualize import display_instances [as 别名]
def visualize_instance_segmentation(data_base_dir, dataset_type, image_id, save_path='', verbose=True):
split_dataset = SketchDataset(data_base_dir)
split_dataset.load_sketches(dataset_type)
split_dataset.prepare()
original_image = split_dataset.load_image(image_id - 1)
gt_mask, gt_class_id = split_dataset.load_mask(image_id - 1)
gt_bbox = utils.extract_bboxes(gt_mask)
if verbose:
log('original_image', original_image)
log('gt_class_id', gt_class_id)
log('gt_bbox', gt_bbox)
log('gt_mask', gt_mask)
visualize.display_instances(original_image, gt_bbox, gt_mask, gt_class_id,
split_dataset.class_names, save_path=save_path)
示例2: debug_saved_npz
# 需要导入模块: import visualize [as 别名]
# 或者: from visualize import display_instances [as 别名]
def debug_saved_npz(dataset_type, img_idx, data_base_dir):
outputs_base_dir = 'outputs'
seg_data_save_base_dir = os.path.join(outputs_base_dir, 'inst_segm_output_data', dataset_type)
npz_name = os.path.join(seg_data_save_base_dir, str(img_idx) + '_datas.npz')
npz = np.load(npz_name)
pred_class_ids = np.array(npz['pred_class_ids'], dtype=np.int32)
pred_boxes = np.array(npz['pred_boxes'], dtype=np.int32)
pred_masks_s = npz['pred_masks']
pred_masks = expand_small_segmentation_mask(pred_masks_s, pred_boxes) # [N, H, W]
pred_masks = np.transpose(pred_masks, (1, 2, 0))
print(pred_class_ids.shape)
print(pred_masks.shape)
print(pred_boxes.shape)
image_name = 'L0_sample' + str(img_idx) + '.png'
images_base_dir = os.path.join(data_base_dir, dataset_type, 'DRAWING_GT')
image_path = os.path.join(images_base_dir, image_name)
original_image = Image.open(image_path).convert("RGB")
original_image = original_image.resize((768, 768), resample=Image.NEAREST)
original_image = np.array(original_image, dtype=np.float32) # shape = [H, W, 3]
dataset_class_names = ['bg']
color_map_mat_path = os.path.join(data_base_dir, 'colorMapC46.mat')
colorMap = scipy.io.loadmat(color_map_mat_path)['colorMap']
for i in range(46):
cat_name = colorMap[i][0][0]
dataset_class_names.append(cat_name)
visualize.display_instances(original_image, pred_boxes, pred_masks, pred_class_ids,
dataset_class_names, figsize=(8, 8))