-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
executable file
·46 lines (32 loc) · 1.08 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
import argparse
import torch
from omegaconf import OmegaConf
import numpy as np
import hydra
from core.tools import run_trainer
from core.tools import run_tester
from core.utils import setup_log
from core.utils import get_modality
torch.multiprocessing.set_sharing_strategy("file_system")
@hydra.main(config_path="config/config.yaml")
def main(cfg):
np.random.seed(cfg.data.manual_seed)
torch.manual_seed(cfg.data.manual_seed)
modality = get_modality(cfg)
logger, writer = setup_log(modality)
logger.info("Initializing the pipeline...")
logger.info(cfg.pretty())
logger.info("Modality: {}".format(modality))
logger.info("----------------------------------------------------------")
try:
if cfg.train.enable:
logger.info("Training the model.")
run_trainer(cfg, logger, modality, writer)
if cfg.test.enable:
logger.info("Evaluating the model.")
run_tester(cfg, logger, modality)
except Exception as e:
logger.exception(e)
if __name__ == "__main__":
main()