-
Notifications
You must be signed in to change notification settings - Fork 14
/
run.py
49 lines (37 loc) · 1.33 KB
/
run.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
46
47
48
49
import argparse
from gans.datasets import dataset_factory
from gans.datasets import problem_type
from gans.models import model_factories
from gans.utils import config
from gans.utils import logging
logger = logging.get_logger(__name__)
def run_experiment(input_args):
problem_type = input_args.problem_type
logger.info(f'Starting pipeline for {problem_type}...')
gan_type = problem_type.split('_')[0]
problem_params = config.read_config(problem_type)
logger.info(f'Loaded parameters: \n {problem_params}')
dataset = dataset_factory.get_dataset(problem_params, problem_type)
logger.info(f'Loaded dataset: {dataset}')
gan_model = model_factories.gan_model_factory(problem_params, gan_type, input_args)
logger.info(f'Built GAN model: {gan_model}')
logger.info('Model training...')
gan_model.fit(dataset)
logger.info('Training finished.')
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
'--problem_type',
required=True,
help='The problem type',
choices=problem_type.dataset_type_values(),
)
parser.add_argument(
'-continue_training',
action='store_true',
help='If set the training process will be continued',
)
args = parser.parse_args()
run_experiment(args)
if __name__ == '__main__':
main()