forked from fudan-zvg/RealMotion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eval.py
29 lines (22 loc) · 788 Bytes
/
eval.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
import os
import hydra
import pytorch_lightning as pl
from hydra.utils import instantiate
@hydra.main(version_base=None, config_path="./conf/", config_name="config")
def main(cfg):
pl.seed_everything(cfg.seed)
assert os.path.exists(cfg.checkpoint), f"Checkpoint {cfg.checkpoint} does not exist"
datamodule = instantiate(cfg.datamodule.pl_module, test=cfg.submit)
model = instantiate(cfg.model.pl_module)
trainer = pl.Trainer(
logger=False,
accelerator="gpu",
devices=cfg.gpus if not cfg.submit else 1,
max_epochs=1,
)
if not cfg.submit:
trainer.validate(model, datamodule, ckpt_path=cfg.checkpoint)
else:
trainer.test(model, datamodule, ckpt_path=cfg.checkpoint)
if __name__ == "__main__":
main()