mirror of
https://github.com/open-mmlab/mmocr.git
synced 2025-06-03 21:54:47 +08:00
[Feature] Add print_config.py to the tools (#1547)
* add print_config.py to the tools * fix bugs
This commit is contained in:
parent
3433c8cba4
commit
29107ef81d
36
tools/analysis_tools/print_config.py
Normal file
36
tools/analysis_tools/print_config.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# Copyright (c) OpenMMLab. All rights reserved.
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
from mmengine import Config, DictAction
|
||||||
|
|
||||||
|
|
||||||
|
def parse_args():
|
||||||
|
parser = argparse.ArgumentParser(description='Print the whole config')
|
||||||
|
parser.add_argument('config', help='config file path')
|
||||||
|
parser.add_argument(
|
||||||
|
'--cfg-options',
|
||||||
|
nargs='+',
|
||||||
|
action=DictAction,
|
||||||
|
help='override some settings in the used config, the key-value pair '
|
||||||
|
'in xxx=yyy format will be merged into config file. If the value to '
|
||||||
|
'be overwritten is a list, it should be like key="[a,b]" or key=a,b '
|
||||||
|
'It also allows nested list/tuple values, e.g. key="[(a,b),(c,d)]" '
|
||||||
|
'Note that the quotation marks are necessary and that no white space '
|
||||||
|
'is allowed.')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
return args
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
args = parse_args()
|
||||||
|
|
||||||
|
cfg = Config.fromfile(args.config)
|
||||||
|
|
||||||
|
if args.cfg_options is not None:
|
||||||
|
cfg.merge_from_dict(args.cfg_options)
|
||||||
|
print(f'Config:\n{cfg.pretty_text}')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
Loading…
x
Reference in New Issue
Block a user