-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
37 lines (28 loc) · 1.13 KB
/
main.py
File metadata and controls
37 lines (28 loc) · 1.13 KB
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
import os
import yaml
import argparse
from utils.characters import Characters
from utils.renderer import Renderer
from model.GAN import GAN
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--render', '-r', help='Render character images', default=False, action='store_true')
parser.add_argument('--train', '-t', help='Train and/or test a model', default=False, action='store_true')
parser.add_argument('--generate', '-g', help='Generate a new font', default=False, action='store_true')
args = parser.parse_args()
if not os.path.exists('config.yaml'):
exit('Config file not found.')
with open('config.yaml') as f:
config = yaml.safe_load(f)
for section in ['general'] + [k for k, v in vars(args).items() if v]:
if section not in config.keys():
exit(f'Missing {section} config.')
chars = Characters(config['general'])
if args.render:
Renderer(config['render'], chars).start()
elif args.train:
GAN(config['train']).start()
elif args.generate:
exit('Not implemented.')
else:
parser.print_help()