Beispiel #1
0
    def __init__(self, owner, backbone, args):

        super().__init__()

        self.backbone1 = nn.Sequential(backbone.conv1, backbone.bn1,
                                       backbone.relu, backbone.maxpool,
                                       backbone.layer1)
        self.shallow_cam = ShallowCAM(args, 256)
        self.backbone2 = nn.Sequential(
            backbone.layer2,
            backbone.layer3[0],
        )
Beispiel #2
0
    def __init__(self, owner, backbone, args):

        super().__init__()
        type_ = owner.type_

        self.backbone1 = nn.Sequential(*backbone.features[:6])
        self.shallow_cam = ShallowCAM(args, 128)

        if type_ == 'd4':
            self.backbone2 = nn.Sequential(*backbone.features[6:-2])
        elif type_ == 't3_d4':
            self.backbone2 = nn.Sequential(*backbone.features[6:-3])
        elif type_ == 'd3_t3_d4':
            denseblock_3 = backbone.features[-4]
            total_layers = len(denseblock_3._modules)
            self.backbone2 = nn.Sequential(
                *backbone.features[6:-4],
                *_copy_dense_layer(denseblock_3, 1, total_layers // 6))