-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
60 lines (49 loc) · 1.27 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
import dotenv
dotenv.load_dotenv(
override=True,
)
import os
import warnings
os.environ["HYDRA_FULL_ERROR"] = "1"
os.environ["HF_HOME"] = os.environ.get("HF_HOME")
os.environ["TOKENIZERS_PARALLELISM"] = "false"
warnings.filterwarnings("ignore")
import json
import hydra
from omegaconf import OmegaConf, DictConfig
from src.pipelines.pipeline import train, test, predict, tune
@hydra.main(
config_path="configs/",
config_name="multimodal.yaml",
)
def main(
config: DictConfig,
) -> None:
if config.is_tuned == "tuned":
params = json.load(
open(
config.tuned_hparams_path,
"rt",
encoding="UTF-8",
)
)
config = OmegaConf.merge(
config,
params,
)
elif config.is_tuned == "untuned":
pass
else:
raise ValueError(f"Invalid is_tuned argument: {config.is_tuned}")
if config.mode == "train":
return train(config)
elif config.mode == "test":
return test(config)
elif config.mode == "predict":
return predict(config)
elif config.mode == "tune":
return tune(config)
else:
raise ValueError(f"Invalid execution mode: {config.mode}")
if __name__ == "__main__":
main()