Skip to content

Commit

Permalink
Fix open-mmlab#6915: Support to set data root through commands
Browse files Browse the repository at this point in the history
  • Loading branch information
CCODING04 committed Mar 15, 2022
1 parent 70f6d9c commit 1418390
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tools/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,17 @@ def main():
args = parse_args()

cfg = Config.fromfile(args.config)

# update data root according to environment variable
if os.environ.get('MMDET_DATASETS', None) is not None:
def update_data_root(cfg, str_o, str_n):
for k, v in cfg.items():
if isinstance(v, mmcv.ConfigDict):
update_data_root(cfg[k], str_o, str_n)
if isinstance(v, str):
cfg[k] = v.replace(str_o, str_n)
update_data_root(cfg, cfg.data_root, os.environ['MMDET_DATASETS'])

if args.cfg_options is not None:
cfg.merge_from_dict(args.cfg_options)

Expand Down

0 comments on commit 1418390

Please sign in to comment.