misc.py 3.67 KB
Newer Older
1
# Copyright (c) OpenMMLab. All rights reserved.
2
3
4
5
6


def replace_ceph_backend(cfg):
    cfg_pretty_text = cfg.pretty_text

ChaimZhu's avatar
ChaimZhu committed
7
8
9
10
    replace_strs = \
        r'''file_client_args = dict(
            backend='petrel',
            path_mapping=dict({
11
                './data/DATA/': 's3://openmmlab/datasets/detection3d/CEPH/',
ChaimZhu's avatar
ChaimZhu committed
12
13
14
                'data/DATA/': 's3://openmmlab/datasets/detection3d/CEPH/'
            }))
        '''
15
16

    if 'nuscenes' in cfg_pretty_text:
ChaimZhu's avatar
ChaimZhu committed
17
18
        replace_strs = replace_strs.replace('DATA', 'nuscenes')
        replace_strs = replace_strs.replace('CEPH', 'nuscenes')
19
    elif 'lyft' in cfg_pretty_text:
ChaimZhu's avatar
ChaimZhu committed
20
21
        replace_strs = replace_strs.replace('DATA', 'lyft')
        replace_strs = replace_strs.replace('CEPH', 'lyft')
22
    elif 'waymo' in cfg_pretty_text:
ChaimZhu's avatar
ChaimZhu committed
23
24
        replace_strs = replace_strs.replace('DATA', 'waymo')
        replace_strs = replace_strs.replace('CEPH', 'waymo')
25
26
27
    elif 'kitti' in cfg_pretty_text:
        replace_strs = replace_strs.replace('DATA', 'kitti')
        replace_strs = replace_strs.replace('CEPH', 'kitti')
28
    elif 'scannet' in cfg_pretty_text:
ChaimZhu's avatar
ChaimZhu committed
29
30
        replace_strs = replace_strs.replace('DATA', 'scannet')
        replace_strs = replace_strs.replace('CEPH', 'scannet_processed')
31
    elif 's3dis' in cfg_pretty_text:
ChaimZhu's avatar
ChaimZhu committed
32
33
        replace_strs = replace_strs.replace('DATA', 's3dis')
        replace_strs = replace_strs.replace('CEPH', 's3dis_processed')
34
    elif 'sunrgbd' in cfg_pretty_text:
ChaimZhu's avatar
ChaimZhu committed
35
36
        replace_strs = replace_strs.replace('DATA', 'sunrgbd')
        replace_strs = replace_strs.replace('CEPH', 'sunrgbd_processed')
37
    elif 'semantickitti' in cfg_pretty_text:
ChaimZhu's avatar
ChaimZhu committed
38
39
        replace_strs = replace_strs.replace('DATA', 'semantickitti')
        replace_strs = replace_strs.replace('CEPH', 'semantickitti')
40
    elif 'nuimages' in cfg_pretty_text:
ChaimZhu's avatar
ChaimZhu committed
41
42
        replace_strs = replace_strs.replace('DATA', 'nuimages')
        replace_strs = replace_strs.replace('CEPH', 'nuimages')
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
    else:
        NotImplemented('Does not support global replacement')

    replace_strs = replace_strs.replace(' ', '').replace('\n', '')

    # use data info file from ceph
    # cfg_pretty_text = cfg_pretty_text.replace(
    #   'ann_file', replace_strs + ', ann_file')

    # replace LoadImageFromFile
    cfg_pretty_text = cfg_pretty_text.replace(
        'LoadImageFromFile\'', 'LoadImageFromFile\',' + replace_strs)

    # replace LoadImageFromFileMono3D
    cfg_pretty_text = cfg_pretty_text.replace(
        'LoadImageFromFileMono3D\'',
        'LoadImageFromFileMono3D\',' + replace_strs)

61
62
63
64
65
    # replace LoadMultiViewImageFromFiles
    cfg_pretty_text = cfg_pretty_text.replace(
        'LoadMultiViewImageFromFiles\'',
        'LoadMultiViewImageFromFiles\',' + replace_strs)

66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
    # replace LoadPointsFromFile
    cfg_pretty_text = cfg_pretty_text.replace(
        'LoadPointsFromFile\'', 'LoadPointsFromFile\',' + replace_strs)

    # replace LoadPointsFromMultiSweeps
    cfg_pretty_text = cfg_pretty_text.replace(
        'LoadPointsFromMultiSweeps\'',
        'LoadPointsFromMultiSweeps\',' + replace_strs)

    # replace LoadAnnotations
    cfg_pretty_text = cfg_pretty_text.replace(
        'LoadAnnotations\'', 'LoadAnnotations\',' + replace_strs)

    # replace LoadAnnotations3D
    cfg_pretty_text = cfg_pretty_text.replace(
        'LoadAnnotations3D\'', 'LoadAnnotations3D\',' + replace_strs)

83
84
85
86
    # replace WaymoMetric
    cfg_pretty_text = cfg_pretty_text.replace('WaymoMetric\'',
                                              'WaymoMetric\',' + replace_strs)

87
88
89
90
91
92
    # replace dbsampler
    cfg_pretty_text = cfg_pretty_text.replace('info_path',
                                              replace_strs + ', info_path')

    cfg = cfg.fromstring(cfg_pretty_text, file_format='.py')
    return cfg