-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtrain.py
52 lines (38 loc) · 1.48 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from large_spatial_model.utils.path_manager import init_all_submodules
init_all_submodules()
# replace inference.loss_of_one_batch
import dust3r.inference
from large_spatial_model.loss import loss_of_one_batch
dust3r.inference.loss_of_one_batch = loss_of_one_batch
# replace losses.Regr3D
import dust3r.losses
from large_spatial_model.loss import KWRegr3D
dust3r.losses.Regr3D = KWRegr3D
# replace losses.GaussianLoss
from large_spatial_model.loss import GaussianLoss
dust3r.losses.GaussianLoss = GaussianLoss
from dust3r.training import get_args_parser as dust3r_get_args_parser # noqa
from dust3r.training import train # noqa
import dust3r.datasets
from large_spatial_model.datasets.scannet import Scannet
from large_spatial_model.datasets.scannetpp import Scannetpp
dust3r.datasets.Scannetpp = Scannetpp
dust3r.datasets.Scannet = Scannet
from large_spatial_model.model import LSM_Dust3R
dust3r.training.LSM_Dust3R = LSM_Dust3R
import yaml
def get_args_parser():
parser = dust3r_get_args_parser()
parser.prog = 'LSM_Dust3R training'
# Load the configuration
with open("configs/default.yaml", "r") as f:
config = yaml.safe_load(f)
# Convert the config dict to a string of keyword arguments
config_str = "config=" + str(config)
# Set the default model string with parameters
parser.set_defaults(model=f"LSM_Dust3R({config_str})")
return parser
if __name__ == '__main__':
args = get_args_parser()
args = args.parse_args()
train(args)