loading.py 21.8 KB
Newer Older
zhangwenwei's avatar
zhangwenwei committed
1
2
3
import mmcv
import numpy as np

4
from mmdet3d.core.points import BasePoints, get_points_type
5
from mmdet.datasets.builder import PIPELINES
wuyuefeng's avatar
wuyuefeng committed
6
from mmdet.datasets.pipelines import LoadAnnotations
zhangwenwei's avatar
zhangwenwei committed
7
8


9
@PIPELINES.register_module()
zhangwenwei's avatar
zhangwenwei committed
10
class LoadMultiViewImageFromFiles(object):
zhangwenwei's avatar
zhangwenwei committed
11
    """Load multi channel images from a list of separate channel files.
zhangwenwei's avatar
zhangwenwei committed
12

liyinhao's avatar
liyinhao committed
13
14
15
16
17
18
    Expects results['img_filename'] to be a list of filenames.

    Args:
        to_float32 (bool): Whether to convert the img to float32.
            Defaults to False.
        color_type (str): Color type of the file. Defaults to 'unchanged'.
zhangwenwei's avatar
zhangwenwei committed
19
    """
zhangwenwei's avatar
zhangwenwei committed
20

zhangwenwei's avatar
zhangwenwei committed
21
22
23
    def __init__(self, to_float32=False, color_type='unchanged'):
        self.to_float32 = to_float32
        self.color_type = color_type
zhangwenwei's avatar
zhangwenwei committed
24
25

    def __call__(self, results):
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
        """Call function to load multi-view image from files.

        Args:
            results (dict): Result dict containing multi-view image filenames.

        Returns:
            dict: The result dict containing the multi-view image data. \
                Added keys and values are described below.

                - filename (str): Multi-view image filenames.
                - img (np.ndarray): Multi-view image arrays.
                - img_shape (tuple[int]): Shape of multi-view image arrays.
                - ori_shape (tuple[int]): Shape of original image arrays.
                - pad_shape (tuple[int]): Shape of padded image arrays.
                - scale_factor (float): Scale factor.
                - img_norm_cfg (dict): Normalization configuration of images.
        """
zhangwenwei's avatar
zhangwenwei committed
43
        filename = results['img_filename']
zhangwenwei's avatar
zhangwenwei committed
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
        img = np.stack(
            [mmcv.imread(name, self.color_type) for name in filename], axis=-1)
        if self.to_float32:
            img = img.astype(np.float32)
        results['filename'] = filename
        results['img'] = img
        results['img_shape'] = img.shape
        results['ori_shape'] = img.shape
        # Set initial values for default meta_keys
        results['pad_shape'] = img.shape
        results['scale_factor'] = 1.0
        num_channels = 1 if len(img.shape) < 3 else img.shape[2]
        results['img_norm_cfg'] = dict(
            mean=np.zeros(num_channels, dtype=np.float32),
            std=np.ones(num_channels, dtype=np.float32),
            to_rgb=False)
zhangwenwei's avatar
zhangwenwei committed
60
61
62
        return results

    def __repr__(self):
63
        """str: Return a string that describes the module."""
64
65
        return f'{self.__class__.__name__} (to_float32={self.to_float32}, '\
            f"color_type='{self.color_type}')"
zhangwenwei's avatar
zhangwenwei committed
66
67
68
69


@PIPELINES.register_module()
class LoadPointsFromMultiSweeps(object):
zhangwenwei's avatar
zhangwenwei committed
70
    """Load points from multiple sweeps.
zhangwenwei's avatar
zhangwenwei committed
71

zhangwenwei's avatar
zhangwenwei committed
72
73
74
    This is usually used for nuScenes dataset to utilize previous sweeps.

    Args:
75
76
77
        sweeps_num (int): Number of sweeps. Defaults to 10.
        load_dim (int): Dimension number of the loaded points. Defaults to 5.
        use_dim (list[int]): Which dimension to use. Defaults to [0, 1, 2, 4].
zhangwenwei's avatar
zhangwenwei committed
78
79
        file_client_args (dict): Config dict of file clients, refer to
            https://github.com/open-mmlab/mmcv/blob/master/mmcv/fileio/file_client.py
liyinhao's avatar
liyinhao committed
80
            for more details. Defaults to dict(backend='disk').
81
82
83
84
85
86
87
        pad_empty_sweeps (bool): Whether to repeat keyframe when
            sweeps is empty. Defaults to False.
        remove_close (bool): Whether to remove close points.
            Defaults to False.
        test_mode (bool): If test_model=True used for testing, it will not
            randomly sample sweeps but select the nearest N frames.
            Defaults to False.
zhangwenwei's avatar
zhangwenwei committed
88
89
90
91
92
    """

    def __init__(self,
                 sweeps_num=10,
                 load_dim=5,
93
94
95
96
97
                 use_dim=[0, 1, 2, 4],
                 file_client_args=dict(backend='disk'),
                 pad_empty_sweeps=False,
                 remove_close=False,
                 test_mode=False):
