|
@@ -24,16 +24,31 @@ class myargparse(argparse.ArgumentParser):
|
|
type=str,
|
|
type=str,
|
|
metavar='FILE',
|
|
metavar='FILE',
|
|
help='YAML config file specifying default arguments')
|
|
help='YAML config file specifying default arguments')
|
|
-
|
|
|
|
|
|
+ self.add_argument(
|
|
|
|
+ '-i',
|
|
|
|
+ '--input_file',
|
|
|
|
+ type=str,
|
|
|
|
+ metavar='FILE',
|
|
|
|
+ help='训练预测数据路径')
|
|
|
|
+ self.add_argument(
|
|
|
|
+ '-m',
|
|
|
|
+ '--model_name',
|
|
|
|
+ type=str,
|
|
|
|
+ metavar='FILE',
|
|
|
|
+ help='模型选择')
|
|
|
|
|
|
def _parse_args_and_yaml(self):
|
|
def _parse_args_and_yaml(self):
|
|
- given_configs, remaining = self.parse_known_args()
|
|
|
|
|
|
+ base_parser = argparse.ArgumentParser(add_help=False)
|
|
|
|
+ base_parser.add_argument('-c', '--config_yaml', default='config.yml', type=str)
|
|
|
|
+ given_configs, remaining = base_parser.parse_known_args()
|
|
current_path = os.path.dirname(__file__)
|
|
current_path = os.path.dirname(__file__)
|
|
if given_configs.config_yaml:
|
|
if given_configs.config_yaml:
|
|
- with open(current_path + '/' + given_configs.config_yaml, 'r', encoding='utf-8') as f:
|
|
|
|
|
|
+ config_path = os.path.join(current_path, given_configs.config_yaml)
|
|
|
|
+ with open(config_path, 'r', encoding='utf-8') as f:
|
|
cfg = yaml.safe_load(f)
|
|
cfg = yaml.safe_load(f)
|
|
self.set_defaults(**cfg)
|
|
self.set_defaults(**cfg)
|
|
# defaults will have been overridden if config file specified.
|
|
# defaults will have been overridden if config file specified.
|
|
|
|
+ # opt = self.parse_args(remaining)
|
|
opt = self.parse_args(remaining)
|
|
opt = self.parse_args(remaining)
|
|
# Cache the args as a text string to save them in the output dir later
|
|
# Cache the args as a text string to save them in the output dir later
|
|
opt_text = yaml.safe_dump(opt.__dict__, default_flow_style=False)
|
|
opt_text = yaml.safe_dump(opt.__dict__, default_flow_style=False)
|