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
EighteenSprings authored and CCODING04 committed Mar 15, 2022
1 parent 70f6d9c commit c871682
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tools/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import copy
import os
import os.path as osp
import string
import time
import warnings

Expand Down Expand Up @@ -98,6 +99,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 c871682

Please sign in to comment.