zhangwenwei's avatar
zhangwenwei committed
98
        self.load_dim = load_dim
zhangwenwei's avatar
zhangwenwei committed
99
        self.sweeps_num = sweeps_num
100
        self.use_dim = use_dim
zhangwenwei's avatar
zhangwenwei committed
101
102
        self.file_client_args = file_client_args.copy()
        self.file_client = None
103
104
105
        self.pad_empty_sweeps = pad_empty_sweeps
        self.remove_close = remove_close
        self.test_mode = test_mode
zhangwenwei's avatar
zhangwenwei committed
106
107

    def _load_points(self, pts_filename):
108
109
110
111
112
113
114
115
        """Private function to load point clouds data.

        Args:
            pts_filename (str): Filename of point clouds data.

        Returns:
            np.ndarray: An array containing point clouds data.
        """
zhangwenwei's avatar
zhangwenwei committed
116
117
118
119
120
121
122
123
124
125
126
127
        if self.file_client is None:
            self.file_client = mmcv.FileClient(**self.file_client_args)
        try:
            pts_bytes = self.file_client.get(pts_filename)
            points = np.frombuffer(pts_bytes, dtype=np.float32)
        except ConnectionError:
            mmcv.check_file_exist(pts_filename)
            if pts_filename.endswith('.npy'):
                points = np.load(pts_filename)
            else:
                points = np.fromfile(pts_filename, dtype=np.float32)
        return points
zhangwenwei's avatar
zhangwenwei committed
128

129
130
131
132
133
134
135
136
137
138
139
    def _remove_close(self, points, radius=1.0):
        """Removes point too close within a certain radius from origin.

        Args:
            points (np.ndarray): Sweep points.
            radius (float): Radius below which points are removed.
                Defaults to 1.0.

        Returns:
            np.ndarray: Points after removing.
        """
140
141
142
143
144
145
146
147
        if isinstance(points, np.ndarray):
            points_numpy = points
        elif isinstance(points, BasePoints):
            points_numpy = points.tensor.numpy()
        else:
            raise NotImplementedError
        x_filt = np.abs(points_numpy[:, 0]) < radius
        y_filt = np.abs(points_numpy[:, 1]) < radius
148
        not_close = np.logical_not(np.logical_and(x_filt, y_filt))
149
        return points[not_close]
150

zhangwenwei's avatar
zhangwenwei committed
151
    def __call__(self, results):
152
153
154
155
156
157
158
159
160
161
162
163
        """Call function to load multi-sweep point clouds from files.

        Args:
            results (dict): Result dict containing multi-sweep point cloud \
                filenames.

        Returns:
            dict: The result dict containing the multi-sweep points data. \
                Added key and value are described below.

                - points (np.ndarray): Multi-sweep point cloud arrays.
        """
zhangwenwei's avatar
zhangwenwei committed
164
        points = results['points']
165
        points.tensor[:, 4] = 0
zhangwenwei's avatar
zhangwenwei committed
166
167
        sweep_points_list = [points]
        ts = results['timestamp']
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
        if self.pad_empty_sweeps and len(results['sweeps']) == 0:
            for i in range(self.sweeps_num):
                if self.remove_close:
                    sweep_points_list.append(self._remove_close(points))
                else:
                    sweep_points_list.append(points)
        else:
            if len(results['sweeps']) <= self.sweeps_num:
                choices = np.arange(len(results['sweeps']))
            elif self.test_mode:
                choices = np.arange(self.sweeps_num)
            else:
                choices = np.random.choice(
                    len(results['sweeps']), self.sweeps_num, replace=False)
            for idx in choices:
                sweep = results['sweeps'][idx]
                points_sweep = self._load_points(sweep['data_path'])
                points_sweep = np.copy(points_sweep).reshape(-1, self.load_dim)
                if self.remove_close:
                    points_sweep = self._remove_close(points_sweep)
                sweep_ts = sweep['timestamp'] / 1e6
                points_sweep[:, :3] = points_sweep[:, :3] @ sweep[
                    'sensor2lidar_rotation'].T
                points_sweep[:, :3] += sweep['sensor2lidar_translation']
                points_sweep[:, 4] = ts - sweep_ts
