forked from fengjian0106/hed-tutorial-for-document-scanning
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhed_net.py
574 lines (464 loc) · 25 KB
/
hed_net.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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
#!/usr/bin/python
#coding=utf8
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import sys
import os
import numpy as np
import const
from mobilenet import *
def class_balanced_sigmoid_cross_entropy(logits, label):
## ref - https://github.com/ppwwyyxx/tensorpack/blob/master/examples/HED/hed.py
"""
The class-balanced cross entropy loss,
as in `Holistically-Nested Edge Detection
<http://arxiv.org/abs/1504.06375>`_.
Args:
logits: of shape (b, ...).
label: of the same shape. the ground truth in {0,1}.
Returns:
class-balanced cross entropy loss.
"""
with tf.name_scope('class_balanced_sigmoid_cross_entropy'):
count_neg = tf.reduce_sum(1.0 - label) # 样本中0的数量
count_pos = tf.reduce_sum(label) # 样本中1的数量(远小于count_neg)
# print('debug, ==========================, count_pos is: {}'.format(count_pos))
beta = count_neg / (count_neg + count_pos) ## e.g. 60000 / (60000 + 800) = 0.9868
pos_weight = beta / (1.0 - beta) ## 0.9868 / (1.0 - 0.9868) = 0.9868 / 0.0132 = 74.75
cost = tf.nn.weighted_cross_entropy_with_logits(logits=logits, targets=label, pos_weight=pos_weight)
cost = tf.reduce_mean(cost * (1 - beta))
# 如果样本中1的数量等于0,那就直接让 cost 为 0,因为 beta == 1 时, 除法 pos_weight = beta / (1.0 - beta) 的结果是无穷大
zero = tf.equal(count_pos, 0.0)
final_cost = tf.where(zero, 0.0, cost)
return final_cost
def mobilenet_v2_style_hed(inputs, batch_size, is_training):
assert const.use_batch_norm == True
assert const.use_kernel_regularizer == False
if const.use_kernel_regularizer:
weights_regularizer = tf.contrib.layers.l2_regularizer(scale=0.0001)
else:
weights_regularizer = None
####################################################
func_blocks = mobilenet_v2_func_blocks(is_training)
# print('============ func_blocks are: %r' % func_blocks)
_conv2d = func_blocks['conv2d']
_inverted_residual_block = func_blocks['inverted_residual_block']
_avg_pool2d = func_blocks['avg_pool2d']
filter_initializer = func_blocks['filter_initializer']
activation_func = func_blocks['activation_func']
####################################################
def _dsn_1x1_conv2d(inputs, filters):
kernel_size = [1, 1]
outputs = tf.layers.conv2d(inputs,
filters,
kernel_size,
padding='same',
activation=None, ## no activation
use_bias=False,
kernel_initializer=filter_initializer,
kernel_regularizer=weights_regularizer)
outputs = tf.layers.batch_normalization(outputs, training=is_training)
## no activation
return outputs
def _output_1x1_conv2d(inputs, filters):
kernel_size = [1, 1]
outputs = tf.layers.conv2d(inputs,
filters,
kernel_size,
padding='same',
activation=None, ## no activation
use_bias=True, ## use bias
kernel_initializer=filter_initializer,
kernel_regularizer=weights_regularizer)
## no batch normalization
## no activation
return outputs
def _dsn_deconv2d_with_upsample_factor(inputs, filters, upsample_factor):
## https://github.com/s9xie/hed/blob/master/examples/hed/train_val.prototxt
## 从这个原版代码里看,是这样计算 kernel_size 的
kernel_size = [2 * upsample_factor, 2 * upsample_factor]
outputs = tf.layers.conv2d_transpose(inputs,
filters,
kernel_size,
strides=(upsample_factor, upsample_factor),
padding='same',
activation=None, ## no activation
use_bias=True, ## use bias
kernel_initializer=filter_initializer,
kernel_regularizer=weights_regularizer)
## 概念上来说,deconv2d 已经是最后的输出 layer 了,只不过最后还有一步 1x1 的 conv2d 把 5 个 deconv2d 的输出再融合到一起
## 所以不需要再使用 batch normalization 了
return outputs
with tf.variable_scope('hed', 'hed', [inputs]):
end_points = {}
net = inputs
## mobilenet v2 as base net
with tf.variable_scope('mobilenet_v2'):
# 标准的 mobilenet v2 里面并没有这两层,
# 这里是为了得到和 input image 相同 size 的 feature map 而增加的层
net = _conv2d(net, 3, [3, 3], stride=1, scope='block0_0')
net = _conv2d(net, 6, [3, 3], stride=1, scope='block0_1')
dsn1 = net
net = _conv2d(net, 12, [3, 3], stride=2, scope='block0_2') # size/2
net = _inverted_residual_block(net, 6, stride=1, expansion=1, scope='block1_0')
dsn2 = net
net = _inverted_residual_block(net, 12, stride=2, scope='block2_0') # size/4
net = _inverted_residual_block(net, 12, stride=1, scope='block2_1')
dsn3 = net
net = _inverted_residual_block(net, 24, stride=2, scope='block3_0') # size/8
net = _inverted_residual_block(net, 24, stride=1, scope='block3_1')
net = _inverted_residual_block(net, 24, stride=1, scope='block3_2')
dsn4 = net
net = _inverted_residual_block(net, 48, stride=2, scope='block4_0') # size/16
net = _inverted_residual_block(net, 48, stride=1, scope='block4_1')
net = _inverted_residual_block(net, 48, stride=1, scope='block4_2')
net = _inverted_residual_block(net, 48, stride=1, scope='block4_3')
net = _inverted_residual_block(net, 64, stride=1, scope='block5_0')
net = _inverted_residual_block(net, 64, stride=1, scope='block5_1')
net = _inverted_residual_block(net, 64, stride=1, scope='block5_2')
dsn5 = net
## dsn layers
with tf.variable_scope('dsn1'):
dsn1 = _dsn_1x1_conv2d(dsn1, 1)
# print('!! debug, dsn1 shape is: {}'.format(dsn1.get_shape()))
## no need deconv2d
with tf.variable_scope('dsn2'):
dsn2 = _dsn_1x1_conv2d(dsn2, 1)
# print('!! debug, dsn2 shape is: {}'.format(dsn2.get_shape()))
dsn2 = _dsn_deconv2d_with_upsample_factor(dsn2, 1, upsample_factor = 2)
# print('!! debug, dsn2 shape is: {}'.format(dsn2.get_shape()))
with tf.variable_scope('dsn3'):
dsn3 = _dsn_1x1_conv2d(dsn3, 1)
# print('!! debug, dsn3 shape is: {}'.format(dsn3.get_shape()))
dsn3 = _dsn_deconv2d_with_upsample_factor(dsn3, 1, upsample_factor = 4)
# print('!! debug, dsn3 shape is: {}'.format(dsn3.get_shape()))
with tf.variable_scope('dsn4'):
dsn4 = _dsn_1x1_conv2d(dsn4, 1)
# print('!! debug, dsn4 shape is: {}'.format(dsn4.get_shape()))
dsn4 = _dsn_deconv2d_with_upsample_factor(dsn4, 1, upsample_factor = 8)
# print('!! debug, dsn4 shape is: {}'.format(dsn4.get_shape()))
with tf.variable_scope('dsn5'):
dsn5 = _dsn_1x1_conv2d(dsn5, 1)
# print('!! debug, dsn5 shape is: {}'.format(dsn5.get_shape()))
dsn5 = _dsn_deconv2d_with_upsample_factor(dsn5, 1, upsample_factor = 16)
# print('!! debug, dsn5 shape is: {}'.format(dsn5.get_shape()))
# dsn fuse
with tf.variable_scope('dsn_fuse'):
dsn_fuse = tf.concat([dsn1, dsn2, dsn3, dsn4, dsn5], 3)
# print('debug, dsn_fuse shape is: {}'.format(dsn_fuse.get_shape()))
dsn_fuse = _output_1x1_conv2d(dsn_fuse, 1)
# print('debug, dsn_fuse shape is: {}'.format(dsn_fuse.get_shape()))
return dsn_fuse, dsn1, dsn2, dsn3, dsn4, dsn5
def mobilenet_v1_style_hed(inputs, batch_size, is_training):
assert const.use_batch_norm == True
assert const.use_kernel_regularizer == False
alpha = 1.0
filter_initializer = tf.contrib.layers.xavier_initializer()
if const.use_kernel_regularizer:
weights_regularizer = tf.contrib.layers.l2_regularizer(scale=0.001)
else:
weights_regularizer = None
def _conv2d(inputs, filters, kernel_size, stride, scope=''):
with tf.variable_scope(scope):
outputs = tf.layers.conv2d(inputs,
filters,
kernel_size,
strides=(stride, stride),
padding='same',
activation=None,
use_bias=False,
kernel_initializer=filter_initializer)
'''
https://github.com/udacity/deep-learning/blob/master/batch-norm/Batch_Normalization_Solutions.ipynb
https://www.tensorflow.org/api_docs/python/tf/layers/batch_normalization
'''
outputs = tf.layers.batch_normalization(outputs, training=is_training)
outputs = tf.nn.relu(outputs)
return outputs
'''stride is just for tf.layers.separable_conv2d, means depthwise_conv_stride'''
def _depthwise_conv2d(inputs,
pointwise_conv_filters,
depthwise_conv_kernel_size,
stride,
scope=''):
with tf.variable_scope(scope):
with tf.variable_scope('depthwise_conv'):
outputs = tf.contrib.layers.separable_conv2d(
inputs,
None, # https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet_v1.py
depthwise_conv_kernel_size,
depth_multiplier=1,
stride=(stride, stride),
padding='SAME',
activation_fn=None,
weights_initializer=filter_initializer,
biases_initializer=None)
'''
!!!important!!! tf.contrib.layers.separable_conv2d already has a depthwise convolution and a pointwise convolution,
but By passing num_outputs=None, separable_conv2d produces only a depthwise convolution layer
ref -- https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet_v1.py
'''
with tf.variable_scope('pointwise_conv'):
pointwise_conv_filters = int(pointwise_conv_filters * alpha)
outputs = tf.layers.conv2d(outputs,
pointwise_conv_filters, ##!! here, pointwise_conv_filters * alpha
(1, 1),
padding='same',
activation=None,
use_bias=False,
kernel_initializer=filter_initializer)
outputs = tf.layers.batch_normalization(outputs, training=is_training)
outputs = tf.nn.relu(outputs)
return outputs
def _dsn_1x1_conv2d(inputs, filters):
kernel_size = [1, 1]
outputs = tf.layers.conv2d(inputs,
filters,
kernel_size,
padding='same',
activation=None, ## no activation
use_bias=False,
kernel_initializer=filter_initializer,
kernel_regularizer=weights_regularizer)
outputs = tf.layers.batch_normalization(outputs, training=is_training)
## no activation
return outputs
def _output_1x1_conv2d(inputs, filters):
kernel_size = [1, 1]
outputs = tf.layers.conv2d(inputs,
filters,
kernel_size,
padding='same',
activation=None, ## no activation
use_bias=True, ## use bias
kernel_initializer=filter_initializer,
kernel_regularizer=weights_regularizer)
## no batch normalization
## no activation
return outputs
def _dsn_deconv2d_with_upsample_factor(inputs, filters, upsample_factor):
## https://github.com/s9xie/hed/blob/master/examples/hed/train_val.prototxt
## 从这个原版代码里看,是这样计算 kernel_size 的
kernel_size = [2 * upsample_factor, 2 * upsample_factor]
outputs = tf.layers.conv2d_transpose(inputs,
filters,
kernel_size,
strides=(upsample_factor, upsample_factor),
padding='same',
activation=None, ## no activation
use_bias=True, ## use bias
kernel_initializer=filter_initializer,
kernel_regularizer=weights_regularizer)
## 概念上来说,deconv2d 已经是最后的输出 layer 了,只不过最后还有一步 1x1 的 conv2d 把 5 个 deconv2d 的输出再融合到一起
## 所以不需要再使用 batch normalization 了
return outputs
with tf.variable_scope('hed', 'hed', [inputs]):
end_points = {}
net = inputs
## mobilenet v1 as base net
with tf.variable_scope('mobilenet_v1'):
# 标准的 mobilenet v1 里面并没有这两层,
# 这里是为了得到和 input image 相同 size 的 feature map 而增加的层
net = _conv2d(net, 6, [3, 3], stride=1, scope='extra_block0')
net = _conv2d(net, 6, [3, 3], stride=1, scope='extra_block1')
dsn1 = net
net = _conv2d(net, 8, [3, 3], stride=2, scope='block0')
# print('\r ++++ block0 shape: %s' % (net.get_shape().as_list()))
end_points['block0'] = net
net = _depthwise_conv2d(net, 16, [3, 3], stride=1, scope='block1')
end_points['block1'] = net
dsn2 = net
net = _depthwise_conv2d(net, 32, [3, 3], stride=2, scope='block2')
end_points['block2'] = net
net = _depthwise_conv2d(net, 32, [3, 3], stride=1, scope='block3')
end_points['block3'] = net
dsn3 = net
net = _depthwise_conv2d(net, 64, [3, 3], stride=2, scope='block4')
end_points['block4'] = net
net = _depthwise_conv2d(net, 64, [3, 3], stride=1, scope='block5')
end_points['block5'] = net
dsn4 = net
net = _depthwise_conv2d(net, 128, [3, 3], stride=2, scope='block6')
end_points['block6'] = net
net = _depthwise_conv2d(net, 128, [3, 3], stride=1, scope='block7')
end_points['block7'] = net
net = _depthwise_conv2d(net, 128, [3, 3], stride=1, scope='block8')
end_points['block8'] = net
net = _depthwise_conv2d(net, 128, [3, 3], stride=1, scope='block9')
end_points['block9'] = net
net = _depthwise_conv2d(net, 128, [3, 3], stride=1, scope='block10')
end_points['block10'] = net
net = _depthwise_conv2d(net, 128, [3, 3], stride=1, scope='block11')
end_points['block11'] = net
dsn5 = net
## dsn layers
with tf.variable_scope('dsn1'):
dsn1 = _dsn_1x1_conv2d(dsn1, 1)
print('!! debug, dsn1 shape is: {}'.format(dsn1.get_shape()))
## no need deconv2d
with tf.variable_scope('dsn2'):
dsn2 = _dsn_1x1_conv2d(dsn2, 1)
print('!! debug, dsn2 shape is: {}'.format(dsn2.get_shape()))
dsn2 = _dsn_deconv2d_with_upsample_factor(dsn2, 1, upsample_factor = 2)
print('!! debug, dsn2 shape is: {}'.format(dsn2.get_shape()))
with tf.variable_scope('dsn3'):
dsn3 = _dsn_1x1_conv2d(dsn3, 1)
print('!! debug, dsn3 shape is: {}'.format(dsn3.get_shape()))
dsn3 = _dsn_deconv2d_with_upsample_factor(dsn3, 1, upsample_factor = 4)
print('!! debug, dsn3 shape is: {}'.format(dsn3.get_shape()))
with tf.variable_scope('dsn4'):
dsn4 = _dsn_1x1_conv2d(dsn4, 1)
print('!! debug, dsn4 shape is: {}'.format(dsn4.get_shape()))
dsn4 = _dsn_deconv2d_with_upsample_factor(dsn4, 1, upsample_factor = 8)
print('!! debug, dsn4 shape is: {}'.format(dsn4.get_shape()))
with tf.variable_scope('dsn5'):
dsn5 = _dsn_1x1_conv2d(dsn5, 1)
print('!! debug, dsn5 shape is: {}'.format(dsn5.get_shape()))
dsn5 = _dsn_deconv2d_with_upsample_factor(dsn5, 1, upsample_factor = 16)
print('!! debug, dsn5 shape is: {}'.format(dsn5.get_shape()))
# dsn fuse
with tf.variable_scope('dsn_fuse'):
dsn_fuse = tf.concat([dsn1, dsn2, dsn3, dsn4, dsn5], 3)
print('debug, dsn_fuse shape is: {}'.format(dsn_fuse.get_shape()))
dsn_fuse = _output_1x1_conv2d(dsn_fuse, 1)
print('debug, dsn_fuse shape is: {}'.format(dsn_fuse.get_shape()))
return dsn_fuse, dsn1, dsn2, dsn3, dsn4, dsn5
def vgg_style_hed(inputs, batch_size, is_training):
filter_initializer = tf.contrib.layers.xavier_initializer()
if const.use_kernel_regularizer:
weights_regularizer = tf.contrib.layers.l2_regularizer(scale=0.0005)
else:
weights_regularizer = None
def _vgg_conv2d(inputs, filters, kernel_size):
use_bias = True
if const.use_batch_norm:
use_bias = False
outputs = tf.layers.conv2d(inputs,
filters,
kernel_size,
padding='same',
activation=None, ## call relu after batch normalization
use_bias=use_bias,
kernel_initializer=filter_initializer,
kernel_regularizer=weights_regularizer)
if const.use_batch_norm:
outputs = tf.layers.batch_normalization(outputs, training=is_training)
outputs = tf.nn.relu(outputs)
return outputs
def _max_pool2d(inputs):
outputs = tf.layers.max_pooling2d(inputs,
[2, 2],
strides=(2, 2),
padding='same')
return outputs
def _dsn_1x1_conv2d(inputs, filters):
use_bias = True
if const.use_batch_norm:
use_bias = False
kernel_size = [1, 1]
outputs = tf.layers.conv2d(inputs,
filters,
kernel_size,
padding='same',
activation=None, ## no activation
use_bias=use_bias,
kernel_initializer=filter_initializer,
kernel_regularizer=weights_regularizer)
if const.use_batch_norm:
outputs = tf.layers.batch_normalization(outputs, training=is_training)
## no activation
return outputs
def _output_1x1_conv2d(inputs, filters):
kernel_size = [1, 1]
outputs = tf.layers.conv2d(inputs,
filters,
kernel_size,
padding='same',
activation=None, ## no activation
use_bias=True, ## use bias
kernel_initializer=filter_initializer,
kernel_regularizer=weights_regularizer)
## no batch normalization
## no activation
return outputs
def _dsn_deconv2d_with_upsample_factor(inputs, filters, upsample_factor):
## https://github.com/s9xie/hed/blob/master/examples/hed/train_val.prototxt
## 从这个原版代码里看,是这样计算 kernel_size 的
kernel_size = [2 * upsample_factor, 2 * upsample_factor]
outputs = tf.layers.conv2d_transpose(inputs,
filters,
kernel_size,
strides=(upsample_factor, upsample_factor),
padding='same',
activation=None, ## no activation
use_bias=True, ## use bias
kernel_initializer=filter_initializer,
kernel_regularizer=weights_regularizer)
## 概念上来说,deconv2d 已经是最后的输出 layer 了,只不过最后还有一步 1x1 的 conv2d 把 5 个 deconv2d 的输出再融合到一起
## 所以不需要再使用 batch normalization 了
return outputs
# ref https://github.com/s9xie/hed/blob/master/examples/hed/train_val.prototxt
with tf.variable_scope('hed', 'hed', [inputs]):
end_points = {}
net = inputs
with tf.variable_scope('conv1'):
net = _vgg_conv2d(net, 12, [3, 3])
net = _vgg_conv2d(net, 12, [3, 3])
dsn1 = net
net = _max_pool2d(net)
with tf.variable_scope('conv2'):
net = _vgg_conv2d(net, 24, [3, 3])
net = _vgg_conv2d(net, 24, [3, 3])
dsn2 = net
net = _max_pool2d(net)
with tf.variable_scope('conv3'):
net = _vgg_conv2d(net, 48, [3, 3])
net = _vgg_conv2d(net, 48, [3, 3])
net = _vgg_conv2d(net, 48, [3, 3])
dsn3 = net
net = _max_pool2d(net)
with tf.variable_scope('conv4'):
net = _vgg_conv2d(net, 96, [3, 3])
net = _vgg_conv2d(net, 96, [3, 3])
net = _vgg_conv2d(net, 96, [3, 3])
dsn4 = net
net = _max_pool2d(net)
with tf.variable_scope('conv5'):
net = _vgg_conv2d(net, 192, [3, 3])
net = _vgg_conv2d(net, 192, [3, 3])
net = _vgg_conv2d(net, 192, [3, 3])
dsn5 = net
# net = _max_pool2d(net) # no need this pool layer
## dsn layers
with tf.variable_scope('dsn1'):
dsn1 = _dsn_1x1_conv2d(dsn1, 1)
print('!! debug, dsn1 shape is: {}'.format(dsn1.get_shape()))
## no need deconv2d
with tf.variable_scope('dsn2'):
dsn2 = _dsn_1x1_conv2d(dsn2, 1)
print('!! debug, dsn2 shape is: {}'.format(dsn2.get_shape()))
dsn2 = _dsn_deconv2d_with_upsample_factor(dsn2, 1, upsample_factor = 2)
print('!! debug, dsn2 shape is: {}'.format(dsn2.get_shape()))
with tf.variable_scope('dsn3'):
dsn3 = _dsn_1x1_conv2d(dsn3, 1)
print('!! debug, dsn3 shape is: {}'.format(dsn3.get_shape()))
dsn3 = _dsn_deconv2d_with_upsample_factor(dsn3, 1, upsample_factor = 4)
print('!! debug, dsn3 shape is: {}'.format(dsn3.get_shape()))
with tf.variable_scope('dsn4'):
dsn4 = _dsn_1x1_conv2d(dsn4, 1)
print('!! debug, dsn4 shape is: {}'.format(dsn4.get_shape()))
dsn4 = _dsn_deconv2d_with_upsample_factor(dsn4, 1, upsample_factor = 8)
print('!! debug, dsn4 shape is: {}'.format(dsn4.get_shape()))
with tf.variable_scope('dsn5'):
dsn5 = _dsn_1x1_conv2d(dsn5, 1)
print('!! debug, dsn5 shape is: {}'.format(dsn5.get_shape()))
dsn5 = _dsn_deconv2d_with_upsample_factor(dsn5, 1, upsample_factor = 16)
print('!! debug, dsn5 shape is: {}'.format(dsn5.get_shape()))
##dsn fuse
with tf.variable_scope('dsn_fuse'):
dsn_fuse = tf.concat([dsn1, dsn2, dsn3, dsn4, dsn5], 3)
print('debug, dsn_fuse shape is: {}'.format(dsn_fuse.get_shape()))
dsn_fuse = _output_1x1_conv2d(dsn_fuse, 1)
print('debug, dsn_fuse shape is: {}'.format(dsn_fuse.get_shape()))
return dsn_fuse, dsn1, dsn2, dsn3, dsn4, dsn5