-
Notifications
You must be signed in to change notification settings - Fork 5
/
train.py
38 lines (26 loc) · 783 Bytes
/
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
import torch
import sys
import os
from coach import Coach
from misc.utils import log
import options
def main():
log.process(os.getpid())
log.title("[{}] (PyTorch code for training MatchNeRF)".format(sys.argv[0]))
opt_cmd = options.parse_arguments(sys.argv[1:])
opt = options.set(opt_cmd=opt_cmd)
options.save_options_file(opt)
with torch.cuda.device(opt.device):
m = Coach(opt)
# setup model
m.build_networks()
# setup dataset
m.load_dataset(splits=['train', 'val', 'test'])
# setup trianing utils
m.setup_visualizer()
m.setup_optimizer()
if opt.resume or opt.load is not None:
m.restore_checkpoint()
m.train_model()
if __name__ == "__main__":
main()