Python visualize.display_instances() Examples
The following are 2
code examples of visualize.display_instances().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
visualize
, or try the search function
.
Example #1
Source File: instance_visualize.py From SketchyScene with MIT License | 6 votes |
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)
Example #2
Source File: segment_data_generation.py From SketchyScene with MIT License | 5 votes |
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))