"tools/imglab/git@developer.sourcefind.cn:OpenDAS/dlib.git" did not exist on "1cf740156d87b9d4a16078a390b09824ffb62955"
Commit 928aa884 authored by VVsssssk's avatar VVsssssk Committed by ChaimZhu
Browse files

[Fix]Fix train.py and registe all model

parent ccf028f7
# Copyright (c) OpenMMLab. All rights reserved.
import datetime
import os
import platform
import warnings
......@@ -58,7 +59,7 @@ def register_all_modules(init_default_scope: bool = True) -> None:
"""Register all modules in mmdet3d into the registries.
Args:
init_default_scope (bool): Whether initialize the mmdet3d default scope.
init_default_scope (bool): Whether initialize the mmdet default scope.
When `init_default_scope=True`, the global default scope will be
set to `mmdet3d`, and all registries will build modules from mmdet3d's
registry node. To understand more about the registry, please refer
......@@ -67,7 +68,23 @@ def register_all_modules(init_default_scope: bool = True) -> None:
""" # noqa
import mmdet3d.core # noqa: F401,F403
import mmdet3d.datasets # noqa: F401,F403
import mmdet3d.metrics # noqa: F401,F403
import mmdet3d.models # noqa: F401,F403
import mmdet3d.ops # noqa: F401,F403
import mmdet3d.scheduler # noqa: F401,F403
if init_default_scope:
DefaultScope.get_instance('mmdet3d', scope_name='mmdet3d')
never_created = DefaultScope.get_current_instance() is None \
or not DefaultScope.check_instance_created('mmdet3d')
if never_created:
DefaultScope.get_instance('mmdet3d', scope_name='mmdet3d')
return
current_scope = DefaultScope.get_current_instance()
if current_scope.scope_name != 'mmdet3d':
warnings.warn('The current default scope '
f'"{current_scope.scope_name}" is not "mmdet3d", '
'`register_all_modules` will force the current'
'default scope to be "mmdet3d". If this is not '
'expected, please set `init_default_scope=False`.')
# avoid name conflict
new_instance_name = f'mmdet3d-{datetime.datetime.now()}'
DefaultScope.get_instance(new_instance_name, scope_name='mmdet3d')
# Copyright (c) OpenMMLab. All rights reserved.
from __future__ import division
import argparse
import os
from os import path as osp
import os.path as osp
from mmcv import Config, DictAction
from mmengine import Runner
from mmengine.config import Config, DictAction
from mmengine.runner import Runner
from mmdet3d.utils import register_all_modules
def parse_args():
parser = argparse.ArgumentParser(description='Train a detector')
parser = argparse.ArgumentParser(description='Train a 3D detector')
parser.add_argument('config', help='train config file path')
parser.add_argument('--work-dir', help='the dir to save logs and models')
parser.add_argument(
......@@ -33,21 +32,19 @@ def parse_args():
args = parser.parse_args()
if 'LOCAL_RANK' not in os.environ:
os.environ['LOCAL_RANK'] = str(args.local_rank)
return args
def main():
args = parse_args()
# register all modules in mmdet3d into the registries
# do not init the default scope here because it will be init in the runner
register_all_modules(init_default_scope=False)
# load config
cfg = Config.fromfile(args.config)
cfg.launcher = args.launcher
if args.cfg_options is not None:
cfg.merge_from_dict(args.cfg_options)
# work_dir is determined in this priority: CLI > segment in file > filename
if args.work_dir is not None:
# update configs according to CLI args if args.work_dir is not None
......@@ -56,10 +53,8 @@ def main():
# use config filename as default work_dir if cfg.work_dir is None
cfg.work_dir = osp.join('./work_dirs',
osp.splitext(osp.basename(args.config))[0])
# build the runner from config
runner = Runner.from_cfg(cfg)
# start training
runner.train()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment