-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtrain.py
executable file
·59 lines (48 loc) · 2.03 KB
/
train.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
58
59
from templates import *
from templates_latent import *
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='')
parser.add_argument('--batch_size', '-b', type=int, default=96,
help='batch size (all gpus)')
parser.add_argument('--patch_size', '-ps', type=int, default=64,
help='model base patch size')
parser.add_argument('--data_path', '-d', type=str, default="./dataset",
help='dataset path')
parser.add_argument('--name', '-n', type=str, default="train",
help='experiment name')
parser.add_argument('--semantic_enc', action='store_true',
help='use semantic encoder')
parser.add_argument('--semantic_path', type=str, default="",
help='semantic code path')
parser.add_argument('--cfg', action='store_true',
help='use cfg')
args = parser.parse_args()
gpus = [0]
conf = train_autoenc()
conf.batch_size = args.batch_size
conf.sample_size = len(gpus)
conf.save_every_samples = 100_000
conf.patch_size = args.patch_size
conf.name = args.name
conf.data_path = args.data_path
conf.semantic_enc = args.semantic_enc
conf.semantic_path = args.semantic_path
conf.cfg = args.cfg
if args.semantic_path: assert not args.semantic_enc, "Semantic Encoder mode should turn off"
if conf.patch_size == 256:
conf.net_ch = 128
conf.net_ch_mult = (1, 1, 2, 2, 4, 4)
conf.net_enc_channel_mult = (1, 1, 2, 2, 4, 4, 4)
conf.make_model_conf()
elif conf.patch_size == 128:
conf.net_ch = 128
conf.net_ch_mult = (1, 1, 2, 3, 4)
conf.net_enc_channel_mult = (1, 1, 2, 3, 4, 4)
conf.make_model_conf()
elif conf.patch_size == 64:
conf.net_ch_mult = (1, 2, 4, 8)
conf.net_enc_channel_mult = (1, 2, 4, 8, 8)
else:
raise NotImplementedError("Patch size not in [64,128,256]")
train(conf, gpus=gpus)