registry.py 5.02 KB
Newer Older
1
# Copyright (c) OpenMMLab. All rights reserved.
2
3
4
5
6
7
8
9
10
"""MMDetection3D provides 17 registry nodes to support using modules across
projects. Each node is a child of the root registry in MMEngine.

More details can be found at
https://mmengine.readthedocs.io/en/latest/tutorials/registry.html.
"""

from mmengine.registry import DATA_SAMPLERS as MMENGINE_DATA_SAMPLERS
from mmengine.registry import DATASETS as MMENGINE_DATASETS
11
from mmengine.registry import EVALUATOR as MMENGINE_EVALUATOR
12
from mmengine.registry import HOOKS as MMENGINE_HOOKS
13
from mmengine.registry import INFERENCERS as MMENGINE_INFERENCERS
14
from mmengine.registry import LOG_PROCESSORS as MMENGINE_LOG_PROCESSORS
15
16
17
18
19
from mmengine.registry import LOOPS as MMENGINE_LOOPS
from mmengine.registry import METRICS as MMENGINE_METRICS
from mmengine.registry import MODEL_WRAPPERS as MMENGINE_MODEL_WRAPPERS
from mmengine.registry import MODELS as MMENGINE_MODELS
from mmengine.registry import \
jshilong's avatar
jshilong committed
20
    OPTIM_WRAPPER_CONSTRUCTORS as MMENGINE_OPTIM_WRAPPER_CONSTRUCTORS
21
from mmengine.registry import OPTIM_WRAPPERS as MMENGINE_OPTIM_WRAPPERS
22
23
24
25
26
27
from mmengine.registry import OPTIMIZERS as MMENGINE_OPTIMIZERS
from mmengine.registry import PARAM_SCHEDULERS as MMENGINE_PARAM_SCHEDULERS
from mmengine.registry import \
    RUNNER_CONSTRUCTORS as MMENGINE_RUNNER_CONSTRUCTORS
from mmengine.registry import RUNNERS as MMENGINE_RUNNERS
from mmengine.registry import TASK_UTILS as MMENGINE_TASK_UTILS
28
from mmengine.registry import TRANSFORMS as MMENGINE_TRANSFORMS
29
30
31
32
from mmengine.registry import VISBACKENDS as MMENGINE_VISBACKENDS
from mmengine.registry import VISUALIZERS as MMENGINE_VISUALIZERS
from mmengine.registry import \
    WEIGHT_INITIALIZERS as MMENGINE_WEIGHT_INITIALIZERS
33
34
from mmengine.registry import Registry

35
# manage all kinds of runners like `EpochBasedRunner` and `IterBasedRunner`
36
37
RUNNERS = Registry(
    'runner', parent=MMENGINE_RUNNERS, locations=['mmdet3d.engine.runner'])
38
39
# manage runner constructors that define how to initialize runners
RUNNER_CONSTRUCTORS = Registry(
40
41
42
    'runner constructor',
    parent=MMENGINE_RUNNER_CONSTRUCTORS,
    locations=['mmdet3d.engine.runner'])
43
# manage all kinds of loops like `EpochBasedTrainLoop`
44
45
LOOPS = Registry(
    'loop', parent=MMENGINE_LOOPS, locations=['mmdet3d.engine.runner'])
46
# manage all kinds of hooks like `CheckpointHook`
47
48
HOOKS = Registry(
    'hook', parent=MMENGINE_HOOKS, locations=['mmdet3d.engine.hooks'])
49
50

# manage data-related modules
51
52
53
54
55
56
57
58
59
60
DATASETS = Registry(
    'dataset', parent=MMENGINE_DATASETS, locations=['mmdet3d.datasets'])
DATA_SAMPLERS = Registry(
    'data sampler',
    parent=MMENGINE_DATA_SAMPLERS,
    locations=['mmdet3d.datasets.samplers'])
TRANSFORMS = Registry(
    'transform',
    parent=MMENGINE_TRANSFORMS,
    locations=['mmdet3d.datasets.transforms'])
61
62

# mangage all kinds of modules inheriting `nn.Module`
63
64
MODELS = Registry(
    'model', parent=MMENGINE_MODELS, locations=['mmdet3d.models'])
65
# mangage all kinds of model wrappers like 'MMDistributedDataParallel'
66
67
68
69
MODEL_WRAPPERS = Registry(
    'model_wrapper',
    parent=MMENGINE_MODEL_WRAPPERS,
    locations=['mmdet3d.models'])
70
71
# mangage all kinds of weight initialization modules like `Uniform`
WEIGHT_INITIALIZERS = Registry(
72
73
74
    'weight initializer',
    parent=MMENGINE_WEIGHT_INITIALIZERS,
    locations=['mmdet3d.models'])
75
76

# mangage all kinds of optimizers like `SGD` and `Adam`
77
78
79
80
OPTIMIZERS = Registry(
    'optimizer',
    parent=MMENGINE_OPTIMIZERS,
    locations=['mmdet3d.engine.optimizers'])
81
# manage optimizer wrapper
82
83
84
85
OPTIM_WRAPPERS = Registry(
    'optim wrapper',
    parent=MMENGINE_OPTIM_WRAPPERS,
    locations=['mmdet3d.engine.optimizers'])
86
# manage constructors that customize the optimization hyperparameters.
jshilong's avatar
jshilong committed
87
88
OPTIM_WRAPPER_CONSTRUCTORS = Registry(
    'optimizer wrapper constructor',
89
90
    parent=MMENGINE_OPTIM_WRAPPER_CONSTRUCTORS,
    locations=['mmdet3d.engine.optimizers'])
91
92
# mangage all kinds of parameter schedulers like `MultiStepLR`
PARAM_SCHEDULERS = Registry(
93
94
95
    'parameter scheduler',
    parent=MMENGINE_PARAM_SCHEDULERS,
    locations=['mmdet3d.engine.schedulers'])
96
# manage all kinds of metrics
97
98
METRICS = Registry(
    'metric', parent=MMENGINE_METRICS, locations=['mmdet3d.evaluation'])
99
# manage evaluator
100
101
EVALUATOR = Registry(
    'evaluator', parent=MMENGINE_EVALUATOR, locations=['mmdet3d.evaluation'])
102
103

# manage task-specific modules like anchor generators and box coders
104
105
TASK_UTILS = Registry(
    'task util', parent=MMENGINE_TASK_UTILS, locations=['mmdet3d.models'])
106
107

# manage visualizer
108
109
110
111
VISUALIZERS = Registry(
    'visualizer',
    parent=MMENGINE_VISUALIZERS,
    locations=['mmdet3d.visualization'])
112
# manage visualizer backend
113
114
115
116
VISBACKENDS = Registry(
    'vis_backend',
    parent=MMENGINE_VISBACKENDS,
    locations=['mmdet3d.visualization'])
117
118

# manage logprocessor
119
120
121
122
123
LOG_PROCESSORS = Registry(
    'log_processor',
    parent=MMENGINE_LOG_PROCESSORS,
    # TODO: update the location when mmdet3d has its own log processor
    locations=['mmdet3d.engine'])
124
125

# manage inferencer
126
127
128
129
INFERENCERS = Registry(
    'inferencer',
    parent=MMENGINE_INFERENCERS,
    locations=['mmdet3d.api.inferencers'])