-
Notifications
You must be signed in to change notification settings - Fork 11
/
config.py
98 lines (77 loc) · 5.46 KB
/
config.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import argparse
import json
from dataloading import dataset_map_train
from architectures import decoder_map, encoder_map
import tensorflow as tf
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('name', type=str, help="name of the experiment")
# run setting
parser.add_argument('--mode', default='train', choices=['train', 'predict'], required=True)
parser.add_argument('--gpu', type=int, required=True)
parser.add_argument('--load', action='store_true')
# dataset folder
parser.add_argument('--dataset', choices=dataset_map_train.keys(), required=True)
# options
parser.add_argument('--covariance', action='store_true')
parser.add_argument('--feat_shape', default=True, type=bool)
parser.add_argument('--L1', action='store_true')
parser.add_argument('--heat_feat_normalize', default=True, type=bool)
parser.add_argument('--epochs', default=100000, type=int, help="number of epochs")
# architectures
parser.add_argument('--decoder', default='standard', choices=decoder_map.keys())
parser.add_argument('--encoder', default='seperate', choices=encoder_map.keys())
parser.add_argument('--in_dim', default=256, type=int, choices=[128, 256], help="dim of input img 256 or 128")
parser.add_argument('--reconstr_dim', default=256, type=int, choices=[128, 256], help="dim of reconstructed img 256 or 128")
parser.add_argument('--heat_dim', default=64, type=int, choices=[64], help="dim of part_map (fixed)")
# modes
parser.add_argument('--l_2_scal', default=0.1, type=float, help="scale around part means that is considered for l2")
parser.add_argument('--l_2_threshold', default=0.2, type=float, help="")
parser.add_argument('--L_inv_scal', default=0.8, type=float, help="")
parser.add_argument('--bn', default=32, type=int, help="batchsize if not slim and 2 * batchsize if slim")
parser.add_argument('--n_parts', default=16, type=int, help="number of parts")
parser.add_argument('--n_features', default=64, type=int, help="neurons of feature map layer")
parser.add_argument('--n_c', default=3, type=int)
parser.add_argument('--nFeat_1', default=256, type=int, help="neurons in residual module of part hourglass")
parser.add_argument('--nFeat_2', default=256, type=int, help="neurons in residual module of feature hourglass")
# loss multiplication constants
parser.add_argument('--lr', default=0.001, type=float, help="learning rate of network")
parser.add_argument('--lr_d', default=0.001, type=float, help="adversarial setting: learning rate discriminator network")
parser.add_argument('--c_l2', default=1., type=float, help="")
parser.add_argument('--c_trans', default=5., type=float, help="")
parser.add_argument('--c_precision_trans', default=0.1, type=float, help="")
parser.add_argument('--c_t', default=1., type=float, help="")
# tps parameters
parser.add_argument('--schedule_scale', default=100000, type=int, help="")
parser.add_argument('--scal', default=[0.8], type=float, nargs='+', help="default 0.6 sensible shedule [0.6, 0.6]")
parser.add_argument('--tps_scal', default=[0.05], type=float, nargs='+', help="sensible shedule [0.01, 0.08]")
parser.add_argument('--rot_scal', default=[0.1], type=float, nargs='+', help="sensible shedule [0.05, 0.6]")
parser.add_argument('--off_scal', default=[0.15], type=float, nargs='+', help="sensible shedule [0.05, 0.15]")
parser.add_argument('--scal_var', default=[0.05], type=float, nargs='+', help="sensible shedule [0.05, 0.2]")
parser.add_argument('--augm_scal', default=[1.], type=float, nargs='+', help="sensible shedule [0.0, 1.]")
#appearance parameters
parser.add_argument('--contrast_var', default=0.5, type=float, help="contrast variation")
parser.add_argument('--brightness_var', default=0.3, type=float, help="contrast variation")
parser.add_argument('--saturation_var', default=0.1, type=float, help="contrast variation")
parser.add_argument('--hue_var', default=0.3, type=float, help="contrast variation")
parser.add_argument('--p_flip', default=0., type=float, help="contrast variation")
# adverserial
parser.add_argument('--adverserial', action='store_true')
parser.add_argument('--c_g', default=0.0002, type=float, help="factor weighting adversarial loss generator")
parser.add_argument('--patch_size', default=[49, 49], type=int, nargs=2, help="dim of patch_size")
parser.add_argument('--print_vars', action='store_true')
parser.add_argument('--save_interval', default=20000, type=int, help="saves model every n gradient steps")
parser.add_argument('--summary_interval', default=500, type=int, help="writes summary every n gradient steps")
parser.add_argument('--static', action='store_true') # for e.g.birds (inter-species reconstruction too difficult)
parser.add_argument('--chunk_size', default=16, type=int, help="group of consecutive frames from video which are used for shape transformations")
parser.add_argument('--n_shuffle', default=64, type=int, help="n shuffle data")
parser.add_argument('--data_parallel_calls', default=4, type=int, help="number of parallel calls for tf map for preprocessing data")
arg = parser.parse_args()
return arg
def write_hyperparameters(r, save_dir):
filename = save_dir + "config.txt"
with open(filename, "a") as input_file:
for k, v in r.items():
line = '{}, {}'.format(k, v)
print(line)
print(line, file=input_file)