-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathbuilder.py
26 lines (23 loc) · 969 Bytes
/
builder.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
import torch.cuda
from lib.models.regression.model import RegressionModel
from lib.models.regression.model import RegressionMultiFrameModel
from lib.models.matching.model import FeatureMatchingModel
def build_model(cfg, checkpoint=''):
if cfg.MODEL == 'FeatureMatching':
return FeatureMatchingModel(cfg)
elif cfg.MODEL == 'Regression':
model = RegressionModel.load_from_checkpoint(checkpoint, cfg=cfg) if \
checkpoint is not '' else RegressionModel(cfg)
if torch.cuda.is_available():
model = model.cuda()
model.eval()
return model
elif cfg.MODEL == 'RegressionMultiFrame':
model = RegressionMultiFrameModel.load_from_checkpoint(checkpoint, cfg=cfg) if \
checkpoint is not '' else RegressionMultiFrameModel(cfg)
if torch.cuda.is_available():
model = model.cuda()
model.eval()
return model
else:
raise NotImplementedError()