193
                points_sweep = points.new_point(points_sweep)
194
195
                sweep_points_list.append(points_sweep)

196
197
        points = points.cat(sweep_points_list)
        points = points[:, self.use_dim]
zhangwenwei's avatar
zhangwenwei committed
198
199
200
201
        results['points'] = points
        return results

    def __repr__(self):
202
        """str: Return a string that describes the module."""
zhangwenwei's avatar
zhangwenwei committed
203
        return f'{self.__class__.__name__}(sweeps_num={self.sweeps_num})'
wuyuefeng's avatar
wuyuefeng committed
204
205
206
207
208
209
210
211
212
213


@PIPELINES.register_module()
class PointSegClassMapping(object):
    """Map original semantic class to valid category ids.

    Map valid classes as 0~len(valid_cat_ids)-1 and
    others as len(valid_cat_ids).

    Args:
214
        valid_cat_ids (tuple[int]): A tuple of valid category.
wuyuefeng's avatar
wuyuefeng committed
215
216
217
218
219
220
    """

    def __init__(self, valid_cat_ids):
        self.valid_cat_ids = valid_cat_ids

    def __call__(self, results):
221
222
223
224
225
226
227
228
229
230
231
        """Call function to map original semantic class to valid category ids.

        Args:
            results (dict): Result dict containing point semantic masks.

        Returns:
            dict: The result dict containing the mapped category ids. \
                Updated key and value are described below.

                - pts_semantic_mask (np.ndarray): Mapped semantic masks.
        """
wuyuefeng's avatar
wuyuefeng committed
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
        assert 'pts_semantic_mask' in results
        pts_semantic_mask = results['pts_semantic_mask']
        neg_cls = len(self.valid_cat_ids)

        for i in range(pts_semantic_mask.shape[0]):
            if pts_semantic_mask[i] in self.valid_cat_ids:
                converted_id = self.valid_cat_ids.index(pts_semantic_mask[i])
                pts_semantic_mask[i] = converted_id
            else:
                pts_semantic_mask[i] = neg_cls

        results['pts_semantic_mask'] = pts_semantic_mask
        return results

    def __repr__(self):
247
        """str: Return a string that describes the module."""
wuyuefeng's avatar
wuyuefeng committed
248
        repr_str = self.__class__.__name__
249
        repr_str += f'(valid_cat_ids={self.valid_cat_ids})'
wuyuefeng's avatar
wuyuefeng committed
250
251
252
253
254
        return repr_str


@PIPELINES.register_module()
class NormalizePointsColor(object):
zhangwenwei's avatar
zhangwenwei committed
255
    """Normalize color of points.
wuyuefeng's avatar
wuyuefeng committed
256
257
258
259
260
261
262
263
264

    Args:
        color_mean (list[float]): Mean color of the point cloud.
    """

    def __init__(self, color_mean):
        self.color_mean = color_mean

    def __call__(self, results):
265
266
267
268
269
270
271
272
273
274
275
        """Call function to normalize color of points.

        Args:
            results (dict): Result dict containing point clouds data.

        Returns:
            dict: The result dict containing the normalized points. \
                Updated key and value are described below.

                - points (np.ndarray): Points after color normalization.
        """
wuyuefeng's avatar
wuyuefeng committed
276
        points = results['points']
277
278
279
280
281
282
283
        assert points.attribute_dims is not None and \
            'color' in points.attribute_dims.keys(), \
            'Expect points have color attribute'
        if self.color_mean is not None:
            points.color = points.color - \
                points.color.new_tensor(self.color_mean)
        points.color = points.color / 255.0
wuyuefeng's avatar
wuyuefeng committed
284
285
286
287
        results['points'] = points
        return results

    def __repr__(self):
288
        """str: Return a string that describes the module."""
wuyuefeng's avatar
wuyuefeng committed
289
        repr_str = self.__class__.__name__
290
        repr_str += f'(color_mean={self.color_mean})'
wuyuefeng's avatar
wuyuefeng committed
291
292
293
294
295
296
297
298
299
300
        return repr_str


