-
Notifications
You must be signed in to change notification settings - Fork 2
/
offline_train_test.py
57 lines (47 loc) · 1.52 KB
/
offline_train_test.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
50
51
52
53
54
55
56
57
import os,sys
import importlib
import options
from utils import log
import warnings
warnings.filterwarnings("ignore")
os.environ['WANDB_IGNORE_GLOBS'] = '*.pth'
os.environ['WANDB_MODE'] = 'dryrun'
def main():
log.process(os.getpid())
log.title("[{}] (PyTorch code for testing Sat2Density and debug".format(sys.argv[0]))
opt_cmd = options.parse_arguments(sys.argv[1:])
opt = options.set(opt_cmd=opt_cmd)
if opt.test_ckpt_path and opt.task not in ["test" , "val","vis_test",'test_speed','test_vid','test_sty','test_interpolation']:
opt.task = "test"
if opt.task in ["train" , "Train"]:
opt.isTrain = True
else:
opt.isTrain = False
opt.name = opt.yaml if opt.name is None else opt.name
mode = importlib.import_module("model.{}".format(opt.model))
m = mode.Model(opt)
m.load_dataset(opt)
m.build_networks(opt)
# train
if opt.task in ["train" , "Train"]:
m.setup_optimizer(opt)
m.train(opt)
# test or visualization
elif opt.task in ["test" , "val","vis_test"]:
m.test(opt)
# test speed
elif opt.task == 'test_speed':
m.test_speed(opt)
# inference video results
elif opt.task == 'test_vid':
m.test_vid(opt)
# test one image with different styles
elif opt.task == 'test_sty':
m.test_sty(opt)
# test style interpolation
elif opt.task == 'test_interpolation':
m.test_interpolation(opt)
else:
raise Exception("Unknow task")
if __name__=="__main__":
main()