def __init__(self, chz, out_c, growth, actfunc=F.leaky_relu, norm=nn.BatchNorm2d): super(DenseNet_decoder, self).__init__() sizes = getSizes(chz, growth) skipSize = sizes['dec']['skip'] opSize = sizes['dec']['op'] ipSize = sizes['dec']['ip'] self.up_block4 = DenseNet2D_up_block(skipSize[0], ipSize[0], opSize[0], 2, actfunc) self.up_block3 = DenseNet2D_up_block(skipSize[1], ipSize[1], opSize[1], 2, actfunc) self.up_block2 = DenseNet2D_up_block(skipSize[2], ipSize[2], opSize[2], 2, actfunc) self.up_block1 = DenseNet2D_up_block(skipSize[3], ipSize[3], opSize[3], 2, actfunc) self.c3_11 = nn.Conv2d(kernel_size=1, in_channels=opSize[0], out_channels=3) self.c2_11 = nn.Conv2d(kernel_size=1, in_channels=opSize[1], out_channels=3) self.c1_11 = nn.Conv2d(kernel_size=1, in_channels=opSize[2], out_channels=3) self.final = convBlock(chz, chz, out_c, actfunc)
def refinement(disp_logits, seg_embedding, is_train, reuse): with tf.variable_scope('refinement', reuse=reuse): d = disp_logits.shape.as_list()[-1] seg_embedding = tf.image.resize_images(seg_embedding, tf.shape(disp_logits)[1:3]) concated = tf.concat([disp_logits, seg_embedding], axis=-1) conv1 = conv_norm_lrelu(concated, 64, kernel_size=5, strides=(2, 2), is_train=is_train, withLrelu=False, name="conv1") l2a = convBlock(conv1, [32, 32, 64], strides=(1, 1), is_train=is_train, name='l2a') l2b = identityBlock(l2a, [32, 32, 64], is_train=is_train, name='l2b') l2c = identityBlock(l2b, [32, 32, 64], is_train=is_train, name='l2c') l3a = convBlock(l2c, [64, 64, 128], strides=(1, 1), is_train=is_train, name='l3a') l3b = identityBlock(l3a, [64, 64, 128], is_train=is_train, name='l3b') l3c = identityBlock(l3b, [64, 64, 128], is_train=is_train, name='l3c') l4a = deconv_norm_lrelu(l3c, 64, 3, strides=(2, 2), is_train=is_train, name='deconvl4a') residul = tf.layers.conv2d(l4a, d, 3, padding='same', name='output') output = tf.add(disp_logits, residul) return output
def __init__(self, in_c=1, chz=32, actfunc=F.leaky_relu, growth=1.5, norm=nn.BatchNorm2d): super(DenseNet_encoder, self).__init__() sizes = getSizes(chz, growth) interSize = sizes['enc']['inter'] opSize = sizes['enc']['op'] ipSize = sizes['enc']['ip'] self.head = convBlock(in_c=1, inter_c=chz, out_c=chz, actfunc=actfunc) self.down_block1 = DenseNet2D_down_block(in_c=ipSize[0], inter_c=interSize[0], op_c=opSize[0], down_size=2, norm=norm, actfunc=actfunc) self.down_block2 = DenseNet2D_down_block(in_c=ipSize[1], inter_c=interSize[1], op_c=opSize[1], down_size=2, norm=norm, actfunc=actfunc) self.down_block3 = DenseNet2D_down_block(in_c=ipSize[2], inter_c=interSize[2], op_c=opSize[2], down_size=2, norm=norm, actfunc=actfunc) self.down_block4 = DenseNet2D_down_block(in_c=ipSize[3], inter_c=interSize[3], op_c=opSize[3], down_size=2, norm=norm, actfunc=actfunc) self.bottleneck = DenseNet2D_down_block(in_c=opSize[3], inter_c=interSize[3], op_c=opSize[3], down_size=0, norm=norm, actfunc=actfunc)