-
Notifications
You must be signed in to change notification settings - Fork 226
/
main.py
41 lines (33 loc) · 1.16 KB
/
main.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
import torch
from trainer import Trainer
from config import get_config
from data_loader import get_loader
from utils import prepare_dirs_and_logger, save_config
def main(config):
prepare_dirs_and_logger(config)
torch.manual_seed(config.random_seed)
if config.num_gpu > 0:
torch.cuda.manual_seed(config.random_seed)
if config.is_train:
data_path = config.data_path
batch_size = config.batch_size
else:
if config.test_data_path is None:
data_path = config.data_path
else:
data_path = config.test_data_path
batch_size = config.sample_per_image
a_data_loader, b_data_loader = get_loader(
data_path, batch_size, config.input_scale_size,
config.num_worker, config.skip_pix2pix_processing)
trainer = Trainer(config, a_data_loader, b_data_loader)
if config.is_train:
save_config(config)
trainer.train()
else:
if not config.load_path:
raise Exception("[!] You should specify `load_path` to load a pretrained model")
trainer.test()
if __name__ == "__main__":
config, unparsed = get_config()
main(config)