()
| 52 | |
| 53 | |
| 54 | def main(): |
| 55 | args = parse_args() |
| 56 | |
| 57 | if args.model_type is not None: |
| 58 | assert args.model_type in CONFIG_TEMPLATE_ZOO, 'model_type must be in [%s]' % ( |
| 59 | ', '.join(CONFIG_TEMPLATE_ZOO.keys())) |
| 60 | print('model_type=%s, config file will be replaced by %s' % |
| 61 | (args.model_type, CONFIG_TEMPLATE_ZOO[args.model_type])) |
| 62 | args.config = CONFIG_TEMPLATE_ZOO[args.model_type] |
| 63 | |
| 64 | print(args.config) |
| 65 | |
| 66 | if args.config.startswith('http'): |
| 67 | |
| 68 | r = requests.get(args.config) |
| 69 | # download config in current dir |
| 70 | tpath = args.config.split('/')[-1] |
| 71 | while not osp.exists(tpath): |
| 72 | try: |
| 73 | with open(tpath, 'wb') as code: |
| 74 | code.write(r.content) |
| 75 | except: |
| 76 | pass |
| 77 | |
| 78 | args.config = tpath |
| 79 | |
| 80 | cfg = mmcv_config_fromfile(args.config) |
| 81 | |
| 82 | if args.user_config_params is not None: |
| 83 | assert args.model_type is not None, 'model_type must be setted' |
| 84 | # rebuild config by user config params |
| 85 | cfg = rebuild_config(cfg, args.user_config_params) |
| 86 | |
| 87 | # dynamic adapt mmdet models |
| 88 | dynamic_adapt_for_mmlab(cfg) |
| 89 | |
| 90 | # check oss_config and init oss io |
| 91 | if cfg.get('oss_io_config', None) is not None: |
| 92 | io.access_oss(**cfg.oss_io_config) |
| 93 | |
| 94 | # init the logger before other steps |
| 95 | logger = get_root_logger(log_level=cfg.log_level) |
| 96 | |
| 97 | export(cfg, args.ckpt_path, args.export_path) |
| 98 | |
| 99 | |
| 100 | if __name__ == '__main__': |
no test coverage detected