forked from Kid-Liet/Reg-GAN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
train.py
41 lines (30 loc) · 1.04 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
#!/usr/bin/python3
import argparse
import os
from trainer import Cyc_Trainer,Nice_Trainer,P2p_Trainer,Munit_Trainer,Unit_Trainer
import yaml
os.environ["CUDA_VISIBLE_DEVICES"] = "2"
def get_config(config):
with open(config, 'r') as stream:
return yaml.load(stream)
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--config', type=str, default='Yaml/CycleGan.yaml', help='Path to the config file.')
opts = parser.parse_args()
config = get_config(opts.config)
if config['name'] == 'CycleGan':
trainer = Cyc_Trainer(config)
elif config['name'] == 'Munit':
trainer = Munit_Trainer(config)
elif config['name'] == 'Unit':
trainer = Unit_Trainer(config)
elif config['name'] == 'NiceGAN':
trainer = Nice_Trainer(config)
elif config['name'] == 'U-gat':
trainer = Ugat_Trainer(config)
elif config['name'] == 'P2p':
trainer = P2p_Trainer(config)
trainer.train()
###################################
if __name__ == '__main__':
main()