-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheval.py
More file actions
29 lines (23 loc) · 844 Bytes
/
eval.py
File metadata and controls
29 lines (23 loc) · 844 Bytes
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
import hydra
import torch
from models import build_module
from datamodules import build_datamodule
from utils.hydra import replace_reference, fix_relative_path
import pytorch_lightning as pl
@hydra.main(config_path="./configs", config_name="cfg", version_base="1.12")
def main(conf):
replace_reference(conf)
fix_relative_path(conf)
print(conf)
print("Instantiating model and datamodule")
module = build_module(conf=conf)
datamodule = build_datamodule(conf=conf)
conf.gpu = [conf.gpu] if isinstance(conf.gpu, int) else conf.gpu
trainer = pl.Trainer(
accelerator="cpu" if not conf.gpu else "gpu",
devices=1 if not conf.gpu else conf.gpu,
)
print("Starting testing!")
trainer.test(model=module, datamodule=datamodule, ckpt_path=conf.ckpt_path)
if __name__ == "__main__":
main()