-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtrain.py
45 lines (38 loc) · 1.37 KB
/
train.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# import sys
import argparse
import runpy
from methods.utils import get_root_dir
# def parse_args_any(args):
# pos = []
# named = {}
# key = None
# for arg in args:
# if key:
# if arg.startswith('--'):
# named[key] = True
# key = arg[2:]
# else:
# named[key] = arg
# key = None
# elif arg.startswith('--'):
# key = arg[2:]
# else:
# pos.append(arg)
# if key:
# named[key] = True
# return (pos, named)
parser = argparse.ArgumentParser()
parser.add_argument("--method", default='unet_gan', type=str, help="name of a method.")
args = parser.parse_args()
if __name__ == '__main__':
if args.method == 'unet_gan':
runpy.run_path(path_name=str(get_root_dir().joinpath('methods', 'unet_gan', 'unet_gan.py')))
elif args.method == 'ldm_stage1':
runpy.run_path(path_name=str(get_root_dir().joinpath('methods', 'ldm', 'stage1.py')))
elif args.method == 'ldm_stage2':
runpy.run_path(path_name=str(get_root_dir().joinpath('methods', 'ldm', 'stage2.py')))
elif args.method == 'ldm':
runpy.run_path(path_name=str(get_root_dir().joinpath('methods', 'ldm', 'stage1.py')))
runpy.run_path(path_name=str(get_root_dir().joinpath('methods', 'ldm', 'stage2.py')))
else:
raise ValueError