本文整理匯總了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))