示例#1
0
    def __init__(self, num_F=32):
        super(feature2d, self).__init__()
        self.inplanes = 32
        self.F = num_F

        self.conv1 = conv2d_bn(3, 32, kernel_size=5, stride=2, flag_bias=flag_bias_t, bn=flag_bn, activefun=activefun_t)
        self.block1 = conv_res(32, 32, blocks=8, stride=1)
        self.conv2 = nn.Conv2d(32, 32, kernel_size=3, stride=1, padding=1)
示例#2
0
    def __init__(self, maxdisparity=192):
        super(dispnet, self).__init__()
        self.name = "dispnet"
        #self.D = maxdisparity
        self.delt = 1e-6

        # 卷积层
        self.conv1 = conv2d_bn(6, 64, kernel_size=7, stride=2, bn=flag_bn, activefun=activefun_default)
        self.conv2 = conv2d_bn(64, 128, kernel_size=5, stride=2, bn=flag_bn, activefun=activefun_default)
        self.conv3a = conv2d_bn(128, 256, kernel_size=5, stride=2, bn=flag_bn, activefun=activefun_default)
        self.conv3b = conv2d_bn(256, 256, kernel_size=3, stride=1, bn=flag_bn, activefun=activefun_default)
        self.conv4a = conv2d_bn(256, 512, kernel_size=3, stride=2, bn=flag_bn, activefun=activefun_default)
        self.conv4b = conv2d_bn(512, 512, kernel_size=3, stride=1, bn=flag_bn, activefun=activefun_default)
        self.conv5a = conv2d_bn(512, 512, kernel_size=3, stride=2, bn=flag_bn, activefun=activefun_default)
        self.conv5b = conv2d_bn(512, 512, kernel_size=3, stride=1, bn=flag_bn, activefun=activefun_default)
        self.conv6a = conv2d_bn(512, 1024, kernel_size=3, stride=2, bn=flag_bn, activefun=activefun_default)
        self.conv6b = conv2d_bn(1024, 1024, kernel_size=3, stride=1, bn=flag_bn, activefun=activefun_default)
        
        # 解卷积层和视差预测层
        self.pr6 = nn.Conv2d(1024, 1, kernel_size=3, stride=1, padding=1)
        
        self.deconv5 = deconv4x4_bn(1024, 512, bn=flag_bn, activefun=activefun_default)
        self.iconv5 = conv2d_bn(1025, 512, kernel_size=3, stride=1, bn=flag_bn, activefun=activefun_default)
        self.pr5 = nn.Conv2d(512, 1, kernel_size=3, stride=1, padding=1)
        
        self.deconv4 = deconv4x4_bn(512, 256, bn=flag_bn, activefun=activefun_default)
        self.iconv4 = conv2d_bn(769, 256, kernel_size=3, stride=1, bn=flag_bn, activefun=activefun_default)
        self.pr4 = nn.Conv2d(256, 1, kernel_size=3, stride=1, padding=1)
        
        self.deconv3 = deconv4x4_bn(256, 128,  bn=flag_bn, activefun=activefun_default)
        self.iconv3 = conv2d_bn(385, 128, kernel_size=3, stride=1, bn=flag_bn, activefun=activefun_default)
        self.pr3 = nn.Conv2d(128, 1, kernel_size=3, stride=1, padding=1)
        
        self.deconv2 = deconv4x4_bn(128, 64, bn=flag_bn, activefun=activefun_default)
        self.iconv2 = conv2d_bn(193, 64, kernel_size=3, stride=1, bn=flag_bn, activefun=activefun_default)
        self.pr2 = nn.Conv2d(64, 1, kernel_size=3, stride=1, padding=1)
        
        self.deconv1 = deconv4x4_bn(64, 32, bn=flag_bn, activefun=activefun_default)
        self.iconv1 = conv2d_bn(97, 32, kernel_size=3, stride=1, bn=flag_bn, activefun=activefun_default)
        self.pr1 = nn.Conv2d(32, 1, kernel_size=3, stride=1, padding=1)
        
        self.upsample = nn.Upsample(scale_factor=2, mode='bilinear')
        
        # 权重初始化
        net_init(self)
