-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
70 lines (61 loc) · 1.99 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import argparse
import logging
import warnings
warnings.filterwarnings('ignore', category=FutureWarning)
warnings.filterwarnings('ignore', category=UserWarning)
import tensorflow as tf
import torch
from audio_separation.common.baseline_registry import baseline_registry
from audio_separation.config.default import get_config
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
"--run-type",
choices=["train", "eval"],
default='train',
help="run type of the experiment (train or eval)",
)
parser.add_argument(
"--exp-config",
type=str,
default='baselines/config/pointnav_rgb.yaml',
help="path to config yaml containing info about experiment",
)
parser.add_argument(
"opts",
default=None,
nargs=argparse.REMAINDER,
help="Modify config options from command line",
)
parser.add_argument(
"--model-dir",
default=None,
help="Modify config options from command line",
)
parser.add_argument(
"--eval-interval",
type=int,
default=1,
help="Evaluation interval of checkpoints",
)
parser.add_argument(
"--prev-ckpt-ind",
type=int,
default=-1,
help="Evaluation interval of checkpoints",
)
args = parser.parse_args()
# run exp
config = get_config(args.exp_config, args.opts, args.model_dir, args.run_type)
trainer_init = baseline_registry.get_trainer(config.TRAINER_NAME)
assert trainer_init is not None, f"{config.TRAINER_NAME} is not supported"
trainer = trainer_init(config)
level = logging.DEBUG if config.DEBUG else logging.INFO
logging.basicConfig(level=level, format='%(asctime)s, %(levelname)s: %(message)s',
datefmt="%Y-%m-%d %H:%M:%S")
if args.run_type == "train":
trainer.train()
elif args.run_type == "eval":
trainer.eval(args.eval_interval, args.prev_ckpt_ind)
if __name__ == "__main__":
main()