-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.py
32 lines (24 loc) · 797 Bytes
/
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
#!/usr/bin/env python3
import importlib
import numpy as np
import torch
from utils.parser import load_config, parse_args
def main():
args = parse_args()
cfg = load_config(args)
torch.manual_seed(cfg.SEED)
torch.backends.cudnn.deterministic = False
torch.backends.cudnn.benchmark = True
np.random.seed(cfg.SEED)
solverlib = importlib.import_module('solvers.' + args.model.lower() + '_solver')
solver_cls = None
target_solver_name = args.model.replace('_', '') + 'Solver'
for name, cls in solverlib.__dict__.items():
if name.lower() == target_solver_name.lower():
solver_cls = cls
if solver_cls is None:
raise ValueError('SOLVER NOT FOUND')
sol = solver_cls(cfg)
sol.run()
if __name__ == '__main__':
main()