forked from open-mmlab/mmdetection
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support open-mmlab#6915: seperate function in tools/utils.py, support…
… test.py and browse_dataset.py
- Loading branch information
Showing
4 changed files
with
44 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
import mmcv | ||
from mmcv.utils import print_log | ||
|
||
def update_data_root(cfg, data_root_n, logger=None): | ||
"""updata data root | ||
Args: | ||
cfg (mmcv.Config): model config | ||
data_root_n (str): new data root | ||
logger (logging.Logger | str | None): the way to print msg | ||
""" | ||
assert isinstance(cfg, mmcv.Config), \ | ||
f"cfg got wrong type: {type(cfg)}, expected mmcv.Config" | ||
|
||
def update(cfg, str_o, str_n): | ||
for k, v in cfg.items(): | ||
if isinstance(v, mmcv.ConfigDict): | ||
update(cfg[k], str_o, str_n) | ||
if isinstance(v, str) and str_o in v: | ||
cfg[k] = v.replace(str_o, str_n) | ||
|
||
update(cfg.data, cfg.data_root, data_root_n) | ||
cfg.data_root = data_root_n | ||
print_log( | ||
f"Set data root to {data_root_n} according to MMDET_DATASETS", | ||
logger=logger) |