|
|
@@ -109,6 +109,8 @@ class ProjectPathAction(argparse.Action): |
|
|
option_string (str): Optional string for specific argument name. Default: None. |
|
|
option_string (str): Optional string for specific argument name. Default: None. |
|
|
""" |
|
|
""" |
|
|
outfile_dir = FileDirAction.check_path(parser, values, option_string) |
|
|
outfile_dir = FileDirAction.check_path(parser, values, option_string) |
|
|
|
|
|
if not os.path.exists(outfile_dir): |
|
|
|
|
|
parser.error(f'{option_string} {outfile_dir} not exists') |
|
|
if not os.path.isdir(outfile_dir): |
|
|
if not os.path.isdir(outfile_dir): |
|
|
parser.error(f'{option_string} [{outfile_dir}] should be a directory.') |
|
|
parser.error(f'{option_string} [{outfile_dir}] should be a directory.') |
|
|
|
|
|
|
|
|
@@ -138,6 +140,32 @@ class InFileAction(argparse.Action): |
|
|
setattr(namespace, self.dest, outfile_dir) |
|
|
setattr(namespace, self.dest, outfile_dir) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ModelFileAction(argparse.Action): |
|
|
|
|
|
"""Model File action class definition.""" |
|
|
|
|
|
|
|
|
|
|
|
def __call__(self, parser, namespace, values, option_string=None): |
|
|
|
|
|
""" |
|
|
|
|
|
Inherited __call__ method from argparse.Action. |
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
|
|
parser (ArgumentParser): Passed-in argument parser. |
|
|
|
|
|
namespace (Namespace): Namespace object to hold arguments. |
|
|
|
|
|
values (object): Argument values with type depending on argument definition. |
|
|
|
|
|
option_string (str): Optional string for specific argument name. Default: None. |
|
|
|
|
|
""" |
|
|
|
|
|
outfile_dir = FileDirAction.check_path(parser, values, option_string) |
|
|
|
|
|
if not os.path.exists(outfile_dir): |
|
|
|
|
|
parser.error(f'{option_string} {outfile_dir} not exists') |
|
|
|
|
|
|
|
|
|
|
|
if not os.path.isfile(outfile_dir): |
|
|
|
|
|
parser.error(f'{option_string} {outfile_dir} is not a file') |
|
|
|
|
|
|
|
|
|
|
|
if not outfile_dir.endswith('.pth'): |
|
|
|
|
|
parser.error(f"{option_string} {outfile_dir} should be a Pytorch model, ending with '.pth'.") |
|
|
|
|
|
|
|
|
|
|
|
setattr(namespace, self.dest, outfile_dir) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class LogFileAction(argparse.Action): |
|
|
class LogFileAction(argparse.Action): |
|
|
"""Log file action class definition.""" |
|
|
"""Log file action class definition.""" |
|
|
|
|
|
|
|
|
@@ -208,7 +236,7 @@ def cli_entry(): |
|
|
parser.add_argument( |
|
|
parser.add_argument( |
|
|
'--model_file', |
|
|
'--model_file', |
|
|
type=str, |
|
|
type=str, |
|
|
action=InFileAction, |
|
|
|
|
|
|
|
|
action=ModelFileAction, |
|
|
required=False, |
|
|
required=False, |
|
|
help=""" |
|
|
help=""" |
|
|
Pytorch .pth model file path ot use graph |
|
|
Pytorch .pth model file path ot use graph |
|
|
|