MCPcopy Index your code
hub / github.com/OpenDriveLab/DriveAdapter / main

Function main

open_loop_training/train.py:114–244  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

112
113
114def main():
115 args = parse_args()
116 cfg = Config.fromfile(args.config)
117 if args.cfg_options is not None:
118 cfg.merge_from_dict(args.cfg_options)
119 # import modules from string list.
120 if cfg.get('custom_imports', None):
121 from mmcv.utils import import_modules_from_strings
122 import_modules_from_strings(**cfg['custom_imports'])
123
124 # import modules from plguin/xx, registry will be updated
125 if hasattr(cfg, 'plugin'):
126 if cfg.plugin:
127 import importlib
128 if hasattr(cfg, 'plugin_dir'):
129 plugin_dir = cfg.plugin_dir
130 _module_dir = os.path.dirname(plugin_dir)
131 _module_dir = _module_dir.split('/')
132 _module_path = _module_dir[0]
133
134 for m in _module_dir[1:]:
135 _module_path = _module_path + '.' + m
136 print(_module_path)
137 plg_lib = importlib.import_module(_module_path)
138 else:
139 # import dir is the dirpath for the config file
140 _module_dir = os.path.dirname(args.config)
141 _module_dir = _module_dir.split('/')
142 _module_path = _module_dir[0]
143 for m in _module_dir[1:]:
144 _module_path = _module_path + '.' + m
145 print(_module_path)
146 plg_lib = importlib.import_module(_module_path)
147
148 from code.apis.train import custom_train_model
149 # set cudnn_benchmark
150 if cfg.get('cudnn_benchmark', False):
151 torch.backends.cudnn.benchmark = True
152
153 # work_dir is determined in this priority: CLI > segment in file > filename
154 if args.work_dir is not None:
155 # update configs according to CLI args if args.work_dir is not None
156 cfg.work_dir = args.work_dir
157 elif cfg.get('work_dir', None) is None:
158 # use config filename as default work_dir if cfg.work_dir is None
159 cfg.work_dir = osp.join('./work_dirs',
160 osp.splitext(osp.basename(args.config))[0])
161 # if args.resume_from is not None:
162 if args.resume_from is not None and osp.isfile(args.resume_from):
163 cfg.resume_from = args.resume_from
164 if args.load_from is not None and osp.isfile(args.load_from):
165 cfg.load_from = args.load_from
166 if args.gpu_ids is not None:
167 cfg.gpu_ids = args.gpu_ids
168 else:
169 cfg.gpu_ids = range(1) if args.gpus is None else range(args.gpus)
170 # init distributed env first, since logger depends on the dist info.
171 if args.launcher == 'none':

Callers 1

train.pyFile · 0.70

Calls 4

custom_train_modelFunction · 0.90
parse_argsFunction · 0.85
getMethod · 0.80
init_weightsMethod · 0.45

Tested by

no test coverage detected