示例#3
0
    def __init__(self, maxdisparity=192):
        super(dispnet, self).__init__()
        self.name = "dispnet"
        self.D = maxdisparity
        self.delt = 1e-6
        self.count_levels = 7 # 分辨率层数

        # 上采样(2倍)
        self.upsample = nn.Upsample(scale_factor=2, mode='bilinear')
        
        # 卷积层
        self.conv1 = conv2d_bn(6, 64, kernel_size=7, stride=2, flag_bias=flag_bias_t, bn=flag_bn, activefun=activefun_t)
        self.conv2 = conv2d_bn(64, 128, kernel_size=5, stride=2, flag_bias=flag_bias_t, bn=flag_bn, activefun=activefun_t)
        self.conv3a = conv2d_bn(128, 256, kernel_size=5, stride=2, flag_bias=flag_bias_t, bn=flag_bn, activefun=activefun_t)
        self.conv3b = conv2d_bn(256, 256, kernel_size=3, stride=1, flag_bias=flag_bias_t, bn=flag_bn, activefun=activefun_t)
        self.conv4a = conv2d_bn(256, 512, kernel_size=3, stride=2, flag_bias=flag_bias_t, bn=flag_bn, activefun=activefun_t)
        self.conv4b = conv2d_bn(512, 512, kernel_size=3, stride=1, flag_bias=flag_bias_t, bn=flag_bn, activefun=activefun_t)
        self.conv5a = conv2d_bn(512, 512, kernel_size=3, stride=2, flag_bias=flag_bias_t, bn=flag_bn, activefun=activefun_t)
        self.conv5b = conv2d_bn(512, 512, kernel_size=3, stride=1, flag_bias=flag_bias_t, bn=flag_bn, activefun=activefun_t)
        self.conv6a = conv2d_bn(512, 1024, kernel_size=3, stride=2, flag_bias=flag_bias_t, bn=flag_bn, activefun=activefun_t)
        self.conv6b = conv2d_bn(1024, 1024, kernel_size=3, stride=1, flag_bias=flag_bias_t, bn=flag_bn, activefun=activefun_t)
        
        # 解卷积层和视差预测层
        self.pr6 = nn.Conv2d(1024, 1, kernel_size=3, stride=1, padding=1)
        
        self.deconv5 = deconv2d_bn(1024, 512, kernel_size=4, stride=2, flag_bias=flag_bias_t, bn=flag_bn, activefun=activefun_t)
        self.iconv5 = conv2d_bn(1025, 512, kernel_size=3, stride=1, flag_bias=flag_bias_t, bn=flag_bn, activefun=activefun_t)
        self.pr5 = nn.Conv2d(512, 1, kernel_size=3, stride=1, padding=1)
        
        self.deconv4 = deconv2d_bn(512, 256, kernel_size=4, stride=2, flag_bias=flag_bias_t, bn=flag_bn, activefun=activefun_t)
        self.iconv4 = conv2d_bn(769, 256, kernel_size=3, stride=1, flag_bias=flag_bias_t, bn=flag_bn, activefun=activefun_t)
        self.pr4 = nn.Conv2d(256, 1, kernel_size=3, stride=1, padding=1)
        
        self.deconv3 = deconv2d_bn(256, 128, kernel_size=4, stride=2, flag_bias=flag_bias_t, bn=flag_bn, activefun=activefun_t)
        self.iconv3 = conv2d_bn(385, 128, kernel_size=3, stride=1, flag_bias=flag_bias_t, bn=flag_bn, activefun=activefun_t)
        self.pr3 = nn.Conv2d(128, 1, kernel_size=3, stride=1, padding=1)
        
        self.deconv2 = deconv2d_bn(128, 64, kernel_size=4, stride=2, flag_bias=flag_bias_t, bn=flag_bn, activefun=activefun_t)
        self.iconv2 = conv2d_bn(193, 64, kernel_size=3, stride=1, flag_bias=flag_bias_t, bn=flag_bn, activefun=activefun_t)
        self.pr2 = nn.Conv2d(64, 1, kernel_size=3, stride=1, padding=1)
        
        self.deconv1 = deconv2d_bn(64, 32, kernel_size=4, stride=2, flag_bias=flag_bias_t, bn=flag_bn, activefun=activefun_t)
        self.iconv1 = conv2d_bn(97, 32, kernel_size=3, stride=1, flag_bias=flag_bias_t, bn=flag_bn, activefun=activefun_t)
        self.pr1 = nn.Conv2d(32, 1, kernel_size=3, stride=1, padding=1)
        
        # 权重初始化
        net_init(self)
        for m in [self.pr6, self.pr5, self.pr4, self.pr3, self.pr2, self.pr1]:
            m.weight.data = m.weight.data*0.1