@PIPELINES.register_module()
class LoadPointsFromFile(object):
    """Load Points From File.

    Load sunrgbd and scannet points from file.

    Args:
301
302
303
304
305
        coord_type (str): The type of coordinates of points cloud.
            Available options includes:
            - 'LIDAR': Points in LiDAR coordinates.
            - 'DEPTH': Points in depth coordinates, usually for indoor dataset.
            - 'CAMERA': Points in camera coordinates.
306
307
        load_dim (int): The dimension of the loaded points.
            Defaults to 6.
wuyuefeng's avatar
wuyuefeng committed
308
        use_dim (list[int]): Which dimensions of the points to be used.
liyinhao's avatar
liyinhao committed
309
310
311
            Defaults to [0, 1, 2]. For KITTI dataset, set use_dim=4
            or use_dim=[0, 1, 2, 3] to use the intensity dimension.
        shift_height (bool): Whether to use shifted height. Defaults to False.
312
        use_color (bool): Whether to use color features. Defaults to False.
wuyuefeng's avatar
wuyuefeng committed
313
314
        file_client_args (dict): Config dict of file clients, refer to
            https://github.com/open-mmlab/mmcv/blob/master/mmcv/fileio/file_client.py
liyinhao's avatar
liyinhao committed
315
            for more details. Defaults to dict(backend='disk').
wuyuefeng's avatar
wuyuefeng committed
316
317
318
    """

    def __init__(self,
319
                 coord_type,
wuyuefeng's avatar
wuyuefeng committed
320
321
322
                 load_dim=6,
                 use_dim=[0, 1, 2],
                 shift_height=False,
323
                 use_color=False,
wuyuefeng's avatar
wuyuefeng committed
324
325
                 file_client_args=dict(backend='disk')):
        self.shift_height = shift_height
326
        self.use_color = use_color
wuyuefeng's avatar
wuyuefeng committed
327
328
329
330
        if isinstance(use_dim, int):
            use_dim = list(range(use_dim))
        assert max(use_dim) < load_dim, \
            f'Expect all used dimensions < {load_dim}, got {use_dim}'
331
        assert coord_type in ['CAMERA', 'LIDAR', 'DEPTH']
wuyuefeng's avatar
wuyuefeng committed
332

333
        self.coord_type = coord_type
wuyuefeng's avatar
wuyuefeng committed
334
335
336
337
338
339
        self.load_dim = load_dim
        self.use_dim = use_dim
        self.file_client_args = file_client_args.copy()
        self.file_client = None

    def _load_points(self, pts_filename):
340
341
342
343
344
345
346
347
        """Private function to load point clouds data.

        Args:
            pts_filename (str): Filename of point clouds data.

        Returns:
            np.ndarray: An array containing point clouds data.
        """
wuyuefeng's avatar
wuyuefeng committed
348
349
350
351
352
353
354
355
356
357
358
        if self.file_client is None:
            self.file_client = mmcv.FileClient(**self.file_client_args)
        try:
            pts_bytes = self.file_client.get(pts_filename)
            points = np.frombuffer(pts_bytes, dtype=np.float32)
        except ConnectionError:
            mmcv.check_file_exist(pts_filename)
            if pts_filename.endswith('.npy'):
                points = np.load(pts_filename)
            else:
                points = np.fromfile(pts_filename, dtype=np.float32)
359

wuyuefeng's avatar
wuyuefeng committed
360
361
362
        return points

    def __call__(self, results):
363
364
365
366
367
368
369
370
371
372
373
        """Call function to load points data from file.

        Args:
            results (dict): Result dict containing point clouds data.

        Returns:
            dict: The result dict containing the point clouds data. \
                Added key and value are described below.

                - points (np.ndarray): Point clouds data.
        """
wuyuefeng's avatar
wuyuefeng committed
374
375
376
377
        pts_filename = results['pts_filename']
        points = self._load_points(pts_filename)
        points = points.reshape(-1, self.load_dim)
        points = points[:, self.use_dim]
378
        attribute_dims = None
wuyuefeng's avatar
wuyuefeng committed
379
380
381
382

        if self.shift_height:
            floor_height = np.percentile(points[:, 2], 0.99)
            height = points[:, 2] - floor_height
383
384
385
            points = np.concatenate(
                [points[:, :3],
                 np.expand_dims(height, 1), points[:, 3:]], 1)
