def test_show(): import mmcv import tempfile from os import path as osp from mmdet3d.core.bbox import LiDARInstance3DBoxes temp_dir = tempfile.mkdtemp() data_root, ann_file, classes, pts_prefix,\ pipeline, modality, split = _generate_kitti_dataset_config() kitti_dataset = KittiDataset(data_root, ann_file, split=split, modality=modality, pipeline=pipeline) boxes_3d = LiDARInstance3DBoxes( torch.tensor( [[46.1218, -4.6496, -0.9275, 0.5316, 1.4442, 1.7450, 1.1749], [33.3189, 0.1981, 0.3136, 0.5656, 1.2301, 1.7985, 1.5723], [46.1366, -4.6404, -0.9510, 0.5162, 1.6501, 1.7540, 1.3778], [33.2646, 0.2297, 0.3446, 0.5746, 1.3365, 1.7947, 1.5430], [58.9079, 16.6272, -1.5829, 1.5656, 3.9313, 1.4899, 1.5505]])) scores_3d = torch.tensor([0.1815, 0.1663, 0.5792, 0.2194, 0.2780]) labels_3d = torch.tensor([0, 0, 1, 1, 2]) result = dict(boxes_3d=boxes_3d, scores_3d=scores_3d, labels_3d=labels_3d) results = [result] kitti_dataset.show(results, temp_dir) pts_file_path = osp.join(temp_dir, '000000', '000000_points.obj') gt_file_path = osp.join(temp_dir, '000000', '000000_gt.ply') pred_file_path = osp.join(temp_dir, '000000', '000000_pred.ply') mmcv.check_file_exist(pts_file_path) mmcv.check_file_exist(gt_file_path) mmcv.check_file_exist(pred_file_path)
def test_show(): import mmcv import tempfile from os import path as osp from mmdet3d.core.bbox import LiDARInstance3DBoxes temp_dir = tempfile.mkdtemp() data_root = 'tests/data/kitti' ann_file = 'tests/data/kitti/kitti_infos_train.pkl' modality = {'use_lidar': True, 'use_camera': False} split = 'training' file_client_args = dict(backend='disk') point_cloud_range = [0, -40, -3, 70.4, 40, 1] class_names = ['Pedestrian', 'Cyclist', 'Car'] pipeline = [ dict(type='LoadPointsFromFile', load_dim=4, use_dim=4, file_client_args=file_client_args), dict(type='MultiScaleFlipAug3D', img_scale=(1333, 800), pts_scale_ratio=1, flip=False, transforms=[ dict(type='GlobalRotScaleTrans', rot_range=[0, 0], scale_ratio_range=[1., 1.], translation_std=[0, 0, 0]), dict(type='RandomFlip3D'), dict(type='PointsRangeFilter', point_cloud_range=point_cloud_range), dict(type='DefaultFormatBundle3D', class_names=class_names, with_label=False), dict(type='Collect3D', keys=['points']) ]) ] kitti_dataset = KittiDataset(data_root, ann_file, split=split, modality=modality, pipeline=pipeline) boxes_3d = LiDARInstance3DBoxes( torch.tensor( [[46.1218, -4.6496, -0.9275, 0.5316, 1.4442, 1.7450, 1.1749], [33.3189, 0.1981, 0.3136, 0.5656, 1.2301, 1.7985, 1.5723], [46.1366, -4.6404, -0.9510, 0.5162, 1.6501, 1.7540, 1.3778], [33.2646, 0.2297, 0.3446, 0.5746, 1.3365, 1.7947, 1.5430], [58.9079, 16.6272, -1.5829, 1.5656, 3.9313, 1.4899, 1.5505]])) scores_3d = torch.tensor([0.1815, 0.1663, 0.5792, 0.2194, 0.2780]) labels_3d = torch.tensor([0, 0, 1, 1, 2]) result = dict(boxes_3d=boxes_3d, scores_3d=scores_3d, labels_3d=labels_3d) results = [result] kitti_dataset.show(results, temp_dir) pts_file_path = osp.join(temp_dir, '000000', '000000_points.obj') gt_file_path = osp.join(temp_dir, '000000', '000000_gt.ply') pred_file_path = osp.join(temp_dir, '000000', '000000_pred.ply') mmcv.check_file_exist(pts_file_path) mmcv.check_file_exist(gt_file_path) mmcv.check_file_exist(pred_file_path)
def test_show(): import mmcv from os import path as osp from mmdet3d.core.bbox import LiDARInstance3DBoxes tmp_dir = tempfile.TemporaryDirectory() temp_dir = tmp_dir.name data_root, ann_file, classes, pts_prefix, \ pipeline, modality, split = _generate_kitti_dataset_config() kitti_dataset = KittiDataset(data_root, ann_file, split=split, modality=modality, pipeline=pipeline) boxes_3d = LiDARInstance3DBoxes( torch.tensor( [[46.1218, -4.6496, -0.9275, 0.5316, 1.4442, 1.7450, 1.1749], [33.3189, 0.1981, 0.3136, 0.5656, 1.2301, 1.7985, 1.5723], [46.1366, -4.6404, -0.9510, 0.5162, 1.6501, 1.7540, 1.3778], [33.2646, 0.2297, 0.3446, 0.5746, 1.3365, 1.7947, 1.5430], [58.9079, 16.6272, -1.5829, 1.5656, 3.9313, 1.4899, 1.5505]])) scores_3d = torch.tensor([0.1815, 0.1663, 0.5792, 0.2194, 0.2780]) labels_3d = torch.tensor([0, 0, 1, 1, 2]) result = dict(boxes_3d=boxes_3d, scores_3d=scores_3d, labels_3d=labels_3d) results = [result] kitti_dataset.show(results, temp_dir, show=False) pts_file_path = osp.join(temp_dir, '000000', '000000_points.obj') gt_file_path = osp.join(temp_dir, '000000', '000000_gt.obj') pred_file_path = osp.join(temp_dir, '000000', '000000_pred.obj') mmcv.check_file_exist(pts_file_path) mmcv.check_file_exist(gt_file_path) mmcv.check_file_exist(pred_file_path) tmp_dir.cleanup() # test show with pipeline eval_pipeline = [ dict(type='LoadPointsFromFile', coord_type='LIDAR', load_dim=4, use_dim=4), dict(type='DefaultFormatBundle3D', class_names=classes, with_label=False), dict(type='Collect3D', keys=['points']) ] tmp_dir = tempfile.TemporaryDirectory() temp_dir = tmp_dir.name kitti_dataset.show(results, temp_dir, show=False, pipeline=eval_pipeline) pts_file_path = osp.join(temp_dir, '000000', '000000_points.obj') gt_file_path = osp.join(temp_dir, '000000', '000000_gt.obj') pred_file_path = osp.join(temp_dir, '000000', '000000_pred.obj') mmcv.check_file_exist(pts_file_path) mmcv.check_file_exist(gt_file_path) mmcv.check_file_exist(pred_file_path) tmp_dir.cleanup() # test multi-modality show tmp_dir = tempfile.TemporaryDirectory() temp_dir = tmp_dir.name _, _, _, _, multi_modality_pipeline, modality, _ = \ _generate_kitti_multi_modality_dataset_config() kitti_dataset = KittiDataset(data_root, ann_file, split, pts_prefix, multi_modality_pipeline, classes, modality) kitti_dataset.show(results, temp_dir, show=False) pts_file_path = osp.join(temp_dir, '000000', '000000_points.obj') gt_file_path = osp.join(temp_dir, '000000', '000000_gt.obj') pred_file_path = osp.join(temp_dir, '000000', '000000_pred.obj') img_file_path = osp.join(temp_dir, '000000', '000000_img.png') img_pred_path = osp.join(temp_dir, '000000', '000000_pred.png') img_gt_file = osp.join(temp_dir, '000000', '000000_gt.png') mmcv.check_file_exist(pts_file_path) mmcv.check_file_exist(gt_file_path) mmcv.check_file_exist(pred_file_path) mmcv.check_file_exist(img_file_path) mmcv.check_file_exist(img_pred_path) mmcv.check_file_exist(img_gt_file) tmp_dir.cleanup() # test multi-modality show with pipeline eval_pipeline = [ dict(type='LoadPointsFromFile', coord_type='LIDAR', load_dim=4, use_dim=4), dict(type='LoadImageFromFile'), dict(type='DefaultFormatBundle3D', class_names=classes, with_label=False), dict(type='Collect3D', keys=['points', 'img']) ] tmp_dir = tempfile.TemporaryDirectory() temp_dir = tmp_dir.name kitti_dataset.show(results, temp_dir, show=False, pipeline=eval_pipeline) pts_file_path = osp.join(temp_dir, '000000', '000000_points.obj') gt_file_path = osp.join(temp_dir, '000000', '000000_gt.obj') pred_file_path = osp.join(temp_dir, '000000', '000000_pred.obj') img_file_path = osp.join(temp_dir, '000000', '000000_img.png') img_pred_path = osp.join(temp_dir, '000000', '000000_pred.png') img_gt_file = osp.join(temp_dir, '000000', '000000_gt.png') mmcv.check_file_exist(pts_file_path) mmcv.check_file_exist(gt_file_path) mmcv.check_file_exist(pred_file_path) mmcv.check_file_exist(img_file_path) mmcv.check_file_exist(img_pred_path) mmcv.check_file_exist(img_gt_file) tmp_dir.cleanup()