-
Notifications
You must be signed in to change notification settings - Fork 12
/
run.py
24 lines (20 loc) · 810 Bytes
/
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
import argparse
import torch
from derender import setup_runtime, Trainer, Derenderer
## runtime arguments
parser = argparse.ArgumentParser(description='Training configurations.')
parser.add_argument('--config', default=None, type=str, help='Specify a config file path')
parser.add_argument('--gpu', default=None, type=str, help='Specify a GPU device')
parser.add_argument('--num_workers', default=4, type=int, help='Specify the number of worker threads for data loaders')
parser.add_argument('--seed', default=0, type=int, help='Specify a random seed')
args = parser.parse_args()
## set up
cfgs = setup_runtime(args)
trainer = Trainer(cfgs, Derenderer)
run_train = cfgs.get('run_train', False)
run_test = cfgs.get('run_test', False)
## run
if run_train:
trainer.train()
if run_test:
trainer.test()