386
387
            attribute_dims = dict(height=3)

388
389
390
391
392
393
394
395
396
397
398
        if self.use_color:
            assert len(self.use_dim) >= 6
            if attribute_dims is None:
                attribute_dims = dict()
            attribute_dims.update(
                dict(color=[
                    points.shape[1] - 3,
                    points.shape[1] - 2,
                    points.shape[1] - 1,
                ]))

399
400
401
        points_class = get_points_type(self.coord_type)
        points = points_class(
            points, points_dim=points.shape[-1], attribute_dims=attribute_dims)
wuyuefeng's avatar
wuyuefeng committed
402
        results['points'] = points
403

wuyuefeng's avatar
wuyuefeng committed
404
405
406
        return results

    def __repr__(self):
407
        """str: Return a string that describes the module."""
liyinhao's avatar
liyinhao committed
408
        repr_str = self.__class__.__name__ + '('
409
410
411
412
413
        repr_str += f'shift_height={self.shift_height}, '
        repr_str += f'use_color={self.use_color}, '
        repr_str += f'file_client_args={self.file_client_args}, '
        repr_str += f'load_dim={self.load_dim}, '
        repr_str += f'use_dim={self.use_dim})'
wuyuefeng's avatar
wuyuefeng committed
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
        return repr_str


@PIPELINES.register_module()
class LoadAnnotations3D(LoadAnnotations):
    """Load Annotations3D.

    Load instance mask and semantic mask of points and
    encapsulate the items into related fields.

    Args:
        with_bbox_3d (bool, optional): Whether to load 3D boxes.
            Defaults to True.
        with_label_3d (bool, optional): Whether to load 3D labels.
            Defaults to True.
        with_mask_3d (bool, optional): Whether to load 3D instance masks.
            for points. Defaults to False.
        with_seg_3d (bool, optional): Whether to load 3D semantic masks.
            for points. Defaults to False.
        with_bbox (bool, optional): Whether to load 2D boxes.
            Defaults to False.
        with_label (bool, optional): Whether to load 2D labels.
            Defaults to False.
        with_mask (bool, optional): Whether to load 2D instance masks.
            Defaults to False.
        with_seg (bool, optional): Whether to load 2D semantic masks.
            Defaults to False.
        poly2mask (bool, optional): Whether to convert polygon annotations
            to bitmasks. Defaults to True.
443
444
        seg_3d_dtype (dtype, optional): Dtype of 3D semantic masks.
            Defaults to int64
wuyuefeng's avatar
wuyuefeng committed
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
        file_client_args (dict): Config dict of file clients, refer to
            https://github.com/open-mmlab/mmcv/blob/master/mmcv/fileio/file_client.py
            for more details.
    """

    def __init__(self,
                 with_bbox_3d=True,
                 with_label_3d=True,
                 with_mask_3d=False,
                 with_seg_3d=False,
                 with_bbox=False,
                 with_label=False,
                 with_mask=False,
                 with_seg=False,
                 poly2mask=True,
460
                 seg_3d_dtype='int',
wuyuefeng's avatar
wuyuefeng committed
461
462
463
464
465
466
467
468
469
470
471
472
                 file_client_args=dict(backend='disk')):
        super().__init__(
            with_bbox,
            with_label,
            with_mask,
            with_seg,
            poly2mask,
            file_client_args=file_client_args)
        self.with_bbox_3d = with_bbox_3d
        self.with_label_3d = with_label_3d
        self.with_mask_3d = with_mask_3d
        self.with_seg_3d = with_seg_3d
473
        self.seg_3d_dtype = seg_3d_dtype
wuyuefeng's avatar
wuyuefeng committed
474
475

    def _load_bboxes_3d(self, results):
476
477
478
479
480
481
482
483
        """Private function to load 3D bounding box annotations.

        Args:
            results (dict): Result dict from :obj:`mmdet3d.CustomDataset`.

        Returns:
            dict: The dict containing loaded 3D bounding box annotations.
        """
wuyuefeng's avatar
wuyuefeng committed
484
485
486
487
488
        results['gt_bboxes_3d'] = results['ann_info']['gt_bboxes_3d']
        results['bbox3d_fields'].append('gt_bboxes_3d')
        return results

    def _load_labels_3d(self, results):
489
490
491
492
493
494
495
496
        """Private function to load label annotations.

        Args:
            results (dict): Result dict from :obj:`mmdet3d.CustomDataset`.

        Returns:
            dict: The dict containing loaded label annotations.
        """
