print_config.py 643 B

123456789101112131415161718192021222324252627
  1. # Copyright (c) OpenMMLab. All rights reserved.
  2. import argparse
  3. from mmengine import Config, DictAction
  4. def parse_args():
  5. parser = argparse.ArgumentParser(description='Print the whole config')
  6. parser.add_argument('config', help='config file path')
  7. parser.add_argument(
  8. '--options', nargs='+', action=DictAction, help='arguments in dict')
  9. args = parser.parse_args()
  10. return args
  11. def main():
  12. args = parse_args()
  13. cfg = Config.fromfile(args.config)
  14. if args.options is not None:
  15. cfg.merge_from_dict(args.options)
  16. print(f'Config:\n{cfg.pretty_text}')
  17. if __name__ == '__main__':
  18. main()