示例#1
0
    def __init__(self,
                 encoder: E.EncoderModule,
                 num_classes: int,
                 fpn_features=128,
                 dropout=0.25):
        super().__init__()

        decoder = D.FPNDecoder(
            features=encoder.output_filters,
            prediction_block=DoubleConvBNRelu,
            bottleneck=FPNBottleneckBlockBN,
            fpn_features=fpn_features,
            prediction_features=fpn_features,
        )

        self.encoder = encoder
        self.decoder = decoder

        self.fpn_fuse = FPNFuse()
        self.dropout = nn.Dropout2d(dropout, inplace=True)
        output_features = sum(self.decoder.output_filters)

        # Final Classifier
        self.final_decoder = DoubleConvBNRelu(output_features,
                                              fpn_features // 2)
        self.logits = nn.Conv2d(fpn_features // 2, num_classes, kernel_size=1)
示例#2
0
def fpn256_resnext50(num_classes=1, num_channels=3):
    assert num_channels == 3
    encoder = E.SEResNeXt50Encoder()
    decoder = D.FPNDecoder(features=encoder.output_filters,
                           prediction_block=DoubleConvRelu,
                           bottleneck=FPNBottleneckBlockBN,
                           fpn_features=256)

    return SegmentationModel(encoder, decoder, num_classes)
示例#3
0
    def __init__(self, encoder: E.EncoderModule, num_classes: int,
                 fpn_features: int):
        super().__init__()

        self.encoder = encoder

        # hard-coded assumption that encoder has first layer with stride of 4
        self.decoder = D.FPNDecoder(features=encoder.output_filters[1:],
                                    prediction_block=DoubleConvRelu,
                                    bottleneck=FPNBottleneckBlockBN,
                                    fpn_features=fpn_features)
        self.fpn_fuse = FPNFuse()
        output_features = sum(self.decoder.output_filters)
        self.reduce = ConvBNRelu(output_features, fpn_features * 2)

        self.smooth1 = DoubleConvRelu(
            fpn_features * 2 + encoder.output_filters[0], fpn_features)
        self.smooth2 = DoubleConvRelu(fpn_features, fpn_features // 2)

        self.dropout = nn.Dropout2d(0.5, inplace=False)
        self.logits = nn.Conv2d(fpn_features // 2, num_classes, kernel_size=1)