-
Notifications
You must be signed in to change notification settings - Fork 0
/
omega_scan.py
44 lines (37 loc) · 1.48 KB
/
omega_scan.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
import torch
from pytorch_lightning import Trainer
from pytorch_lightning.callbacks import TQDMProgressBar, LearningRateMonitor
from dataloader.data_module import LitDataModule
from models.main_model import MainModel
import utils.get_model
def omega_scan(texture_mode: str = 'sa'):
cfg = utils.get_model.get_cfg()
cfg.model.texture_mode = texture_mode
cfg.model.pnp_mode = None
if texture_mode == 'sa':
candidates = [2. ** i for i in [6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6]]
elif texture_mode == 'cb':
candidates = [2 ** i for i in range(8)]
else:
raise NotImplementedError
datamodule = LitDataModule(cfg)
for value in candidates:
trainer = Trainer(
accelerator='auto',
devices=1 if torch.cuda.is_available() else None,
max_epochs=10,
callbacks=[
TQDMProgressBar(refresh_rate=1),
LearningRateMonitor(logging_interval='step', log_momentum=False),
],
default_root_dir='outputs',
log_every_n_steps=10,
num_sanity_val_steps=-1,
)
cfg.model.texture.siren_first_omega_0 = value
cfg.model.texture.cb_num_cycles = value
model = MainModel(cfg, datamodule.dataset.objects, datamodule.dataset.objects_eval)
model = model.to(cfg.device, dtype=cfg.dtype)
trainer.fit(model, ckpt_path=None, datamodule=datamodule)
if __name__ == '__main__':
omega_scan(texture_mode='sa')