Skip to content

Commit ef798d4

Browse files
Merge 7e38aa6 into 60d848b
2 parents 60d848b + 7e38aa6 commit ef798d4

19 files changed

+84
-65
lines changed

demo/mono_det_demo.py

-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from mmdet3d.apis import inference_mono_3d_detector, init_model
77
from mmdet3d.registry import VISUALIZERS
8-
from mmdet3d.utils import register_all_modules
98

109

1110
def parse_args():
@@ -38,9 +37,6 @@ def parse_args():
3837

3938

4039
def main(args):
41-
# register all modules in mmdet3d into the registries
42-
register_all_modules()
43-
4440
# build the model from a config file and a checkpoint file
4541
model = init_model(args.config, args.checkpoint, device=args.device)
4642

demo/multi_modality_demo.py

-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from mmdet3d.apis import inference_multi_modality_detector, init_model
77
from mmdet3d.registry import VISUALIZERS
8-
from mmdet3d.utils import register_all_modules
98

109

1110
def parse_args():
@@ -39,9 +38,6 @@ def parse_args():
3938

4039

4140
def main(args):
42-
# register all modules in mmdet3d into the registries
43-
register_all_modules()
44-
4541
# build the model from a config file and a checkpoint file
4642
model = init_model(args.config, args.checkpoint, device=args.device)
4743

demo/pcd_demo.py

-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
from mmdet3d.apis import inference_detector, init_model
55
from mmdet3d.registry import VISUALIZERS
6-
from mmdet3d.utils import register_all_modules
76

87

98
def parse_args():
@@ -30,9 +29,6 @@ def parse_args():
3029

3130

3231
def main(args):
33-
# register all modules in mmdet3d into the registries
34-
register_all_modules()
35-
3632
# TODO: Support inference of point cloud numpy file.
3733
# build the model from a config file and a checkpoint file
3834
model = init_model(args.config, args.checkpoint, device=args.device)

demo/pcd_seg_demo.py

-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
from mmdet3d.apis import inference_segmentor, init_model
55
from mmdet3d.registry import VISUALIZERS
6-
from mmdet3d.utils import register_all_modules
76

87

98
def parse_args():
@@ -28,9 +27,6 @@ def parse_args():
2827

2928

3029
def main(args):
31-
# register all modules in mmdet3d into the registries
32-
register_all_modules()
33-
3430
# build the model from a config file and a checkpoint file
3531
model = init_model(args.config, args.checkpoint, device=args.device)
3632

docs/en/get_started.md

-2
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,7 @@ Case b: If you install MMDetection3D with MIM, open your python interpreter and
169169

170170
```python
171171
from mmdet3d.apis import init_model, inference_detector
172-
from mmdet3d.utils import register_all_modules
173172

174-
register_all_modules()
175173
config_file = 'pointpillars_hv_secfpn_8xb6-160e_kitti-3d-car.py'
176174
checkpoint_file = 'hv_pointpillars_secfpn_6x8_160e_kitti-3d-car_20220331_134606-d42d15ed.pth'
177175
model = init_model(config_file, checkpoint_file)

docs/en/notes/faq.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ We list some potential troubles encountered by users and developers, along with
1010

1111
| MMDetection3D version | MMEngine version | MMCV version | MMDetection version |
1212
| --------------------- | :----------------------: | :---------------------: | :----------------------: |
13-
| dev-1.x | mmengine>=0.1.0, \<1.0.0 | mmcv>=2.0.0rc0, \<2.1.0 | mmdet>=3.0.0rc0, \<3.1.0 |
13+
| dev-1.x | mmengine>=0.4.0, \<1.0.0 | mmcv>=2.0.0rc4, \<2.1.0 | mmdet>=3.0.0rc0, \<3.1.0 |
1414
| v1.1.0rc3 | mmengine>=0.1.0, \<1.0.0 | mmcv>=2.0.0rc0, \<2.1.0 | mmdet>=3.0.0rc0, \<3.1.0 |
1515
| v1.1.0rc2 | mmengine>=0.1.0, \<1.0.0 | mmcv>=2.0.0rc0, \<2.1.0 | mmdet>=3.0.0rc0, \<3.1.0 |
1616
| v1.1.0rc1 | mmengine>=0.1.0, \<1.0.0 | mmcv>=2.0.0rc0, \<2.1.0 | mmdet>=3.0.0rc0, \<3.1.0 |

docs/zh_cn/get_started.md

-2
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,7 @@ to_ply('./test.obj', './test.ply', 'obj')
166166

167167
```python
168168
from mmdet3d.apis import init_model, inference_detector
169-
from mmdet3d.utils import register_all_modules
170169

