def __init__(self, num_feat=64, deformable_groups=8): super(PCDAlignment, self).__init__() # Pyramid has three levels: # L3: level 3, 1/4 spatial size # L2: level 2, 1/2 spatial size # L1: level 1, original spatial size self.offset_conv1 = nn.ModuleDict() self.offset_conv2 = nn.ModuleDict() self.offset_conv3 = nn.ModuleDict() self.dcn_pack = nn.ModuleDict() self.feat_conv = nn.ModuleDict() # Pyramids for i in range(3, 0, -1): level = f'l{i}' self.offset_conv1[level] = nn.Conv2d(num_feat * 2, num_feat, 3, 1, 1) if i == 3: self.offset_conv2[level] = nn.Conv2d(num_feat, num_feat, 3, 1, 1) else: self.offset_conv2[level] = nn.Conv2d(num_feat * 2, num_feat, 3, 1, 1) self.offset_conv3[level] = nn.Conv2d(num_feat, num_feat, 3, 1, 1) self.dcn_pack[level] = DCNv2Pack( num_feat, num_feat, 3, padding=1, deformable_groups=deformable_groups) if i < 3: self.feat_conv[level] = nn.Conv2d(num_feat * 2, num_feat, 3, 1, 1) # Cascading dcn self.cas_offset_conv1 = nn.Conv2d(num_feat * 2, num_feat, 3, 1, 1) self.cas_offset_conv2 = nn.Conv2d(num_feat, num_feat, 3, 1, 1) self.cas_dcnpack = DCNv2Pack(num_feat, num_feat, 3, padding=1, deformable_groups=deformable_groups) self.upsample = nn.Upsample(scale_factor=2, mode='bilinear', align_corners=False) self.lrelu = nn.LeakyReLU(negative_slope=0.1, inplace=True)
def __init__(self, num_feat=64, deformable_groups=8): super(PreDcn, self).__init__() self.offset_conv1 = nn.ModuleDict() self.dcn_pack = nn.ModuleDict() self.feat_conv = nn.ModuleDict() # Cascading dcn self.cas_offset_conv1 = nn.Conv2d(num_feat * 2, num_feat, 3, 1, 1) self.cas_offset_conv2 = nn.Conv2d(num_feat, num_feat, 3, 1, 1) self.cas_dcnpack = DCNv2Pack(num_feat, num_feat, 3, padding=1, deformable_groups=deformable_groups) self.upsample = nn.Upsample(scale_factor=2, mode='bilinear', align_corners=False) self.lrelu = nn.LeakyReLU(negative_slope=0.1, inplace=True)