-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
45 lines (34 loc) · 1.1 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
from omegaconf import DictConfig, ListConfig, OmegaConf
import argparse
# from models import build_model
from scene_graph.data import build_dataset
from scene_graph.model import SceneGraphViT
from scene_graph.trainer import SceneGraphTrainer
import logging
def select_log_level(cfg):
""" Selects the log level based on the input string
"""
levels = {
"debug": logging.DEBUG,
"info": logging.INFO,
"warning": logging.WARNING,
"error": logging.ERROR,
}
logging.basicConfig(level=levels[cfg.experiment.log_level])
def get_config():
""" Creates a config object from the yaml file and the cli arguments
"""
cli_conf = OmegaConf.from_cli()
yaml_conf = OmegaConf.load(cli_conf.config)
conf = OmegaConf.merge(yaml_conf, cli_conf)
return conf
if __name__=="__main__":
cfg = get_config()
# log level
select_log_level(cfg)
# build the model, data loader and trainer
model = SceneGraphViT(cfg)
data_loaders = build_dataset(cfg)
trainer = SceneGraphTrainer(cfg, model, data_loaders)
# train the model
trainer.train()