171-
register_all_modules()
172170
config_file = 'pointpillars_hv_secfpn_8xb6-160e_kitti-3d-car.py'
173171
checkpoint_file = 'hv_pointpillars_secfpn_6x8_160e_kitti-3d-car_20220331_134606-d42d15ed.pth'
174172
model = init_model(config_file, checkpoint_file)

docs/zh_cn/notes/faq.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
| MMDetection3D 版本 | MMEngine 版本 | MMCV 版本 | MMDetection 版本 |
1212
| ------------------ | :----------------------: | :---------------------: | :----------------------: |
13-
| dev-1.x | mmengine>=0.1.0, \<1.0.0 | mmcv>=2.0.0rc0, \<2.1.0 | mmdet>=3.0.0rc0, \<3.1.0 |
13+
| dev-1.x | mmengine>=0.4.0, \<1.0.0 | mmcv>=2.0.0rc4, \<2.1.0 | mmdet>=3.0.0rc0, \<3.1.0 |
14+
| v1.1.0rc3 | mmengine>=0.1.0, \<1.0.0 | mmcv>=2.0.0rc0, \<2.1.0 | mmdet>=3.0.0rc0, \<3.1.0 |
1415
| v1.1.0rc2 | mmengine>=0.1.0, \<1.0.0 | mmcv>=2.0.0rc0, \<2.1.0 | mmdet>=3.0.0rc0, \<3.1.0 |
1516
| v1.1.0rc1 | mmengine>=0.1.0, \<1.0.0 | mmcv>=2.0.0rc0, \<2.1.0 | mmdet>=3.0.0rc0, \<3.1.0 |
1617
| v1.1.0rc0 | mmengine>=0.1.0, \<1.0.0 | mmcv>=2.0.0rc0, \<2.1.0 | mmdet>=3.0.0rc0, \<3.1.0 |

mmdet3d/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
mmcv_maximum_version = '2.1.0'
1111
mmcv_version = digit_version(mmcv.__version__)
1212

13-
mmengine_minimum_version = '0.1.0'
13+
mmengine_minimum_version = '0.4.0'
1414
mmengine_maximum_version = '1.0.0'
1515
mmengine_version = digit_version(mmengine.__version__)
1616

mmdet3d/apis/inference.py

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import torch.nn as nn
1212
from mmengine.config import Config
1313
from mmengine.dataset import Compose, pseudo_collate
14+
from mmengine.registry import init_default_scope
1415
from mmengine.runner import load_checkpoint
1516

