-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig_autoencoder_y_3d.py
342 lines (307 loc) · 10.1 KB
/
config_autoencoder_y_3d.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
# define the configuration (hyperparameters) for the residual autoencoder
# for this type of network.
# NETWORK MODEL NAME
network_model = 'SR_LFFULLGAN_y_3d_1511_noloss'
data_path = '/data_fast/aa/trainData/Data_Cross_HR_new/'
# data_path = '/data/cvia/Data_AWS/'
# data_path = '/data/aa/Data_Cross_HR/'
# tf_log_path = '/home/mz/HD_data/Tensorboard Logs/'
tf_log_path = '/data_fast/aa/tf_logs/meow/'
# tf_log_path = './tf_logs/'
# tf_log_path = '/home/aa/tf_logs/meow/'
# tf_log_path = './tf_logs/'
# data_path = 'H:\\trainData\\'
# CURRENT TRAINING DATASET
training_data = [
data_path + 'lf_patch_synthetic_rgb_sr_s4_1.hdf5',
data_path + 'lf_patch_synthetic_rgb_sr_s4_1.hdf5',
data_path + 'lf_patch_synthetic_rgb_sr_s4_STF_HCI.hdf5',
data_path + 'lf_patch_synthetic_rgb_sr_s4_STF_HCI.hdf5',
data_path + 'lf_patch_synthetic_rgb_sr_s4_3.hdf5',
data_path + 'lf_patch_synthetic_rgb_sr_s4_3.hdf5',
data_path + 'lf_patch_synthetic_rgb_sr_s4_flowers_2.hdf5',
data_path + 'lf_patch_synthetic_rgb_sr_s4_flowers_2.hdf5',
data_path + 'lf_patch_synthetic_rgb_sr_s4_2.hdf5',
data_path + 'lf_patch_synthetic_rgb_sr_s4_2.hdf5',
# '/home/aa/Python_projects/Data_train/super_resolution/lf_patch_synthetic_rgb_sr_s4_4.hdf5',
# '/home/aa/Python_projects/Data_train/super_resolution/lf_patch_synthetic_rgb_sr_s4_4.hdf5',
# data_path + 'lf_patch_synthetic_rgb_sr_s4_4.hdf5',
# data_path + 'lf_patch_synthetic_rgb_sr_s4_4.hdf5',
data_path + 'lf_patch_synthetic_rgb_sr_s4_disp_half_all.hdf5',
data_path + 'lf_patch_synthetic_rgb_sr_s4_disp_half_all.hdf5',
]
# NETWORK LAYOUT HYPERPARAMETERS
# general config params
config = {
# flag whether we want to train for RGB (might require more
# changes in other files, can't remember right now)
# 'ColorSpace' : 'YUV',
'ColorSpace' : 'YCBCR',
# 'ColorSpace' : 'LAB',
# 'ColorSpace' : 'RGB',
'VisibleGPU' :'0,1,2,3',
# maximum layer which will be initialized (deprecated)
'max_layer' : 100,
# add interpolated input as patch for skip connection in the upscaling phase
'interpolate' : False,
# this will log every tensor being allocated,
# very spammy, but useful for debugging
'log_device_placement' : False,
}
# encoder for 48 x 48 patch, 9 views, RGB
D = 9
D_in = 3
H = 48
W = 48
# nviews = 9
H_s2 = 96
W_s2 = 96
H_s4 = 192
W_s4 = 192
cv_pos = int((D-1)/2)
# patch stepping
sx = 16
sy = 16
sx_s2 = 32
sy_s2 = 32
sx_HR = 64
sy_HR = 64
C = 3
C_value = 1
C_color = 2
# Number of features in the layers
# Number of features in the layers
L_half = 6
L = 8
L0 = 12
L1 = 16
L2 = 24
L3 = 32
L4 = 48
L5 = 64
L6 = 96
L7 = 128
L8 = 192
# contect_features_size = [1,1]
# fraction between encoded patch and decoded patch. e.g.
# the feature maps of decoded patch are 3 times as many
# as the encoded patch, then patch_weight = 3
# Encoder stack for downwards convolution
patch_weight = 2
# chain of dense layers to form small bottleneck (can be empty)
layers = dict()
layer_config = [
{
'id': 'Y',# 'YUV', 'RGB', 'YCBCR', 'LAB' and any combinations
'channels' : C_value,
'start' : 0,
'end': 1,
'upscale': [
{'conv': [3, 3, 3, L0, L0],
'stride': [1, 1, 1, 1, 1]
}],
'final_s2': [
{'conv': [1,1, 1, L * patch_weight, C_value],
'stride': [1,1, 1, 1, 1]
}, ],
'final_s4': [
{'conv': [1,1, 1, L_half * patch_weight, C_value],
'stride': [1,1, 1, 1, 1]
}, ],
},
]
layers['encoder_3D'] = [
{'conv': [3, 3, 3, C_value, L0],
'stride': [1, 1, 1, 1, 1]
},
{ 'conv' : [ 3,3,3, L0, L1 ],
'stride' : [ 1,1, 2,2, 1 ]
},
# resolution now 9 x 18 x 18
{ 'conv' : [ 3,3,3, L1, L2 ],
'stride' : [ 1,2, 1,1, 1 ]
},
# resolution now 5 x 18 x 18
{ 'conv' : [ 3,3,3, L2, L3 ],
'stride' : [ 1,1, 2,2, 1 ]
},
# resolution now 5 x 9 x 9
{ 'conv' : [ 3,3,3, L3, L3 ],
'stride' : [ 1,2, 1,1, 1 ]
},
# # resolution now 5 x 5 x 5
{ 'conv' : [ 3,3,3, L3, L4 ],
'stride' : [ 1,1, 2,2, 1 ]
},
# resolution now 3 x 5 x 5
{'conv' : [3, 3, 3, L4, L5],
'stride' : [1, 2, 1, 1, 1]
},
{'conv': [3, 3, 3, L5, L6],
'stride': [1, 1, 2, 2, 1]
},
{'conv': [3, 3, 3, L6, L8],
'stride': [1, 1, 1, 1, 1]
},
# resolution now 3 x 3 x 3
]
layers['discriminator_3D'] = [
{'conv': [3, 3, 3, C_value, L0],
'stride': [1, 1, 2, 2, 1]
},
{ 'conv' : [ 3,3,3,L0, L1 ],
'stride' : [ 1,1, 2,2, 1 ]
},
# resolution now 9 x 18 x 18
{ 'conv' : [ 3,3,3, L1, L2 ],
'stride' : [ 1,1, 2,2, 1 ]
},
# resolution now 5 x 18 x 18
{ 'conv' : [ 3,3,3, L2, L3 ],
'stride' : [ 1,2, 1,1, 1 ]
},
# # resolution now 5 x 5 x 5
{ 'conv' : [ 3,3,3, L3, L4 ],
'stride' : [ 1,1, 2,2, 1 ]
},
# resolution now 3 x 5 x 5
{'conv' : [3, 3, 3, L4, L5],
'stride' : [1, 2, 2, 2, 1]
},
{'conv': [3, 3, 3, L5, L5],
'stride': [1, 1, 2, 2, 1]
},
# resolution now 3 x 3 x 3
]
layers['upscale'] = [
{ 'conv' : [ 3, 3, 3, L, L0],
'stride' : [1, 1, 2, 2, 1],
'target_shape': [H_s2,W_s2],
'out': None,
},
{ 'conv' : [ 3, 3, 3, L, L],
'stride' : [1, 1, 1, 1, 1],
'target_shape': [H_s2, W_s2],
'out': None,
},
{'conv': [3, 3, 3, L, L],
'stride': [1, 1, 1, 1, 1],
'target_shape': [H_s2, W_s2],
'out': 's2',
},
{'conv': [3, 3, 3, L_half, L],
'stride': [1, 1, 2, 2, 1],
'target_shape': [H_s4, W_s4],
'out': None,
},
{'conv' : [ 3, 3, 3, L_half, L_half],
'stride' : [1, 1, 1, 1, 1],
'target_shape': [H_s4, W_s4],
'out': None,
},
{'conv': [3, 3, 3, L_half, L_half],
'stride': [1, 1, 1, 1, 1],
'target_shape': [H_s4, W_s4],
'out': 's4',
},
]
layers[ 'autoencoder_nodes' ] = []
layers[ '2D_encoder_nodes' ] = []
layers[ '2D_decoder_nodes' ] = []
layers[ 'preferred_gpu' ] = 0
layers[ 'merge_encoders' ] = False
discriminator = [
{'gan_preferred_gpu':2,
'step_size' : 1e-5,
'train': True,
'weight': 1.0,
'channels': C_value,
}
]
iterGan = 1
# 3D ENCODERS
encoders_3D = [
{
'id': 'Y',
'channels': C_value,
'preferred_gpu' : 0,
},
]
#
# 2D DECODERS
#
# Each one generates a 2D upsampling pathway next to the
# two normal autoencoder pipes.
#
# Careful, takes memory. Remove some from training if limited.
#
decoders_3D = [
{
'id': 'Y',
'channels': C_value,
'preferred_gpu' : [0,2],
'loss_fn': 'L2',
'train': True,
'weight': 1.0,
'no_relu': False,
'skip_connection': True,
'skip_id': ['Y'],
'percep_loss': [ ],# 'block1','block2','block3','block4' 'conv4/conv4_4', 'conv5/conv5_4', 'conv2/conv2_2' ,'conv3/conv3_4','conv4/conv4_4', 'conv1/conv1_2',,'conv3/conv3_4','conv4/conv4_4','conv5/conv5_4' #['block1','block2', 'block3','block4'],
'percep_loss_weight': 1.0,
'adv_loss_weight': 1e-4,
},
]
# MINIMIZERS
minimizers = [
# center view super resolution
{
'id': 'Y_min', # 'YCBCR_min'
'losses_3D': ['Y'], # 'KL_divergence' , 'YUV', 'RGB', 'YCBCR', 'LAB' and any combinations
'optimizer': 'Adam',
'preferred_gpu': [1,3],
'step_size': 1e-5,
},
]
# TRAINING HYPERPARAMETERS
training = dict()
# subsets to split training data into
# by default, only 'training' will be used for training, but the results
# on mini-batches on 'validation' will also be logged to check model performance.
# note, split will be performed based upon a random shuffle with filename hash
# as seed, thus, should be always the same for the same file.
#
training[ 'subsets' ] = {
'validation' : 0.05,
'training' : 0.95,
}
# number of samples per mini-batch
# reduce if memory is on the low side,
# but if it's too small, training becomes ridicuously slow
training[ 'samples_per_batch' ] = 6
# log interval (every # mini-batches per dataset)
training[ 'log_interval' ] = 5
# save interval (every # iterations over all datasets)
training[ 'save_interval' ] = 50
# noise to be added on each input patch
# (NOT on the decoding result)
training[ 'noise_sigma' ] = 0.0
# decay parameter for batch normalization
# should be larger for larger datasets
training[ 'batch_norm_decay' ] = 0.9
# flag whether BN center param should be used
training[ 'batch_norm_center' ] = False
# flag whether BN scale param should be used
training[ 'batch_norm_scale' ] = False
# flag whether BN should be zero debiased (extra param)
training[ 'batch_norm_zero_debias' ] = False
eval_res = {
'h_mask_s4': 190,
'w_mask_s4': 190,
'h_mask_s2': 90,
'w_mask_s2': 90,
'm_s4': 32,
'm_s2': 16,
'min_mask': 0.1,
'result_folder': "./results/",
'test_data_folder': "H:\\testData\\"
}