示例#4
0
    def __init__(self, maxdisparity=192):
        super(iresnet, self).__init__()
        self.name = "iresnet"
        self.D = maxdisparity
        self.delt = 1e-6
        self.count_levels = 7  # 分辨率层数

        self.upsample = nn.Upsample(scale_factor=2, mode='bilinear')
        # Stem Block for Multi-scale Shared Features Extraction
        self.conv1 = conv2d_bn(3,
                               64,
                               kernel_size=7,
                               stride=2,
                               flag_bias=flag_bias_t,
                               bn=flag_bn,
                               activefun=activefun_t)
        self.conv2 = conv2d_bn(64,
                               128,
                               kernel_size=5,
                               stride=2,
                               flag_bias=flag_bias_t,
                               bn=flag_bn,
                               activefun=activefun_t)
        self.deconv1_s = deconv2d_bn(64,
                                     32,
                                     kernel_size=4,
                                     stride=2,
                                     flag_bias=flag_bias_t,
                                     bn=flag_bn,
                                     activefun=activefun_t)  # stride=2
        self.deconv2_s = deconv2d_bn(128,
                                     32,
                                     kernel_size=8,
                                     stride=4,
                                     flag_bias=flag_bias_t,
                                     bn=flag_bn,
                                     activefun=activefun_t)  # stride=4
        self.conv_de1_de2 = conv2d_bn(64,
                                      32,
                                      kernel_size=1,
                                      stride=1,
                                      flag_bias=flag_bias_t,
                                      bn=flag_bn,
                                      activefun=activefun_t)

        # Initial Disparity Estimation Sub-network
        self.corr = Corr1d(kernel_size=1, stride=1, D=81, simfun=None)
        self.redir = conv2d_bn(128,
                               64,
                               kernel_size=1,
                               stride=1,
                               flag_bias=flag_bias_t,
                               bn=flag_bn,
                               activefun=activefun_t)
        self.conv3 = conv2d_bn(81 + 64,
                               256,
                               kernel_size=3,
                               stride=2,
                               flag_bias=flag_bias_t,
                               bn=flag_bn,
                               activefun=activefun_t)
        self.conv3_1 = conv2d_bn(256,
                                 256,
                                 kernel_size=3,
                                 stride=1,
                                 flag_bias=flag_bias_t,
                                 bn=flag_bn,
                                 activefun=activefun_t)
        self.conv4 = conv2d_bn(256,
                               512,
                               kernel_size=3,
                               stride=2,
                               flag_bias=flag_bias_t,
                               bn=flag_bn,
                               activefun=activefun_t)
        self.conv4_1 = conv2d_bn(512,
                                 512,
                                 kernel_size=3,
                                 stride=1,
                                 flag_bias=flag_bias_t,
                                 bn=flag_bn,
                                 activefun=activefun_t)
        self.conv5 = conv2d_bn(512,
                               512,
                               kernel_size=3,
                               stride=2,
                               flag_bias=flag_bias_t,
                               bn=flag_bn,
                               activefun=activefun_t)
        self.conv5_1 = conv2d_bn(512,
                                 512,
                                 kernel_size=3,
                                 stride=1,
                                 flag_bias=flag_bias_t,
                                 bn=flag_bn,
                                 activefun=activefun_t)
        self.conv6 = conv2d_bn(512,
                               1024,
                               kernel_size=3,
                               stride=2,
                               flag_bias=flag_bias_t,
                               bn=flag_bn,
                               activefun=activefun_t)
        self.conv6_1 = conv2d_bn(1024,
                                 1024,
                                 kernel_size=3,
                                 stride=1,
                                 flag_bias=flag_bias_t,
                                 bn=flag_bn,
                                 activefun=activefun_t)
        self.pr6 = nn.Conv2d(1024, 1, kernel_size=3, stride=1, padding=1)
        self.deconv5 = deconv2d_bn(1024,
                                   512,
                                   kernel_size=4,
                                   stride=2,
                                   flag_bias=flag_bias_t,
                                   bn=flag_bn,
                                   activefun=activefun_t)  # stride=2
        self.iconv5 = conv2d_bn(1025,
                                512,
                                kernel_size=3,
                                stride=1,
                                flag_bias=flag_bias_t,
                                bn=flag_bn,
                                activefun=activefun_t)
        self.pr5 = nn.Conv2d(512, 1, kernel_size=3, stride=1, padding=1)
        self.deconv4 = deconv2d_bn(512,
                                   256,
                                   kernel_size=4,
                                   stride=2,
                                   flag_bias=flag_bias_t,
                                   bn=flag_bn,
                                   activefun=activefun_t)  # stride=2
        self.iconv4 = conv2d_bn(769,
                                256,
                                kernel_size=3,
                                stride=1,
                                flag_bias=flag_bias_t,
                                bn=flag_bn,
                                activefun=activefun_t)
        self.pr4 = nn.Conv2d(256, 1, kernel_size=3, stride=1, padding=1)
        self.deconv3 = deconv2d_bn(256,
                                   128,
                                   kernel_size=4,
                                   stride=2,
                                   flag_bias=flag_bias_t,
                                   bn=flag_bn,
                                   activefun=activefun_t)  # stride=2
        self.iconv3 = conv2d_bn(385,
                                128,
                                kernel_size=3,
                                stride=1,
                                flag_bias=flag_bias_t,
                                bn=flag_bn,
                                activefun=activefun_t)
        self.pr3 = nn.Conv2d(128, 1, kernel_size=3, stride=1, padding=1)
        self.deconv2 = deconv2d_bn(128,
                                   64,
                                   kernel_size=4,
                                   stride=2,
                                   flag_bias=flag_bias_t,
                                   bn=flag_bn,
                                   activefun=activefun_t)  # stride=2
        self.iconv2 = conv2d_bn(193,
                                64,
                                kernel_size=3,
                                stride=1,
                                flag_bias=flag_bias_t,
                                bn=flag_bn,
                                activefun=activefun_t)
        self.pr2 = nn.Conv2d(64, 1, kernel_size=3, stride=1, padding=1)
        self.deconv1 = deconv2d_bn(64,
                                   32,
                                   kernel_size=4,
                                   stride=2,
                                   flag_bias=flag_bias_t,
                                   bn=flag_bn,
                                   activefun=activefun_t)  # stride=2
        self.iconv1 = conv2d_bn(97,
                                32,
                                kernel_size=3,
                                stride=1,
                                flag_bias=flag_bias_t,
                                bn=flag_bn,
                                activefun=activefun_t)
        self.pr1 = nn.Conv2d(32, 1, kernel_size=3, stride=1, padding=1)
        self.deconv0 = deconv2d_bn(32,
                                   32,
                                   kernel_size=4,
                                   stride=2,
                                   flag_bias=flag_bias_t,
                                   bn=flag_bn,
                                   activefun=activefun_t)  # stride=2
        self.iconv0 = conv2d_bn(65,
                                32,
                                kernel_size=3,
                                stride=1,
                                flag_bias=flag_bias_t,
                                bn=flag_bn,
                                activefun=activefun_t)
        self.pr0 = nn.Conv2d(32, 1, kernel_size=3, stride=1, padding=1)

        # Disparity Refinement Sub-network
        #imwrap up_conv1b2b
        self.r_conv0 = conv2d_bn(65,
                                 32,
                                 kernel_size=3,
                                 stride=1,
                                 flag_bias=flag_bias_t,
                                 bn=flag_bn,
                                 activefun=activefun_t)
        self.r_conv1 = conv2d_bn(32,
                                 64,
                                 kernel_size=3,
                                 stride=2,
                                 flag_bias=flag_bias_t,
                                 bn=flag_bn,
                                 activefun=activefun_t)
        self.c_conv1 = conv2d_bn(64,
                                 64,
                                 kernel_size=3,
                                 stride=1,
                                 flag_bias=flag_bias_t,
                                 bn=flag_bn,
                                 activefun=activefun_t)
        self.r_corr = Corr1d(kernel_size=3, stride=2, D=41, simfun=None)
        self.r_conv1_1 = conv2d_bn(105,
                                   64,
                                   kernel_size=3,
                                   stride=1,
                                   flag_bias=flag_bias_t,
                                   bn=flag_bn,
                                   activefun=activefun_t)
        self.r_conv2 = conv2d_bn(64,
                                 128,
                                 kernel_size=3,
                                 stride=2,
                                 flag_bias=flag_bias_t,
                                 bn=flag_bn,
                                 activefun=activefun_t)
        self.r_conv2_1 = conv2d_bn(128,
                                   128,
                                   kernel_size=3,
                                   stride=1,
                                   flag_bias=flag_bias_t,
                                   bn=flag_bn,
                                   activefun=activefun_t)
        self.r_res2 = nn.Conv2d(128, 1, kernel_size=3, stride=1, padding=1)
        self.r_deconv1 = deconv2d_bn(128,
                                     64,
                                     kernel_size=4,
                                     stride=2,
                                     flag_bias=flag_bias_t,
                                     bn=flag_bn,
                                     activefun=activefun_t)  # stride=2
        self.r_iconv1 = conv2d_bn(129,
                                  64,
                                  kernel_size=3,
                                  stride=1,
                                  flag_bias=flag_bias_t,
                                  bn=flag_bn,
                                  activefun=activefun_t)
        self.r_res1 = nn.Conv2d(64, 1, kernel_size=3, stride=1, padding=1)
        self.r_deconv0 = deconv2d_bn(64,
                                     32,
                                     kernel_size=4,
                                     stride=2,
                                     flag_bias=flag_bias_t,
                                     bn=flag_bn,
                                     activefun=activefun_t)  # stride=2
        self.r_iconv0 = conv2d_bn(65,
                                  32,
                                  kernel_size=3,
                                  stride=1,
                                  flag_bias=flag_bias_t,
                                  bn=flag_bn,
                                  activefun=activefun_t)
        self.r_res0 = nn.Conv2d(32, 1, kernel_size=3, stride=1, padding=1)

        # init weight
        net_init(self)
        for m in [
                self.pr6, self.pr5, self.pr4, self.pr3, self.pr2, self.pr1,
                self.r_res2, self.r_res1, self.r_res0
        ]:
            m.weight.data = m.weight.data * 0.1