1617
from mmdet3d.registry import MODELS
@@ -63,6 +64,7 @@ def init_model(config: Union[str, Path, Config],
6364

6465
convert_SyncBN(config.model)
6566
config.model.train_cfg = None
67+
init_default_scope(config.get('default_scope', 'mmdet3d'))
6668
model = MODELS.build(config.model)
6769

6870
if checkpoint is not None:

mmdet3d/apis/inferencers/base_det3d_inferencer.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
from mmengine.fileio import (get_file_backend, isdir, join_path,
88
list_dir_or_file)
99
from mmengine.infer.infer import BaseInferencer, ModelType
10+
from mmengine.registry import init_default_scope
1011
from mmengine.runner import load_checkpoint
1112
from mmengine.structures import InstanceData
1213
from mmengine.visualization import Visualizer
1314

1415
from mmdet3d.registry import MODELS
15-
from mmdet3d.utils import ConfigType, register_all_modules
16+
from mmdet3d.utils import ConfigType
1617

1718
InstanceList = List[InstanceData]
1819
InputType = Union[str, np.ndarray]
@@ -60,7 +61,7 @@ def __init__(self,
6061
scope: Optional[str] = 'mmdet3d',
6162
palette: str = 'none') -> None:
6263
self.palette = palette
63-
register_all_modules()
64+
init_default_scope(scope)
6465
super().__init__(
6566
model=model, weights=weights, device=device, scope=scope)
6667

mmdet3d/apis/inferencers/lidar_det3d_inferencer.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from mmengine.structures import InstanceData
1010

1111
from mmdet3d.registry import INFERENCERS
12-
from mmdet3d.utils import ConfigType, register_all_modules
12+
from mmdet3d.utils import ConfigType
1313
from .base_det3d_inferencer import BaseDet3DInferencer
1414

1515
InstanceList = List[InstanceData]
@@ -62,7 +62,6 @@ def __init__(self,
6262
# naming of the output results
6363
self.num_visualized_frames = 0
6464
self.palette = palette
65-
register_all_modules()
6665
super().__init__(
6766
model=model, weights=weights, device=device, scope=scope)
6867

mmdet3d/registry.py

+64-21
Original file line numberDiff line numberDiff line change
@@ -33,54 +33,97 @@
3333
from mmengine.registry import Registry
3434

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

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

5062
# mangage all kinds of modules inheriting `nn.Module`
51-
MODELS = Registry('model', parent=MMENGINE_MODELS)
63+
MODELS = Registry(
64+
'model', parent=MMENGINE_MODELS, locations=['mmdet3d.models'])
5265
# mangage all kinds of model wrappers like 'MMDistributedDataParallel'
53-
MODEL_WRAPPERS = Registry('model_wrapper', parent=MMENGINE_MODEL_WRAPPERS)
66+
MODEL_WRAPPERS = Registry(
67+
'model_wrapper',
68+
parent=MMENGINE_MODEL_WRAPPERS,
69+
locations=['mmdet3d.models'])
5470
# mangage all kinds of weight initialization modules like `Uniform`
5571
WEIGHT_INITIALIZERS = Registry(
56-
'weight initializer', parent=MMENGINE_WEIGHT_INITIALIZERS)
72+
'weight initializer',
73+
parent=MMENGINE_WEIGHT_INITIALIZERS,
74+
locations=['mmdet3d.models'])
5775

5876
# mangage all kinds of optimizers like `SGD` and `Adam`
59-
OPTIMIZERS = Registry('optimizer', parent=MMENGINE_OPTIMIZERS)
77+
OPTIMIZERS = Registry(
78+
'optimizer',
79+
parent=MMENGINE_OPTIMIZERS,
80+
locations=['mmdet3d.engine.optimizers'])
6081
# manage optimizer wrapper
61-
OPTIM_WRAPPERS = Registry('optim wrapper', parent=MMENGINE_OPTIM_WRAPPERS)
82+
OPTIM_WRAPPERS = Registry(
83+
'optim wrapper',
84+
parent=MMENGINE_OPTIM_WRAPPERS,
85+
locations=['mmdet3d.engine.optimizers'])
6286
# manage constructors that customize the optimization hyperparameters.
6387
OPTIM_WRAPPER_CONSTRUCTORS = Registry(
6488
'optimizer wrapper constructor',
65-
parent=MMENGINE_OPTIM_WRAPPER_CONSTRUCTORS)
89+
parent=MMENGINE_OPTIM_WRAPPER_CONSTRUCTORS,
90+
locations=['mmdet3d.engine.optimizers'])
6691
# mangage all kinds of parameter schedulers like `MultiStepLR`
6792
PARAM_SCHEDULERS = Registry(
68-
'parameter scheduler', parent=MMENGINE_PARAM_SCHEDULERS)
93+
'parameter scheduler',
94+
parent=MMENGINE_PARAM_SCHEDULERS,
95+
locations=['mmdet3d.engine.schedulers'])
6996
# manage all kinds of metrics
70-
METRICS = Registry('metric', parent=MMENGINE_METRICS)
97+
METRICS = Registry(
98+
'metric', parent=MMENGINE_METRICS, locations=['mmdet3d.evaluation'])
7199
# manage evaluator
72-
EVALUATOR = Registry('evaluator', parent=MMENGINE_EVALUATOR)
100+
EVALUATOR = Registry(
101+
'evaluator', parent=MMENGINE_EVALUATOR, locations=['mmdet3d.evaluation'])
73102

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