wuyuefeng's avatar
wuyuefeng committed
497
498
499
500
        results['gt_labels_3d'] = results['ann_info']['gt_labels_3d']
        return results

    def _load_masks_3d(self, results):
501
502
503
504
505
506
507
508
        """Private function to load 3D mask annotations.

        Args:
            results (dict): Result dict from :obj:`mmdet3d.CustomDataset`.

        Returns:
            dict: The dict containing loaded 3D mask annotations.
        """
wuyuefeng's avatar
wuyuefeng committed
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
        pts_instance_mask_path = results['ann_info']['pts_instance_mask_path']

        if self.file_client is None:
            self.file_client = mmcv.FileClient(**self.file_client_args)
        try:
            mask_bytes = self.file_client.get(pts_instance_mask_path)
            pts_instance_mask = np.frombuffer(mask_bytes, dtype=np.int)
        except ConnectionError:
            mmcv.check_file_exist(pts_instance_mask_path)
            pts_instance_mask = np.fromfile(
                pts_instance_mask_path, dtype=np.long)

        results['pts_instance_mask'] = pts_instance_mask
        results['pts_mask_fields'].append('pts_instance_mask')
        return results

    def _load_semantic_seg_3d(self, results):
526
527
528
529
530
531
532
533
        """Private function to load 3D semantic segmentation annotations.

        Args:
            results (dict): Result dict from :obj:`mmdet3d.CustomDataset`.

        Returns:
            dict: The dict containing the semantic segmentation annotations.
        """
wuyuefeng's avatar
wuyuefeng committed
534
535
536
537
538
539
540
        pts_semantic_mask_path = results['ann_info']['pts_semantic_mask_path']

        if self.file_client is None:
            self.file_client = mmcv.FileClient(**self.file_client_args)
        try:
            mask_bytes = self.file_client.get(pts_semantic_mask_path)
            # add .copy() to fix read-only bug
541
542
            pts_semantic_mask = np.frombuffer(
                mask_bytes, dtype=self.seg_3d_dtype).copy()
wuyuefeng's avatar
wuyuefeng committed
543
544
545
546
547
548
549
550
551
552
        except ConnectionError:
            mmcv.check_file_exist(pts_semantic_mask_path)
            pts_semantic_mask = np.fromfile(
                pts_semantic_mask_path, dtype=np.long)

        results['pts_semantic_mask'] = pts_semantic_mask
        results['pts_seg_fields'].append('pts_semantic_mask')
        return results

    def __call__(self, results):
553
554
555
556
557
558
559
560
561
        """Call function to load multiple types annotations.

        Args:
            results (dict): Result dict from :obj:`mmdet3d.CustomDataset`.

        Returns:
            dict: The dict containing loaded 3D bounding box, label, mask and
                semantic segmentation annotations.
        """
wuyuefeng's avatar
wuyuefeng committed
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
        results = super().__call__(results)
        if self.with_bbox_3d:
            results = self._load_bboxes_3d(results)
            if results is None:
                return None
        if self.with_label_3d:
            results = self._load_labels_3d(results)
        if self.with_mask_3d:
            results = self._load_masks_3d(results)
        if self.with_seg_3d:
            results = self._load_semantic_seg_3d(results)

        return results

    def __repr__(self):
577
        """str: Return a string that describes the module."""
wuyuefeng's avatar
wuyuefeng committed
578
579
        indent_str = '    '
        repr_str = self.__class__.__name__ + '(\n'
liyinhao's avatar
liyinhao committed
580
581
582
583
584
585
586
587
        repr_str += f'{indent_str}with_bbox_3d={self.with_bbox_3d}, '
        repr_str += f'{indent_str}with_label_3d={self.with_label_3d}, '
        repr_str += f'{indent_str}with_mask_3d={self.with_mask_3d}, '
        repr_str += f'{indent_str}with_seg_3d={self.with_seg_3d}, '
        repr_str += f'{indent_str}with_bbox={self.with_bbox}, '
        repr_str += f'{indent_str}with_label={self.with_label}, '
        repr_str += f'{indent_str}with_mask={self.with_mask}, '
        repr_str += f'{indent_str}with_seg={self.with_seg}, '
wuyuefeng's avatar
wuyuefeng committed
588
589
        repr_str += f'{indent_str}poly2mask={self.poly2mask})'
        return repr_str