scannet_dataset.py 1.8 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,
wuyuefeng's avatar
Votenet  
wuyuefeng committed
23
                 filter_empty_gt=True,
zhangwenwei's avatar
zhangwenwei committed
24
                 test_mode=False):
liyinhao's avatar
liyinhao committed
25
        super().__init__(data_root, ann_file, pipeline, classes, modality,
wuyuefeng's avatar
Votenet  
wuyuefeng committed
26
                         filter_empty_gt, test_mode)
27

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

        anns_results = dict(
            gt_bboxes_3d=gt_bboxes_3d,
zhangwenwei's avatar
zhangwenwei committed
45
            gt_labels_3d=gt_labels_3d,
46
47
48
            pts_instance_mask_path=pts_instance_mask_path,
            pts_semantic_mask_path=pts_semantic_mask_path)
        return anns_results