def __init__(self, in_channels, out_channels, expansion=6, stride=2): super().__init__() self.use_shortcut = stride == 1 and in_channels == out_channels expand_channels = in_channels * expansion self.block = nn.Sequential( # pw ConvBNReLU( in_channels=in_channels, out_channels=expand_channels, kernel_size=1, bias_attr=False), # dw ConvBNReLU( in_channels=expand_channels, out_channels=expand_channels, kernel_size=3, stride=stride, padding=1, groups=expand_channels, bias_attr=False), # pw-linear ConvBN( in_channels=expand_channels, out_channels=out_channels, kernel_size=1, bias_attr=False))
def __init__(self, in_channels): super().__init__() self.double_conv = nn.Sequential(ConvBNReLU(in_channels, 64, 3), ConvBNReLU(64, 64, 3)) down_channels = [[64, 128], [128, 256], [256, 512], [512, 512]] self.down_sample_list = nn.LayerList([ self.down_sampling(channel[0], channel[1]) for channel in down_channels ])
def __init__(self, in_channels, num_image, first_concat=True): super().__init__() bate = 1 if first_concat == False else num_image self.double_conv = nn.Sequential( ConvBNReLU(bate*in_channels, 64, 3), ConvBNReLU(64, 64, 3)) down_channels = [[64, 128], [128, 256], [256, 512], [512, 512]] self.down_sample_list = nn.LayerList([ self.down_sampling(channel[0], channel[1]) for channel in down_channels ])
def __init__(self, in_channels, out_channels, align_corners, use_deconv=False): super().__init__() self.align_corners = align_corners self.use_deconv = use_deconv if self.use_deconv: self.deconv = nn.Conv2DTranspose(in_channels, out_channels // 2, kernel_size=2, stride=2, padding=0) in_channels = in_channels + out_channels // 2 else: in_channels *= 2 self.double_conv = nn.Sequential( ConvBNReLU(in_channels, out_channels, 3), ConvBNReLU(out_channels, out_channels, 3))
def __init__(self, high_in_channels, low_in_channels, out_channels, align_corners): super().__init__() # Only depth-wise conv self.dwconv = ConvBNReLU( in_channels=low_in_channels, out_channels=out_channels, kernel_size=3, padding=1, groups=128, bias_attr=False) self.conv_low_res = ConvBN(out_channels, out_channels, 1) self.conv_high_res = ConvBN(high_in_channels, out_channels, 1) self.align_corners = align_corners
def __init__(self, in_channels=3, dw_channels1=32, dw_channels2=48, out_channels=64): super(LearningToDownsample, self).__init__() self.conv_bn_relu = ConvBNReLU( in_channels=2*in_channels, out_channels=dw_channels1, kernel_size=3, stride=2) self.dsconv_bn_relu1 = SeparableConvBNReLU( in_channels=dw_channels1, out_channels=dw_channels2, kernel_size=3, stride=2, padding=1) self.dsconv_bn_relu2 = SeparableConvBNReLU( in_channels=dw_channels2, out_channels=out_channels, kernel_size=3, stride=2, padding=1)
def down_sampling(self, in_channels, out_channels): modules = [] modules.append(nn.MaxPool2D(kernel_size=2, stride=2)) modules.append(ConvBNReLU(in_channels, out_channels, 3)) modules.append(ConvBNReLU(out_channels, out_channels, 3)) return nn.Sequential(*modules)