def __init__(self, input_channels, output_channels, kernel_size, apply_bn_relu, plus_one): super(DecoderBlock, self).__init__() # Upsample the inpput coming from previous layer self.up_convolution = UpconvolutionLayer( input_channels=input_channels, output_channels=output_channels, kernel_size=kernel_size) if plus_one: next_input_channels = input_channels + 1 else: next_input_channels = input_channels # Aggregate skip and upsampled input self.convolution1 = conv_layer(input_channels=next_input_channels, output_channels=output_channels, kernel_size=kernel_size, stride=1, apply_bn_relu=True) # Learn from aggregation self.convolution2 = conv_layer(input_channels=output_channels, output_channels=output_channels, kernel_size=kernel_size, stride=1, apply_bn_relu=apply_bn_relu)
def __init__(self, channels, kernel_size, apply_bn_relu): super(StandardLayer, self).__init__() self.conv1 = conv_layer(input_channels=channels, output_channels=channels, stride=1, kernel_size=kernel_size, apply_bn_relu=True) self.conv2 = conv_layer(input_channels=channels, output_channels=channels, stride=1, kernel_size=kernel_size, apply_bn_relu=apply_bn_relu)
def __init__(self, input_channels, output_channels, kernel_size): super(UpconvolutionLayer, self).__init__() self.conv = conv_layer(input_channels=input_channels, output_channels=output_channels, stride=1, kernel_size=kernel_size, apply_bn_relu=True)
def __init__(self): super(CostVolumeDecoder, self).__init__() self.inverse_depth_base = 1 / Config.train_max_depth self.inverse_depth_multiplier = 1 / Config.train_min_depth - 1 / Config.train_max_depth self.decoder_block1 = DecoderBlock(input_channels=hyper_channels * 16, output_channels=hyper_channels * 8, kernel_size=3, apply_bn_relu=True, plus_one=False) self.decoder_block2 = DecoderBlock(input_channels=hyper_channels * 8, output_channels=hyper_channels * 4, kernel_size=3, apply_bn_relu=True, plus_one=True) self.decoder_block3 = DecoderBlock(input_channels=hyper_channels * 4, output_channels=hyper_channels * 2, kernel_size=3, apply_bn_relu=True, plus_one=True) self.decoder_block4 = DecoderBlock(input_channels=hyper_channels * 2, output_channels=hyper_channels, kernel_size=5, apply_bn_relu=True, plus_one=True) self.refine = torch.nn.Sequential( conv_layer(input_channels=hyper_channels + 4, output_channels=hyper_channels, kernel_size=5, stride=1, apply_bn_relu=True), conv_layer(input_channels=hyper_channels, output_channels=hyper_channels, kernel_size=5, stride=1, apply_bn_relu=True)) self.depth_layer_one_sixteen = depth_layer_3x3(hyper_channels * 8) self.depth_layer_one_eight = depth_layer_3x3(hyper_channels * 4) self.depth_layer_quarter = depth_layer_3x3(hyper_channels * 2) self.depth_layer_half = depth_layer_3x3(hyper_channels) self.depth_layer_full = depth_layer_3x3(hyper_channels)
def __init__(self): super(CostVolumeEncoder, self).__init__() self.aggregator0 = conv_layer( input_channels=Config.train_n_depth_levels + fpn_output_channels, output_channels=hyper_channels, kernel_size=5, stride=1, apply_bn_relu=True) self.encoder_block0 = EncoderBlock(input_channels=hyper_channels, output_channels=hyper_channels * 2, kernel_size=5) ### self.aggregator1 = conv_layer(input_channels=hyper_channels * 2 + fpn_output_channels, output_channels=hyper_channels * 2, kernel_size=3, stride=1, apply_bn_relu=True) self.encoder_block1 = EncoderBlock(input_channels=hyper_channels * 2, output_channels=hyper_channels * 4, kernel_size=3) ### self.aggregator2 = conv_layer(input_channels=hyper_channels * 4 + fpn_output_channels, output_channels=hyper_channels * 4, kernel_size=3, stride=1, apply_bn_relu=True) self.encoder_block2 = EncoderBlock(input_channels=hyper_channels * 4, output_channels=hyper_channels * 8, kernel_size=3) ### self.aggregator3 = conv_layer(input_channels=hyper_channels * 8 + fpn_output_channels, output_channels=hyper_channels * 8, kernel_size=3, stride=1, apply_bn_relu=True) self.encoder_block3 = EncoderBlock(input_channels=hyper_channels * 8, output_channels=hyper_channels * 16, kernel_size=3)