77107
# manage visualizer
78-
VISUALIZERS = Registry('visualizer', parent=MMENGINE_VISUALIZERS)
108+
VISUALIZERS = Registry(
109+
'visualizer',
110+
parent=MMENGINE_VISUALIZERS,
111+
locations=['mmdet3d.visualization'])
79112
# manage visualizer backend
80-
VISBACKENDS = Registry('vis_backend', parent=MMENGINE_VISBACKENDS)
113+
VISBACKENDS = Registry(
114+
'vis_backend',
115+
parent=MMENGINE_VISBACKENDS,
116+
locations=['mmdet3d.visualization'])
81117

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

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

requirements/mminstall.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
mmcv>=2.0.0rc0,<2.1.0
1+
mmcv>=2.0.0rc4,<2.1.0
22
mmdet>=3.0.0rc0,<3.1.0
3-
mmengine>=0.1.0,<1.0.0
3+
mmengine>=0.4.0,<1.0.0

tests/test_datasets/test_transforms/test_transforms_3d.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def test_transform(self):
216216
transform = PolarMix(instance_classes=[1.0, 2.0])
217217

218218
transform = PolarMix(
219-
instance_classes=[1, 2],
219+
instance_classes=[15, 16, 17],
220220
swap_ratio=1.0,
221221
pre_transform=self.pre_transform)
222222
results = transform.transform(copy.deepcopy(self.results))

tools/analysis_tools/get_flops.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
import torch
55
from mmengine import Config, DictAction
6+
from mmengine.registry import init_default_scope
67

78
from mmdet3d.registry import MODELS
8-
from mmdet3d.utils import register_all_modules
99

1010
try:
1111
from mmcv.cnn import get_model_complexity_info
@@ -43,7 +43,6 @@ def parse_args():
4343

4444

4545
def main():
46-
register_all_modules()
4746
args = parse_args()
4847

4948
if args.modality == 'point':
@@ -64,6 +63,7 @@ def main():
6463
cfg = Config.fromfile(args.config)
6564
if args.cfg_options is not None:
6665
cfg.merge_from_dict(args.cfg_options)
66+
init_default_scope(cfg.get('default_scope', 'mmdet3d'))
6767

6868
model = MODELS.build(cfg.model)
6969
if torch.cuda.is_available():

tools/misc/browse_dataset.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
from os import path as osp
44

55
from mmengine.config import Config, DictAction
6+
from mmengine.registry import init_default_scope
67
from mmengine.utils import ProgressBar, mkdir_or_exist
78

89
from mmdet3d.registry import DATASETS, VISUALIZERS
9-
from mmdet3d.utils import register_all_modules, replace_ceph_backend
10+
from mmdet3d.utils import replace_ceph_backend
1011

1112

1213
def parse_args():
@@ -99,8 +100,7 @@ def main():
99100
if args.ceph:
100101
cfg = replace_ceph_backend(cfg)
101102

102-
# register all modules in mmdet3d into the registries
103-
register_all_modules()
103+
init_default_scope(cfg.get('default_scope', 'mmdet3d'))
104104

105105
try:
106106
dataset = DATASETS.build(

tools/test.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from mmengine.registry import RUNNERS
88
from mmengine.runner import Runner
99

10-
from mmdet3d.utils import register_all_modules, replace_ceph_backend
10+
from mmdet3d.utils import replace_ceph_backend
1111

1212

1313
# TODO: support fuse_conv_bn and format_only
@@ -84,10 +84,6 @@ def trigger_visualization_hook(cfg, args):
8484
def main():
8585
args = parse_args()
8686

87-
# register all modules in mmdet3d into the registries
88-
# do not init the default scope here because it will be init in the runner
89-
register_all_modules(init_default_scope=False)
90-
9187
# load config
9288
cfg = Config.fromfile(args.config)
9389

tools/train.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from mmengine.registry import RUNNERS
1010
from mmengine.runner import Runner
1111

12-
from mmdet3d.utils import register_all_modules, replace_ceph_backend
12+
from mmdet3d.utils import replace_ceph_backend
1313

1414

1515
def parse_args():
@@ -59,9 +59,6 @@ def parse_args():
5959

6060
def main():
6161
args = parse_args()
62-
# register all modules in mmdet3d into the registries
63-
# do not init the default scope here because it will be init in the runner
64-
register_all_modules(init_default_scope=False)
6562

6663
# load config
6764
cfg = Config.fromfile(args.config)

0 commit comments

Comments
 (0)