-
Notifications
You must be signed in to change notification settings - Fork 0
/
train_dsns.py
33 lines (24 loc) · 944 Bytes
/
train_dsns.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
import hydra
import torch
from pytorch_lightning import Trainer
from omegaconf import DictConfig
from mains.dsns_main import DSNS
from utils.config import compose_config_folders, copy_config_to_experiment_folder
@hydra.main(config_path='configs', config_name='dsns', version_base='1.1')
def main(cfg: DictConfig) -> None:
compose_config_folders(cfg)
copy_config_to_experiment_folder(cfg)
model = DSNS(cfg)
model.net.load_state_dict(torch.load("./_pretrained/model.pth", weights_only=True))
trainer = Trainer(max_epochs=1)
trainer.fit(model)
# save dsns model
print("Saving model weights.")
model.save_model()
print("Evaluating the performance. {est time. 10 minutes}")
print(f"Performance: {torch.mean(model.evaluate(save_first_frame=True))}.")
# visualize
print("Running the heatmap visualization. {est time. 10 minutes}")
model.visualize()
if __name__ == '__main__':
main()