-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrain.py
35 lines (29 loc) · 923 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
# Copyright Niantic 2019. Patent Pending. All rights reserved.
#
# This software is licensed under the terms of the Monodepth2 licence
# which allows for non-commercial use only, the full terms of which are made
# available in the LICENSE file.
from __future__ import absolute_import, division, print_function
import torch
import random
import numpy as np
from trainer import Trainer
from options import MonodepthOptions
def set_seed(seed):
if seed is None:
seed = 1
print("Random Seed: {}".format(seed))
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
torch.cuda.manual_seed(seed)
np.random.seed(seed)
random.seed(seed)
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
options = MonodepthOptions()
opts = options.parse()
# seed.
set_seed(opts.random_seed)
if __name__ == "__main__":
trainer = Trainer(opts)
trainer.train()