forked from wyf0912/SinSR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_distill.py
49 lines (43 loc) · 1.34 KB
/
main_distill.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
import argparse
from omegaconf import OmegaConf
from trainer import TrainerDistillDifIR as TrainerDistill
def get_parser(**parser_kwargs):
parser = argparse.ArgumentParser(**parser_kwargs)
parser.add_argument(
"--save_dir",
type=str,
default="./saved_logs",
help="Folder to save the checkpoints and training log",
)
parser.add_argument(
"--resume",
type=str,
const=True,
default="",
nargs="?",
help="Resume from the save_dir or checkpoint",
)
parser.add_argument(
"--cfg_path",
type=str,
default="./configs/realsr_swinunet_realesrgan256.yaml",
help="Configs of yaml file",
)
parser.add_argument(
"--steps",
type=int,
default=15,
help="Hyper-parameters of diffusion steps",
)
args = parser.parse_args()
return args
if __name__ == "__main__":
args = get_parser()
configs = OmegaConf.load(args.cfg_path)
configs.diffusion.params.steps = args.steps
# merge args to config
for key in vars(args):
if key in ['cfg_path', 'save_dir', 'resume', ]:
configs[key] = getattr(args, key)
trainer = TrainerDistill(configs)
trainer.train()