コード例 #1
0
    def __init__(self, in_planes, hourglass_in_planes, batch_norm=True):
        super(DeepPrunerAggregator, self).__init__()
        self.in_planes = in_planes
        self.hourglass_in_planes = hourglass_in_planes
        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.dres2 = HWHourglass(hourglass_in_planes, batch_norm=batch_norm)

        self.classify = nn.Sequential(
            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))
    def __init__(self, in_planes, batchNorm=True):
        super(Hourglass, self).__init__()
        self.batchNorm = batchNorm

        self.conv1 = conv3d_bn_relu(self.batchNorm,
                                    in_planes,
                                    in_planes * 2,
                                    kernel_size=3,
                                    stride=2,
                                    padding=1,
                                    bias=False)

        self.conv2 = conv3d_bn(self.batchNorm,
                               in_planes * 2,
                               in_planes * 2,
                               kernel_size=3,
                               stride=1,
                               padding=1,
                               bias=False)

        self.conv3 = conv3d_bn_relu(self.batchNorm,
                                    in_planes * 2,
                                    in_planes * 2,
                                    kernel_size=3,
                                    stride=2,
                                    padding=1,
                                    bias=False)
        self.conv4 = conv3d_bn_relu(self.batchNorm,
                                    in_planes * 2,
                                    in_planes * 2,
                                    kernel_size=3,
                                    stride=1,
                                    padding=1,
                                    bias=False)
        self.conv5 = deconv3d_bn(self.batchNorm,
                                 in_planes * 2,
                                 in_planes * 2,
                                 kernel_size=3,
                                 padding=1,
                                 output_padding=1,
                                 stride=2,
                                 bias=False)
        self.conv6 = deconv3d_bn(self.batchNorm,
                                 in_planes * 2,
                                 in_planes,
                                 kernel_size=3,
                                 padding=1,
                                 output_padding=1,
                                 stride=2,
                                 bias=False)
コード例 #3
0
 def _make_layer(self, in_planes, out_planes, stride=1):
     return conv3d_bn_relu(self.batch_norm,
                           in_planes,
                           out_planes,
                           kernel_size=3,
                           stride=stride,
                           padding=1,
                           dilation=1,
                           bias=False)
コード例 #4
0
    def __init__(self, max_disp, in_planes=64, batch_norm=True):
        super(AcfAggregator, self).__init__()
        self.max_disp = max_disp
        self.in_planes = in_planes
        self.batch_norm = batch_norm

        self.dres0 = nn.Sequential(
            conv3d_bn_relu(batch_norm, self.in_planes, 32, 3, 1, 1),
            conv3d_bn_relu(batch_norm, 32, 32, 3, 1, 1),
        )
        self.dres1 = nn.Sequential(conv3d_bn_relu(batch_norm, 32, 32, 3, 1, 1),
                                   conv3d_bn(batch_norm, 32, 32, 3, 1, 1))
        self.dres2 = Hourglass(in_planes=32, batch_norm=batch_norm)
        self.dres3 = Hourglass(in_planes=32, batch_norm=batch_norm)
        self.dres4 = Hourglass(in_planes=32, batch_norm=batch_norm)

        self.classif1 = nn.Sequential(
            conv3d_bn_relu(batch_norm, 32, 32, 3, 1, 1),
            nn.Conv3d(32, 1, kernel_size=3, stride=1, padding=1, bias=False),
        )
        self.classif2 = nn.Sequential(
            conv3d_bn_relu(batch_norm, 32, 32, 3, 1, 1),
            nn.Conv3d(32, 1, kernel_size=3, stride=1, padding=1, bias=False),
        )
        self.classif3 = nn.Sequential(
            conv3d_bn_relu(batch_norm, 32, 32, 3, 1, 1),
            nn.Conv3d(32, 1, kernel_size=3, stride=1, padding=1, bias=False))

        self.deconv1 = nn.ConvTranspose3d(1, 1, 8, 4, 2, bias=False)
        self.deconv2 = nn.ConvTranspose3d(1, 1, 8, 4, 2, bias=False)
        self.deconv3 = nn.ConvTranspose3d(1, 1, 8, 4, 2, bias=False)
コード例 #5
0
    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)
コード例 #6
0
    def __init__(self, max_disp, in_planes=32, batch_norm=True, num=4):
        super(StereoNetAggregator, self).__init__()
        self.max_disp = max_disp
        self.in_planes = in_planes
        self.batch_norm = batch_norm
        self.num = num

        self.classify = nn.ModuleList([
            conv3d_bn_relu(self.batch_norm,
                           in_planes,
                           32,
                           kernel_size=3,
                           stride=1,
                           padding=1,
                           dilation=1,
                           bias=True) for _ in range(self.num)
        ])

        self.lastconv = nn.Conv3d(32,
                                  1,
                                  kernel_size=3,
                                  stride=1,
                                  padding=1,
                                  bias=True)
コード例 #7
0
    def __init__(self, in_planes, batch_norm=True):
        super(HWHourglass, self).__init__()
        self.batch_norm = batch_norm

        self.conv1_a = conv3d_bn_relu(self.batch_norm,
                                      in_planes,
                                      in_planes * 2,
                                      kernel_size=3,
                                      stride=(1, 2, 2),
                                      padding=1,
                                      bias=False)

        self.conv1_b = conv3d_bn_relu(self.batch_norm,
                                      in_planes * 2,
                                      in_planes * 2,
                                      kernel_size=3,
                                      stride=(1, 1, 1),
                                      padding=1,
                                      bias=False)

        self.conv1_d = deconv3d_bn(self.batch_norm,
                                   in_planes * 2,
                                   in_planes,
                                   kernel_size=3,
                                   padding=1,
                                   output_padding=(0, 1, 1),
                                   stride=(1, 2, 2),
                                   bias=False)

        self.conv2_a = conv3d_bn_relu(self.batch_norm,
                                      in_planes * 2,
                                      in_planes * 4,
                                      kernel_size=3,
                                      stride=(1, 2, 2),
                                      padding=1,
                                      bias=False)

        self.conv2_b = conv3d_bn_relu(self.batch_norm,
                                      in_planes * 4,
                                      in_planes * 4,
                                      kernel_size=3,
                                      stride=(1, 1, 1),
                                      padding=1,
                                      bias=False)

        self.conv2_d = deconv3d_bn(self.batch_norm,
                                   in_planes * 4,
                                   in_planes * 2,
                                   kernel_size=3,
                                   padding=1,
                                   output_padding=(0, 1, 1),
                                   stride=(1, 2, 2),
                                   bias=False)

        self.conv3_a = conv3d_bn_relu(self.batch_norm,
                                      in_planes * 4,
                                      in_planes * 8,
                                      kernel_size=3,
                                      stride=(1, 2, 2),
                                      padding=1,
                                      bias=False)

        self.conv3_b = conv3d_bn_relu(self.batch_norm,
                                      in_planes * 8,
                                      in_planes * 8,
                                      kernel_size=3,
                                      stride=(1, 1, 1),
                                      padding=1,
                                      bias=False)

        self.conv3_d = deconv3d_bn(self.batch_norm,
                                   in_planes * 8,
                                   in_planes * 4,
                                   kernel_size=3,
                                   padding=1,
                                   output_padding=(0, 1, 1),
                                   stride=(1, 2, 2),
                                   bias=False)