Rockey ee5fbcff74 [Feature] add log collector (#1175)
* [Feature] add log collector

* Update .dev/log_collector/readme.md

Co-authored-by: Miao Zheng <76149310+MeowZheng@users.noreply.github.com>

* Update .dev/log_collector/example_config.py

Co-authored-by: Miao Zheng <76149310+MeowZheng@users.noreply.github.com>

* fix typo and so on

* modify readme

* fix some bugs and revise the readme.md

* more elegant

* Update .dev/log_collector/readme.md

Co-authored-by: Junjun2016 <hejunjun@sjtu.edu.cn>

Co-authored-by: Miao Zheng <76149310+MeowZheng@users.noreply.github.com>
Co-authored-by: Junjun2016 <hejunjun@sjtu.edu.cn>
2022-01-14 15:19:23 +08:00

21 lines
582 B
Python

# Copyright (c) OpenMMLab. All rights reserved.
# modified from https://github.dev/open-mmlab/mmcv
import os.path as osp
import sys
from importlib import import_module
def load_config(cfg_dir: str) -> dict:
assert cfg_dir.endswith('.py')
root_path, file_name = osp.split(cfg_dir)
temp_module = osp.splitext(file_name)[0]
sys.path.insert(0, root_path)
mod = import_module(temp_module)
sys.path.pop(0)
cfg_dict = {
k: v
for k, v in mod.__dict__.items() if not k.startswith('__')
}
del sys.modules[temp_module]
return cfg_dict