def __init__(self, in_dim: int, out_dim: int): super(StemBlock, self).__init__() self.conv = layers.ConvBNReLU(in_dim, out_dim, 3, stride=2) self.left = nn.Sequential( layers.ConvBNReLU(out_dim, out_dim // 2, 1), layers.ConvBNReLU(out_dim // 2, out_dim, 3, stride=2)) self.right = nn.MaxPool2D(kernel_size=3, stride=2, padding=1) self.fuse = layers.ConvBNReLU(out_dim * 2, out_dim, 3)
def __init__(self, in_dim: int, mid_dim: int, num_classes: int): super().__init__() self.conv_3x3 = nn.Sequential(layers.ConvBNReLU(in_dim, mid_dim, 3), nn.Dropout(0.1)) self.conv_1x1 = nn.Conv2D(mid_dim, num_classes, 1, 1)
def __init__(self, in_dim: int, out_dim: int): super(ContextEmbeddingBlock, self).__init__() self.gap = nn.AdaptiveAvgPool2D(1) self.bn = layers.SyncBatchNorm(in_dim) self.conv_1x1 = layers.ConvBNReLU(in_dim, out_dim, 1) self.conv_3x3 = nn.Conv2D(out_dim, out_dim, 3, 1, 1)
def __init__(self, in_dim: int, out_dim: int, expand: int): super().__init__() expand_dim = expand * in_dim self.conv = nn.Sequential( layers.ConvBNReLU(in_dim, in_dim, 3), layers.DepthwiseConvBN(in_dim, expand_dim, 3), layers.ConvBN(expand_dim, out_dim, 1))
def __init__(self, in_channels: int): super().__init__() C1, C2, C3 = in_channels self.convs = nn.Sequential( # stage 1 layers.ConvBNReLU(3, C1, 3, stride=2), layers.ConvBNReLU(C1, C1, 3), # stage 2 layers.ConvBNReLU(C1, C2, 3, stride=2), layers.ConvBNReLU(C2, C2, 3), layers.ConvBNReLU(C2, C2, 3), # stage 3 layers.ConvBNReLU(C2, C3, 3, stride=2), layers.ConvBNReLU(C3, C3, 3), layers.ConvBNReLU(C3, C3, 3), )