def __init__(self, in_planes, C=16, batch_norm=True): super(WarpErrorRefinement, self).__init__() self.in_planes = in_planes self.batch_norm = batch_norm self.C = C self.conv_mix = conv_bn_relu(batch_norm, in_planes * 4 + 1, 2 * C, kernel_size=3, stride=1, padding=1, dilation=1, bias=False) # Dilated residual module self.residual_dilation_blocks = nn.ModuleList() self.dilation_list = [1, 2, 4, 8, 1, 1] for dilation in self.dilation_list: self.residual_dilation_blocks.append( conv_bn_relu(batch_norm, 2 * C, 2 * C, kernel_size=3, stride=1, padding=dilation, dilation=dilation, bias=False)) self.conv_res = nn.Conv2d(2 * C, 1, kernel_size=3, stride=1, padding=1, bias=True)
def __init__(self, in_planes, spn_planes=8, batch_norm=True): super(AnyNetRefinement, self).__init__() self.in_planes = in_planes self.spn_planes = spn_planes self.batch_norm = batch_norm self.img_conv = nn.Sequential( conv_bn_relu(batch_norm, in_planes, spn_planes * 2, kernel_size=3, stride=1, padding=1, dilation=1, bias=False), conv_bn_relu(batch_norm, spn_planes * 2, spn_planes * 2, kernel_size=3, stride=1, padding=1, dilation=1, bias=False), conv_bn_relu(batch_norm, spn_planes * 2, spn_planes * 2, kernel_size=3, stride=1, padding=1, dilation=1, bias=False), nn.Conv2d(spn_planes * 2, spn_planes * 3, kernel_size=3, stride=1, padding=1, dilation=1, bias=False), ) self.disp_conv = nn.Conv2d(1, spn_planes, kernel_size=3, stride=1, padding=1, dilation=1, bias=False) self.classify = nn.Conv2d(spn_planes, 1, kernel_size=3, stride=1, padding=1, dilation=1, bias=False) # left->right propagation self.spn = GateRecurrent2dnoind(True, False)
def __init__(self, in_planes, batch_norm=True): super(Hourglass2D, self).__init__() self.batch_norm = batch_norm self.conv1 = conv_bn_relu(self.batch_norm, in_planes, in_planes * 2, kernel_size=3, stride=2, padding=1, bias=False) self.conv2 = conv_bn(self.batch_norm, in_planes * 2, in_planes * 2, kernel_size=3, stride=1, padding=1, bias=False) self.conv3 = conv_bn_relu(self.batch_norm, in_planes * 2, in_planes * 2, kernel_size=3, stride=2, padding=1, bias=False) self.conv4 = conv_bn_relu(self.batch_norm, in_planes * 2, in_planes * 2, kernel_size=3, stride=1, padding=1, bias=False) self.conv5 = deconv_bn(self.batch_norm, in_planes * 2, in_planes * 2, kernel_size=3, padding=1, output_padding=1, stride=2, bias=False) self.conv6 = deconv_bn(self.batch_norm, in_planes * 2, in_planes, kernel_size=3, padding=1, output_padding=1, stride=2, bias=False)
def __init__(self, in_planes, hourglass_in_planes, disparity_sample_number, batch_norm=True): super(ConfidenceRangePredictor, self).__init__() self.in_planes = in_planes self.hourglass_in_planes = hourglass_in_planes self.disparity_sample_number = disparity_sample_number self.batch_norm = batch_norm self.dres0 = nn.Sequential( conv3d_bn_relu(batch_norm, in_planes, 64, kernel_size=3, stride=1, padding=1, bias=False), conv3d_bn_relu(batch_norm, 64, 32, kernel_size=3, stride=1, padding=1, bias=False), ) self.dres1 = nn.Sequential( conv3d_bn_relu(batch_norm, 32, 32, kernel_size=3, stride=1, padding=1, bias=False), conv3d_bn_relu(batch_norm, 32, hourglass_in_planes, kernel_size=3, stride=1, padding=1, bias=False), ) self.min_disparity_predictor = nn.Sequential( HWHourglass(hourglass_in_planes, batch_norm), conv3d_bn_relu(batch_norm, hourglass_in_planes, hourglass_in_planes*2, kernel_size=3, stride=1, padding=1, bias=False), nn.Conv3d(hourglass_in_planes*2, 1, kernel_size=3, stride=1, padding=1, bias=False) ) self.max_disparity_predictor = nn.Sequential( HWHourglass(hourglass_in_planes, batch_norm), conv3d_bn_relu(batch_norm, hourglass_in_planes, hourglass_in_planes*2, kernel_size=3, stride=1, padding=1, bias=False), nn.Conv3d(hourglass_in_planes*2, 1, kernel_size=3, stride=1, padding=1, bias=False) ) # batch norm cannot be used here, as disparity map is the input and output self.min_disparity_conv = nn.Sequential( nn.Conv2d(1, 1, kernel_size=5, stride=1, padding=2, bias=True), nn.ReLU(inplace=True) ) # batch norm cannot be used here, as disparity map is the input and output self.max_disparity_conv = nn.Sequential( nn.Conv2d(1, 1, kernel_size=5, stride=1, padding=2, bias=True), nn.ReLU(inplace=True) ) self.min_disparity_feature_conv = conv_bn_relu(batch_norm, disparity_sample_number, disparity_sample_number, kernel_size=5, stride=1, padding=2, dilation=1, bias=True) self.max_disparity_feature_conv = conv_bn_relu(batch_norm, disparity_sample_number, disparity_sample_number, kernel_size=5, stride=1, padding=2, dilation=1, bias=True)
def __init__(self, cfg): super(DeepPrunerProcessor, self).__init__() self.cfg = cfg.copy() self.batch_norm = cfg.model.batch_norm self.patch_match_disparity_sample_number = cfg.model.cost_processor.patch_match_disparity_sample_number self.uniform_disparity_sample_number = cfg.model.cost_processor.uniform_disparity_sample_number # setting confidence range predictor self.confidence_range_predictor_args = cfg.model.cost_processor.confidence_range_predictor self.confidence_range_predictor_args.update( # besides the disparity samples generated by PatchMatch, it also includes min, max disparity disparity_sample_number=self.patch_match_disparity_sample_number, batch_norm = self.batch_norm ) self.confidence_range_predictor = ConfidenceRangePredictor( **self.confidence_range_predictor_args ) # setting cost aggregator self.cost_aggregator = build_cost_aggregator(cfg) # batch norm cannot be used here, as disparity map is the input and output self.disparity_conv = nn.Sequential( nn.Conv2d(1, 1, kernel_size=5, stride=1, padding=2, bias=True), nn.ReLU(inplace=True) ) self.disparity_feature_conv = conv_bn_relu(self.batch_norm, in_planes=self.uniform_disparity_sample_number, out_planes=self.uniform_disparity_sample_number, kernel_size=5, stride=1, padding=2, dilation=1, bias=True)
def __init__(self, in_planes, batchNorm=True): super(WarpErrorRefinement, self).__init__() self.in_planes = in_planes self.batchNorm = batchNorm self.conv_mix = conv_bn_relu(batchNorm, in_planes * 4 + 1, in_planes, kernel_size=3, stride=1, padding=1, dilation=1, bias=False) # Dilated residual module self.residual_dilation_blocks = nn.ModuleList() self.dilation_list = [1, 2, 4, 8, 1, 1] for dilation in self.dilation_list: self.residual_astrous_blocks.append( BasicBlock(self.batch_norm, 32, 32, stride=1, downsample=None, padding=1, dilation=dilation)) self.conv_res = nn.Conv2d(32, 1, kernel_size=3, stride=1, padding=1, bias=True)
def __init__(self, in_planes, out_planes, dropout_rate=0., batch_norm=True): super(DenseAspp, self).__init__() self.batch_norm = batch_norm in_planes = int(in_planes) in_2_planes = int(in_planes / 2) in_4_planes = int(in_planes / 4) self.ASPP_3 = _DenseAsppBlock(in_planes=in_planes, mid_planes=in_2_planes, out_planes=in_4_planes, dilation_rate=3, dropout_rate=dropout_rate, bn_start=False, batch_norm=batch_norm) self.ASPP_6 = _DenseAsppBlock(in_planes=in_planes + in_4_planes * 1 , mid_planes=in_2_planes, out_planes=in_4_planes, dilation_rate=6, dropout_rate=dropout_rate, bn_start=batch_norm, batch_norm=batch_norm) self.ASPP_12 = _DenseAsppBlock(in_planes=in_planes + in_4_planes * 2, mid_planes=in_2_planes, out_planes=in_4_planes, dilation_rate=12, dropout_rate=dropout_rate, bn_start=batch_norm, batch_norm=batch_norm) self.ASPP_18 = _DenseAsppBlock(in_planes=in_planes + in_4_planes * 3, mid_planes=in_2_planes, out_planes=in_4_planes, dilation_rate=18, dropout_rate=dropout_rate, bn_start=batch_norm, batch_norm=batch_norm) self.ASPP_24 = _DenseAsppBlock(in_planes=in_planes + in_4_planes * 4, mid_planes=in_2_planes, out_planes=in_4_planes, dilation_rate=24, dropout_rate=dropout_rate, bn_start=batch_norm, batch_norm=batch_norm) self.fuse_conv = nn.Sequential(conv_bn_relu(batch_norm, in_planes + in_4_planes * 5, in_planes, kernel_size=3, stride=1, padding=1, dilation=1, bias=False), nn.Conv2d(in_planes, out_planes, kernel_size=1, padding=0, dilation=1, bias=False))
def __init__(self, in_planes=3, batch_norm=True): super(DeepPrunerFastBackbone, self).__init__() self.in_planes = in_planes self.batch_norm = batch_norm self.firstconv = nn.Sequential( conv_bn_relu(batch_norm, self.in_planes, 32, 3, 2, 1, 1, bias=False), conv_bn_relu(batch_norm, 32, 32, 3, 1, 1, 1, bias=False), conv_bn_relu(batch_norm, 32, 32, 3, 1, 1, 1, bias=False), ) # For building Basic Block self.in_planes = 32 self.layer1 = self._make_layer(batch_norm, BasicBlock, 32, 3, 1, 1, 1) self.layer2 = self._make_layer(batch_norm, BasicBlock, 64, 16, 2, 1, 1) self.layer3 = self._make_layer(batch_norm, BasicBlock, 128, 3, 2, 1, 1) self.layer4 = self._make_layer(batch_norm, BasicBlock, 128, 3, 1, 1, 1) self.branch2 = nn.Sequential( nn.AvgPool2d((32, 32), stride=(32, 32)), conv_bn_relu(batch_norm, 128, 32, 1, 1, 0, 1, bias=False), ) self.branch3 = nn.Sequential( nn.AvgPool2d((16, 16), stride=(16, 16)), conv_bn_relu(batch_norm, 128, 32, 1, 1, 0, 1, bias=False), ) self.branch4 = nn.Sequential( nn.AvgPool2d((8, 8), stride=(8, 8)), conv_bn_relu(batch_norm, 128, 32, 1, 1, 0, 1, bias=False), ) self.lastconv = nn.Sequential( conv_bn_relu(batch_norm, 352, 128, 3, 1, 1, 1, bias=False), nn.Conv2d(128, 32, kernel_size=1, padding=0, stride=1, dilation=1, bias=False) )
def __init__(self, in_planes, batch_norm=True): super(ConfHead, self).__init__() self.in_planes = in_planes self.sec_in_planes = int(self.in_planes // 3) self.sec_in_planes = self.sec_in_planes if self.sec_in_planes > 0 else 1 self.conf_net = nn.Sequential( conv_bn_relu(batch_norm, self.in_planes, self.sec_in_planes, 3, 1, 1, bias=False), nn.Conv2d(self.sec_in_planes, 1, 1, 1, 0, bias=False) )
def __init__(self, in_planes, batch_norm=True): super(RefinementHeand, self).__init__() self.in_planes = in_planes self.batch_norm = batch_norm self.conv = nn.Sequential( conv_bn_relu(batch_norm, in_planes, 32, kernel_size=3, stride=1, padding=1, bias=False), conv_bn_relu(batch_norm, 32, 32, kernel_size=3, stride=1, padding=1, dilation=1, bias=False), conv_bn_relu(batch_norm, 32, 32, kernel_size=3, stride=1, padding=1, dilation=1, bias=False), conv_bn_relu(batch_norm, 32, 16, kernel_size=3, stride=1, padding=2, dilation=2, bias=False), conv_bn_relu(batch_norm, 16, 16, kernel_size=3, stride=1, padding=4, dilation=4, bias=False), conv_bn_relu(batch_norm, 16, 16, kernel_size=3, stride=1, padding=1, dilation=1, bias=False)) self.classify = nn.Conv2d(16, 1, kernel_size=3, padding=1, stride=1, bias=False)
def __init__(self, in_planes, batch_norm=True): super(GCNetBackbone, self).__init__() self.in_planes = in_planes self.backbone = nn.Sequential( conv_bn_relu(batch_norm, self.in_planes, 32, 5, 2, 2), BasicBlock(batch_norm, 32, 32, 1, None, 1, 1), BasicBlock(batch_norm, 32, 32, 1, None, 1, 1), BasicBlock(batch_norm, 32, 32, 1, None, 1, 1), BasicBlock(batch_norm, 32, 32, 1, None, 1, 1), BasicBlock(batch_norm, 32, 32, 1, None, 1, 1), BasicBlock(batch_norm, 32, 32, 1, None, 1, 1), BasicBlock(batch_norm, 32, 32, 1, None, 1, 1), BasicBlock(batch_norm, 32, 32, 1, None, 1, 1), nn.Conv2d(32, 32, 3, 1, 1))