def test_evaluate(): if not torch.cuda.is_available(): pytest.skip() from mmdet3d.core.bbox.structures import DepthInstance3DBoxes root_path = './tests/data/sunrgbd' ann_file = './tests/data/sunrgbd/sunrgbd_infos.pkl' sunrgbd_dataset = SUNRGBDDataset(root_path, ann_file) results = [] pred_boxes = dict() pred_boxes['boxes_3d'] = DepthInstance3DBoxes( torch.tensor( [[1.0473, 4.1687, -1.2317, 2.3021, 1.8876, 1.9696, 1.6956], [2.5831, 4.8117, -1.2733, 0.5852, 0.8832, 0.9733, 1.6500], [-1.0864, 1.9045, -1.2000, 0.7128, 1.5631, 2.1045, 0.1022]])) pred_boxes['labels_3d'] = torch.tensor([0, 7, 6]) pred_boxes['scores_3d'] = torch.tensor([0.5, 1.0, 1.0]) results.append(pred_boxes) metric = [0.25, 0.5] ap_dict = sunrgbd_dataset.evaluate(results, metric) bed_precision_25 = ap_dict['bed_AP_0.25'] dresser_precision_25 = ap_dict['dresser_AP_0.25'] night_stand_precision_25 = ap_dict['night_stand_AP_0.25'] assert abs(bed_precision_25 - 1) < 0.01 assert abs(dresser_precision_25 - 1) < 0.01 assert abs(night_stand_precision_25 - 1) < 0.01
def test_show(): import mmcv import tempfile from os import path as osp from mmdet3d.core.bbox import DepthInstance3DBoxes temp_dir = tempfile.mkdtemp() root_path = './tests/data/sunrgbd' ann_file = './tests/data/sunrgbd/sunrgbd_infos.pkl' sunrgbd_dataset = SUNRGBDDataset(root_path, ann_file) boxes_3d = DepthInstance3DBoxes( torch.tensor( [[1.1500, 4.2614, -1.0669, 1.3219, 2.1593, 1.0267, 1.6473], [-0.9583, 2.1916, -1.0881, 0.6213, 1.3022, 1.6275, -3.0720], [2.5697, 4.8152, -1.1157, 0.5421, 0.7019, 0.7896, 1.6712], [0.7283, 2.5448, -1.0356, 0.7691, 0.9056, 0.5771, 1.7121], [-0.9860, 3.2413, -1.2349, 0.5110, 0.9940, 1.1245, 0.3295]])) scores_3d = torch.tensor( [1.5280e-01, 1.6682e-03, 6.2811e-04, 1.2860e-03, 9.4229e-06]) labels_3d = torch.tensor([0, 0, 0, 0, 0]) result = dict(boxes_3d=boxes_3d, scores_3d=scores_3d, labels_3d=labels_3d) results = [result] sunrgbd_dataset.show(results, temp_dir, show=False) pts_file_path = osp.join(temp_dir, '000001', '000001_points.obj') gt_file_path = osp.join(temp_dir, '000001', '000001_gt.ply') pred_file_path = osp.join(temp_dir, '000001', '000001_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_indoor_eval_less_classes(): if not torch.cuda.is_available(): pytest.skip() from mmdet3d.core.bbox.structures import Box3DMode, DepthInstance3DBoxes det_infos = [{ 'labels_3d': torch.tensor([0]), 'boxes_3d': DepthInstance3DBoxes(torch.tensor([[1., 1., 1., 1., 1., 1., 1.]])), 'scores_3d': torch.tensor([.5]) }, { 'labels_3d': torch.tensor([1]), 'boxes_3d': DepthInstance3DBoxes(torch.tensor([[1., 1., 1., 1., 1., 1., 1.]])), 'scores_3d': torch.tensor([.5]) }] label2cat = {0: 'cabinet', 1: 'bed', 2: 'chair'} gt_annos = [{ 'gt_num': 2, 'gt_boxes_upright_depth': np.array([[0., 0., 0., 1., 1., 1., 1.], [1., 1., 1., 1., 1., 1., 1.]]), 'class': np.array([2, 0]) }, { 'gt_num': 1, 'gt_boxes_upright_depth': np.array([ [1., 1., 1., 1., 1., 1., 1.], ]), 'class': np.array([1]) }] ret_value = indoor_eval(gt_annos, det_infos, [0.25, 0.5], label2cat, box_type_3d=DepthInstance3DBoxes, box_mode_3d=Box3DMode.DEPTH) assert np.isclose(ret_value['mAP_0.25'], 0.666667) assert np.isclose(ret_value['mAR_0.25'], 0.666667)
def test_show(): import mmcv import tempfile from os import path as osp from mmdet3d.core.bbox import DepthInstance3DBoxes tmp_dir = tempfile.TemporaryDirectory() temp_dir = tmp_dir.name root_path, ann_file, _, pipelines, modality = \ _generate_sunrgbd_dataset_config() sunrgbd_dataset = SUNRGBDDataset(root_path, ann_file, pipelines, modality=modality) boxes_3d = DepthInstance3DBoxes( torch.tensor( [[1.1500, 4.2614, -1.0669, 1.3219, 2.1593, 1.0267, 1.6473], [-0.9583, 2.1916, -1.0881, 0.6213, 1.3022, 1.6275, -3.0720], [2.5697, 4.8152, -1.1157, 0.5421, 0.7019, 0.7896, 1.6712], [0.7283, 2.5448, -1.0356, 0.7691, 0.9056, 0.5771, 1.7121], [-0.9860, 3.2413, -1.2349, 0.5110, 0.9940, 1.1245, 0.3295]])) scores_3d = torch.tensor( [1.5280e-01, 1.6682e-03, 6.2811e-04, 1.2860e-03, 9.4229e-06]) labels_3d = torch.tensor([0, 0, 0, 0, 0]) result = dict(boxes_3d=boxes_3d, scores_3d=scores_3d, labels_3d=labels_3d) results = [result] sunrgbd_dataset.show(results, temp_dir, show=False) pts_file_path = osp.join(temp_dir, '000001', '000001_points.obj') gt_file_path = osp.join(temp_dir, '000001', '000001_gt.obj') pred_file_path = osp.join(temp_dir, '000001', '000001_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 root_path, ann_file, _, multi_modality_pipelines, modality = \ _generate_sunrgbd_multi_modality_dataset_config() sunrgbd_dataset = SUNRGBDDataset(root_path, ann_file, multi_modality_pipelines, modality=modality) sunrgbd_dataset.show(results, temp_dir, show=False) pts_file_path = osp.join(temp_dir, '000001', '000001_points.obj') gt_file_path = osp.join(temp_dir, '000001', '000001_gt.obj') pred_file_path = osp.join(temp_dir, '000001', '000001_pred.obj') img_file_path = osp.join(temp_dir, '000001', '000001_img.png') img_pred_path = osp.join(temp_dir, '000001', '000001_pred.png') img_gt_file = osp.join(temp_dir, '000001', '000001_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()
def test_evaluate(): if not torch.cuda.is_available(): pytest.skip() from mmdet3d.core.bbox.structures import DepthInstance3DBoxes root_path = './tests/data/scannet' ann_file = './tests/data/scannet/scannet_infos.pkl' scannet_dataset = ScanNetDataset(root_path, ann_file) results = [] pred_boxes = dict() pred_boxes['boxes_3d'] = DepthInstance3DBoxes( torch.tensor([[ 1.4813e+00, 3.5207e+00, 1.5704e+00, 1.7445e+00, 2.3196e-01, 5.7235e-01, 0.0000e+00 ], [ 2.9040e+00, -3.4803e+00, 1.1911e+00, 6.6078e-01, 1.7072e-01, 6.7154e-01, 0.0000e+00 ], [ 1.1466e+00, 2.1987e+00, 9.2576e-03, 5.4184e-01, 2.5346e+00, 1.2145e+00, 0.0000e+00 ], [ 2.9168e+00, 2.5016e+00, 8.2875e-01, 6.1697e-01, 1.8428e+00, 2.8697e-01, 0.0000e+00 ], [ -3.3114e+00, -1.3351e-02, -8.9524e-03, 4.4082e-01, 3.8582e+00, 2.1603e+00, 0.0000e+00 ], [ -2.0135e+00, -3.4857e+00, 9.3848e-01, 1.9911e+00, 2.1603e-01, 1.2767e+00, 0.0000e+00 ], [ -2.1945e+00, -3.1402e+00, -3.8165e-02, 1.4801e+00, 6.8676e-01, 1.0586e+00, 0.0000e+00 ], [ -2.7553e+00, 2.4055e+00, -2.9972e-02, 1.4764e+00, 1.4927e+00, 2.3380e+00, 0.0000e+00 ]])) pred_boxes['labels_3d'] = torch.tensor([6, 6, 4, 9, 11, 11]) pred_boxes['scores_3d'] = torch.tensor([0.5, 1.0, 1.0, 1.0, 1.0, 0.5]) results.append(pred_boxes) metric = [0.25, 0.5] ret_dict = scannet_dataset.evaluate(results, metric) assert abs(ret_dict['table_AP_0.25'] - 0.3333) < 0.01 assert abs(ret_dict['window_AP_0.25'] - 1.0) < 0.01 assert abs(ret_dict['counter_AP_0.25'] - 1.0) < 0.01 assert abs(ret_dict['curtain_AP_0.25'] - 1.0) < 0.01
def test_show(): import mmcv import tempfile from os import path as osp from mmdet3d.core.bbox import DepthInstance3DBoxes tmp_dir = tempfile.TemporaryDirectory() temp_dir = tmp_dir.name root_path = './tests/data/scannet' ann_file = './tests/data/scannet/scannet_infos.pkl' scannet_dataset = ScanNetDataset(root_path, ann_file) boxes_3d = DepthInstance3DBoxes( torch.tensor([[ -2.4053e+00, 9.2295e-01, 8.0661e-02, 2.4054e+00, 2.1468e+00, 8.5990e-01, 0.0000e+00 ], [ -1.9341e+00, -2.0741e+00, 3.0698e-03, 3.2206e-01, 2.5322e-01, 3.5144e-01, 0.0000e+00 ], [ -3.6908e+00, 8.0684e-03, 2.6201e-01, 4.1515e-01, 7.6489e-01, 5.3585e-01, 0.0000e+00 ], [ 2.6332e+00, 8.5143e-01, -4.9964e-03, 3.0367e-01, 1.3448e+00, 1.8329e+00, 0.0000e+00 ], [ 2.0221e-02, 2.6153e+00, 1.5109e-02, 7.3335e-01, 1.0429e+00, 1.0251e+00, 0.0000e+00 ]])) scores_3d = torch.tensor( [1.2058e-04, 2.3012e-03, 6.2324e-06, 6.6139e-06, 6.7965e-05]) labels_3d = torch.tensor([0, 0, 0, 0, 0]) result = dict(boxes_3d=boxes_3d, scores_3d=scores_3d, labels_3d=labels_3d) results = [result] scannet_dataset.show(results, temp_dir, show=False) pts_file_path = osp.join(temp_dir, 'scene0000_00', 'scene0000_00_points.obj') gt_file_path = osp.join(temp_dir, 'scene0000_00', 'scene0000_00_gt.obj') pred_file_path = osp.join(temp_dir, 'scene0000_00', 'scene0000_00_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()
def test_evaluate(): if not torch.cuda.is_available(): pytest.skip() from mmdet3d.core.bbox.structures import DepthInstance3DBoxes root_path = './tests/data/s3dis' ann_file = './tests/data/s3dis/s3dis_infos.pkl' s3dis_dataset = S3DISDataset(root_path, ann_file) results = [] pred_boxes = dict() pred_boxes['boxes_3d'] = DepthInstance3DBoxes( torch.tensor([[2.3080, 2.4175, 0.2010, 0.8820, 0.8690, 0.6970, 0.0000], [2.4730, 0.7090, 0.2010, 0.9080, 0.9620, 0.7030, 0.0000], [5.3235, 0.4910, 0.0740, 0.8410, 0.9020, 0.8790, 0.0000]])) pred_boxes['labels_3d'] = torch.tensor([1, 1, 3]) pred_boxes['scores_3d'] = torch.tensor([0.5, 1.0, 1.0]) results.append(pred_boxes) ret_dict = s3dis_dataset.evaluate(results) assert abs(ret_dict['chair_AP_0.25'] - 0.666) < 0.01 assert abs(ret_dict['chair_AP_0.50'] - 0.666) < 0.01 assert abs(ret_dict['bookcase_AP_0.25'] - 0.5) < 0.01 assert abs(ret_dict['bookcase_AP_0.50'] - 0.5) < 0.01
def test_show(): import mmcv import tempfile from os import path as osp from mmdet3d.core.bbox import DepthInstance3DBoxes tmp_dir = tempfile.TemporaryDirectory() temp_dir = tmp_dir.name root_path, ann_file, class_names, pipelines, modality = \ _generate_sunrgbd_dataset_config() sunrgbd_dataset = SUNRGBDDataset(root_path, ann_file, pipelines, modality=modality) boxes_3d = DepthInstance3DBoxes( torch.tensor( [[1.1500, 4.2614, -1.0669, 1.3219, 2.1593, 1.0267, 1.6473], [-0.9583, 2.1916, -1.0881, 0.6213, 1.3022, 1.6275, -3.0720], [2.5697, 4.8152, -1.1157, 0.5421, 0.7019, 0.7896, 1.6712], [0.7283, 2.5448, -1.0356, 0.7691, 0.9056, 0.5771, 1.7121], [-0.9860, 3.2413, -1.2349, 0.5110, 0.9940, 1.1245, 0.3295]])) scores_3d = torch.tensor( [1.5280e-01, 1.6682e-03, 6.2811e-04, 1.2860e-03, 9.4229e-06]) labels_3d = torch.tensor([0, 0, 0, 0, 0]) result = dict(boxes_3d=boxes_3d, scores_3d=scores_3d, labels_3d=labels_3d) results = [result] sunrgbd_dataset.show(results, temp_dir, show=False) pts_file_path = osp.join(temp_dir, '000001', '000001_points.obj') gt_file_path = osp.join(temp_dir, '000001', '000001_gt.obj') pred_file_path = osp.join(temp_dir, '000001', '000001_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='DEPTH', shift_height=True, load_dim=6, use_dim=[0, 1, 2]), dict(type='DefaultFormatBundle3D', class_names=class_names, with_label=False), dict(type='Collect3D', keys=['points']) ] tmp_dir = tempfile.TemporaryDirectory() temp_dir = tmp_dir.name sunrgbd_dataset.show(results, temp_dir, show=False, pipeline=eval_pipeline) pts_file_path = osp.join(temp_dir, '000001', '000001_points.obj') gt_file_path = osp.join(temp_dir, '000001', '000001_gt.obj') pred_file_path = osp.join(temp_dir, '000001', '000001_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 root_path, ann_file, class_names, multi_modality_pipelines, modality = \ _generate_sunrgbd_multi_modality_dataset_config() sunrgbd_dataset = SUNRGBDDataset(root_path, ann_file, multi_modality_pipelines, modality=modality) sunrgbd_dataset.show(results, temp_dir, False, multi_modality_pipelines) pts_file_path = osp.join(temp_dir, '000001', '000001_points.obj') gt_file_path = osp.join(temp_dir, '000001', '000001_gt.obj') pred_file_path = osp.join(temp_dir, '000001', '000001_pred.obj') img_file_path = osp.join(temp_dir, '000001', '000001_img.png') img_pred_path = osp.join(temp_dir, '000001', '000001_pred.png') img_gt_file = osp.join(temp_dir, '000001', '000001_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='LoadImageFromFile'), dict(type='LoadPointsFromFile', coord_type='DEPTH', shift_height=True, load_dim=6, use_dim=[0, 1, 2]), dict(type='DefaultFormatBundle3D', class_names=class_names, with_label=False), dict(type='Collect3D', keys=['points', 'img']) ] tmp_dir = tempfile.TemporaryDirectory() temp_dir = tmp_dir.name sunrgbd_dataset.show(results, temp_dir, show=False, pipeline=eval_pipeline) pts_file_path = osp.join(temp_dir, '000001', '000001_points.obj') gt_file_path = osp.join(temp_dir, '000001', '000001_gt.obj') pred_file_path = osp.join(temp_dir, '000001', '000001_pred.obj') img_file_path = osp.join(temp_dir, '000001', '000001_img.png') img_pred_path = osp.join(temp_dir, '000001', '000001_pred.png') img_gt_file = osp.join(temp_dir, '000001', '000001_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()
def test_show(): import mmcv import tempfile from os import path as osp from mmdet3d.core.bbox import DepthInstance3DBoxes tmp_dir = tempfile.TemporaryDirectory() temp_dir = tmp_dir.name root_path = './tests/data/scannet' ann_file = './tests/data/scannet/scannet_infos.pkl' scannet_dataset = ScanNetDataset(root_path, ann_file) boxes_3d = DepthInstance3DBoxes( torch.tensor([[ -2.4053e+00, 9.2295e-01, 8.0661e-02, 2.4054e+00, 2.1468e+00, 8.5990e-01, 0.0000e+00 ], [ -1.9341e+00, -2.0741e+00, 3.0698e-03, 3.2206e-01, 2.5322e-01, 3.5144e-01, 0.0000e+00 ], [ -3.6908e+00, 8.0684e-03, 2.6201e-01, 4.1515e-01, 7.6489e-01, 5.3585e-01, 0.0000e+00 ], [ 2.6332e+00, 8.5143e-01, -4.9964e-03, 3.0367e-01, 1.3448e+00, 1.8329e+00, 0.0000e+00 ], [ 2.0221e-02, 2.6153e+00, 1.5109e-02, 7.3335e-01, 1.0429e+00, 1.0251e+00, 0.0000e+00 ]])) scores_3d = torch.tensor( [1.2058e-04, 2.3012e-03, 6.2324e-06, 6.6139e-06, 6.7965e-05]) labels_3d = torch.tensor([0, 0, 0, 0, 0]) result = dict(boxes_3d=boxes_3d, scores_3d=scores_3d, labels_3d=labels_3d) results = [result] scannet_dataset.show(results, temp_dir, show=False) pts_file_path = osp.join(temp_dir, 'scene0000_00', 'scene0000_00_points.obj') gt_file_path = osp.join(temp_dir, 'scene0000_00', 'scene0000_00_gt.obj') pred_file_path = osp.join(temp_dir, 'scene0000_00', 'scene0000_00_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() # show function with pipeline class_names = ('cabinet', 'bed', 'chair', 'sofa', 'table', 'door', 'window', 'bookshelf', 'picture', 'counter', 'desk', 'curtain', 'refrigerator', 'showercurtrain', 'toilet', 'sink', 'bathtub', 'garbagebin') eval_pipeline = [ dict(type='LoadPointsFromFile', coord_type='DEPTH', shift_height=False, load_dim=6, use_dim=[0, 1, 2]), dict(type='DefaultFormatBundle3D', class_names=class_names, with_label=False), dict(type='Collect3D', keys=['points']) ] tmp_dir = tempfile.TemporaryDirectory() temp_dir = tmp_dir.name scannet_dataset.show(results, temp_dir, show=False, pipeline=eval_pipeline) pts_file_path = osp.join(temp_dir, 'scene0000_00', 'scene0000_00_points.obj') gt_file_path = osp.join(temp_dir, 'scene0000_00', 'scene0000_00_gt.obj') pred_file_path = osp.join(temp_dir, 'scene0000_00', 'scene0000_00_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()
def test_indoor_eval(): if not torch.cuda.is_available(): pytest.skip() from mmdet3d.core.bbox.structures import Box3DMode, DepthInstance3DBoxes det_infos = [{ 'labels_3d': torch.tensor([0, 1, 2, 2, 0, 3, 1, 2, 3, 2]), 'boxes_3d': DepthInstance3DBoxes( torch.tensor([[ -2.4089e-03, -3.3174e+00, 4.9438e-01, 2.1668e+00, 2.8431e-01, 1.6506e+00, 0.0000e+00 ], [ -3.4269e-01, -2.7565e+00, 2.8144e-02, 6.8554e-01, 9.6854e-01, 6.1755e-01, 0.0000e+00 ], [ -3.8320e+00, -1.0646e+00, 1.7074e-01, 2.4981e-01, 4.4708e-01, 6.2538e-01, 0.0000e+00 ], [ 4.1073e-01, 3.3757e+00, 3.4311e-01, 8.0617e-01, 2.8679e-01, 1.6060e+00, 0.0000e+00 ], [ 6.1199e-01, -3.1041e+00, 4.1873e-01, 1.2310e+00, 4.0162e-01, 1.7303e+00, 0.0000e+00 ], [ -5.9877e-01, -2.6011e+00, 1.1148e+00, 1.5704e-01, 7.5957e-01, 9.6930e-01, 0.0000e+00 ], [ 2.7462e-01, -3.0088e+00, 6.5231e-02, 8.1208e-01, 4.1861e-01, 3.7339e-01, 0.0000e+00 ], [ -1.4704e+00, -2.0024e+00, 2.7479e-01, 1.7888e+00, 1.0566e+00, 1.3704e+00, 0.0000e+00 ], [ 8.2727e-02, -3.1160e+00, 2.5690e-01, 1.4054e+00, 2.0772e-01, 9.6792e-01, 0.0000e+00 ], [ 2.6896e+00, 1.9881e+00, 1.1566e+00, 9.9885e-02, 3.5713e-01, 4.5638e-01, 0.0000e+00 ]]), origin=(0.5, 0.5, 0)), 'scores_3d': torch.tensor([ 1.7516e-05, 1.0167e-06, 8.4486e-07, 7.1048e-02, 6.4274e-05, 1.5003e-07, 5.8102e-06, 1.9399e-08, 5.3126e-07, 1.8630e-09 ]) }] label2cat = { 0: 'cabinet', 1: 'bed', 2: 'chair', 3: 'sofa', } gt_annos = [{ 'gt_num': 10, 'gt_boxes_upright_depth': np.array([[ -2.4089e-03, -3.3174e+00, 4.9438e-01, 2.1668e+00, 2.8431e-01, 1.6506e+00, 0.0000e+00 ], [ -3.4269e-01, -2.7565e+00, 2.8144e-02, 6.8554e-01, 9.6854e-01, 6.1755e-01, 0.0000e+00 ], [ -3.8320e+00, -1.0646e+00, 1.7074e-01, 2.4981e-01, 4.4708e-01, 6.2538e-01, 0.0000e+00 ], [ 4.1073e-01, 3.3757e+00, 3.4311e-01, 8.0617e-01, 2.8679e-01, 1.6060e+00, 0.0000e+00 ], [ 6.1199e-01, -3.1041e+00, 4.1873e-01, 1.2310e+00, 4.0162e-01, 1.7303e+00, 0.0000e+00 ], [ -5.9877e-01, -2.6011e+00, 1.1148e+00, 1.5704e-01, 7.5957e-01, 9.6930e-01, 0.0000e+00 ], [ 2.7462e-01, -3.0088e+00, 6.5231e-02, 8.1208e-01, 4.1861e-01, 3.7339e-01, 0.0000e+00 ], [ -1.4704e+00, -2.0024e+00, 2.7479e-01, 1.7888e+00, 1.0566e+00, 1.3704e+00, 0.0000e+00 ], [ 8.2727e-02, -3.1160e+00, 2.5690e-01, 1.4054e+00, 2.0772e-01, 9.6792e-01, 0.0000e+00 ], [ 2.6896e+00, 1.9881e+00, 1.1566e+00, 9.9885e-02, 3.5713e-01, 4.5638e-01, 0.0000e+00 ]]), 'class': np.array([0, 1, 2, 0, 0, 3, 1, 3, 3, 2]) }] ret_value = indoor_eval( gt_annos, det_infos, [0.25, 0.5], label2cat, box_type_3d=DepthInstance3DBoxes, box_mode_3d=Box3DMode.DEPTH) assert np.isclose(ret_value['cabinet_AP_0.25'], 0.666667) assert np.isclose(ret_value['bed_AP_0.25'], 1.0) assert np.isclose(ret_value['chair_AP_0.25'], 0.5) assert np.isclose(ret_value['mAP_0.25'], 0.708333) assert np.isclose(ret_value['mAR_0.25'], 0.833333)
def test_evaluate(): if not torch.cuda.is_available(): pytest.skip() from mmdet3d.core.bbox.structures import DepthInstance3DBoxes root_path = './tests/data/scannet' ann_file = './tests/data/scannet/scannet_infos.pkl' scannet_dataset = ScanNetDataset(root_path, ann_file) results = [] pred_boxes = dict() pred_boxes['boxes_3d'] = DepthInstance3DBoxes( torch.tensor([[ 1.4813e+00, 3.5207e+00, 1.5704e+00, 1.7445e+00, 2.3196e-01, 5.7235e-01, 0.0000e+00 ], [ 2.9040e+00, -3.4803e+00, 1.1911e+00, 6.6078e-01, 1.7072e-01, 6.7154e-01, 0.0000e+00 ], [ 1.1466e+00, 2.1987e+00, 9.2576e-03, 5.4184e-01, 2.5346e+00, 1.2145e+00, 0.0000e+00 ], [ 2.9168e+00, 2.5016e+00, 8.2875e-01, 6.1697e-01, 1.8428e+00, 2.8697e-01, 0.0000e+00 ], [ -3.3114e+00, -1.3351e-02, -8.9524e-03, 4.4082e-01, 3.8582e+00, 2.1603e+00, 0.0000e+00 ], [ -2.0135e+00, -3.4857e+00, 9.3848e-01, 1.9911e+00, 2.1603e-01, 1.2767e+00, 0.0000e+00 ], [ -2.1945e+00, -3.1402e+00, -3.8165e-02, 1.4801e+00, 6.8676e-01, 1.0586e+00, 0.0000e+00 ], [ -2.7553e+00, 2.4055e+00, -2.9972e-02, 1.4764e+00, 1.4927e+00, 2.3380e+00, 0.0000e+00 ]])) pred_boxes['labels_3d'] = torch.tensor([6, 6, 4, 9, 11, 11]) pred_boxes['scores_3d'] = torch.tensor([0.5, 1.0, 1.0, 1.0, 1.0, 0.5]) results.append(pred_boxes) metric = [0.25, 0.5] ret_dict = scannet_dataset.evaluate(results, metric) assert abs(ret_dict['table_AP_0.25'] - 0.3333) < 0.01 assert abs(ret_dict['window_AP_0.25'] - 1.0) < 0.01 assert abs(ret_dict['counter_AP_0.25'] - 1.0) < 0.01 assert abs(ret_dict['curtain_AP_0.25'] - 1.0) < 0.01 # test evaluate with pipeline class_names = ('cabinet', 'bed', 'chair', 'sofa', 'table', 'door', 'window', 'bookshelf', 'picture', 'counter', 'desk', 'curtain', 'refrigerator', 'showercurtrain', 'toilet', 'sink', 'bathtub', 'garbagebin') eval_pipeline = [ dict(type='LoadPointsFromFile', coord_type='DEPTH', shift_height=False, load_dim=6, use_dim=[0, 1, 2]), dict(type='GlobalAlignment', rotation_axis=2), dict(type='DefaultFormatBundle3D', class_names=class_names, with_label=False), dict(type='Collect3D', keys=['points']) ] ret_dict = scannet_dataset.evaluate(results, metric, pipeline=eval_pipeline) assert abs(ret_dict['table_AP_0.25'] - 0.3333) < 0.01 assert abs(ret_dict['window_AP_0.25'] - 1.0) < 0.01 assert abs(ret_dict['counter_AP_0.25'] - 1.0) < 0.01 assert abs(ret_dict['curtain_AP_0.25'] - 1.0) < 0.01