-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
executable file
·47 lines (37 loc) · 1.39 KB
/
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import torch
import random
import numpy as np
import argparse
from utils.common import load_config
from slams.dns_slam import DNS_SLAM
def setup_seed(seed):
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
np.random.seed(seed)
random.seed(seed)
torch.backends.cudnn.deterministic = True
if __name__ == '__main__':
setup_seed(0)
torch.multiprocessing.set_start_method('spawn')
parser = argparse.ArgumentParser(
description='Arguments for running the NICE-SLAM/iMAP*.'
)
parser.add_argument('config', type=str, help='Path to config file.')
parser.add_argument('--input', type=str,
help='input folder, this have higher priority, can overwrite the one in config file')
parser.add_argument('--output', type=str,
help='output folder, this have higher priority, can overwrite the one in config file')
nice_parser = parser.add_mutually_exclusive_group(required=False)
parser.set_defaults(nice=True)
args = parser.parse_args()
cfg = load_config(args.config, 'configs/slam.yaml')
if args.input is not None:
cfg['dataset_dir'] = args.input
if args.output is not None:
cfg['out_dir'] = args.output
print(cfg)
device = [torch.device('cuda:0'), torch.device('cuda:0')]
slam = DNS_SLAM(cfg, device)
print('Model created.')
# SLAM
slam.run()