scannet_dataset.py 2 KB
Newer Older
1
2
3
4
5
import os.path as osp

import numpy as np

from mmdet.datasets import DATASETS
zhangwenwei's avatar
zhangwenwei committed
6
from .custom_3d import Custom3DDataset
7
8
9


@DATASETS.register_module()
zhangwenwei's avatar
zhangwenwei committed
10
class ScanNetDataset(Custom3DDataset):
11

12
13
14
15
16
17
    CLASSES = ('cabinet', 'bed', 'chair', 'sofa', 'table', 'door', 'window',
               'bookshelf', 'picture', 'counter', 'desk', 'curtain',
               'refrigerator', 'showercurtrain', 'toilet', 'sink', 'bathtub',
               'garbagebin')

    def __init__(self,
zhangwenwei's avatar
zhangwenwei committed
18
                 data_root,
19
20
                 ann_file,
                 pipeline=None,
liyinhao's avatar
liyinhao committed
21
                 classes=None,
liyinhao's avatar
liyinhao committed
22
                 modality=None,
23
                 box_type_3d='Depth',
wuyuefeng's avatar
Votenet  
wuyuefeng committed
24
                 filter_empty_gt=True,
zhangwenwei's avatar
zhangwenwei committed
25
                 test_mode=False):
26
27
28
29
30
31
32
33
34
        super().__init__(
            data_root=data_root,
            ann_file=ann_file,
            pipeline=pipeline,
            classes=classes,
            modality=modality,
            box_type_3d=box_type_3d,
            filter_empty_gt=filter_empty_gt,
            test_mode=test_mode)
35

liyinhao's avatar
liyinhao committed
36
    def get_ann_info(self, index):
37
        # Use index to get the annos, thus the evalhook could also use this api
liyinhao's avatar
liyinhao committed
38
        info = self.data_infos[index]
39
        if info['annos']['gt_num'] != 0:
liyinhao's avatar
liyinhao committed
40
41
42
            gt_bboxes_3d = info['annos']['gt_boxes_upright_depth'].astype(
                np.float32)  # k, 6
            gt_labels_3d = info['annos']['class'].astype(np.long)
43
        else:
liyinhao's avatar
liyinhao committed
44
            gt_bboxes_3d = np.zeros((0, 6), dtype=np.float32)
liyinhao's avatar
liyinhao committed
45
            gt_labels_3d = np.zeros((0, ), dtype=np.long)
zhangwenwei's avatar
zhangwenwei committed
46
        pts_instance_mask_path = osp.join(self.data_root,
liyinhao's avatar
liyinhao committed
47
                                          info['pts_instance_mask_path'])
zhangwenwei's avatar
zhangwenwei committed
48
        pts_semantic_mask_path = osp.join(self.data_root,
liyinhao's avatar
liyinhao committed
49
                                          info['pts_semantic_mask_path'])
50
51
52

        anns_results = dict(
            gt_bboxes_3d=gt_bboxes_3d,
zhangwenwei's avatar
zhangwenwei committed
53
            gt_labels_3d=gt_labels_3d,
54
55
56
            pts_instance_mask_path=pts_instance_mask_path,
            pts_semantic_mask_path=pts_semantic_mask_path)
        return anns_results