Esempio n. 1
0
def ela_tf_efficientnet_b2_ns(num_classes=4, pretrained=True, dropout=0):
    encoder = efficientnet.tf_efficientnet_b2_ns(in_chans=9,
                                                 pretrained=False,
                                                 drop_path_rate=0.1)
    del encoder.classifier

    if pretrained:
        donor = efficientnet.tf_efficientnet_b2_ns(pretrained=pretrained)
        transfer_weights(encoder, donor.state_dict())

    return TimmElaOnlyRichModel(encoder,
                                num_classes=num_classes,
                                dropout=dropout)
Esempio n. 2
0
def rgb_res_tf_efficientnet_b2_ns(num_classes=4, pretrained=True, dropout=0):
    encoder = efficientnet.tf_efficientnet_b2_ns(in_chans=6,
                                                 pretrained=False,
                                                 drop_path_rate=0.1)
    del encoder.classifier

    if pretrained:
        donor = efficientnet.tf_efficientnet_b2_ns(pretrained=pretrained)
        transfer_weights(encoder, donor.state_dict())

    return ImageAndResidualModel(
        encoder,
        num_classes=num_classes,
        dropout=dropout,
        mean=encoder.default_cfg["mean"],
        std=encoder.default_cfg["std"],
    )
Esempio n. 3
0
def rgb_res_sms_v2_tf_efficientnet_b2_ns(num_classes=4,
                                         pretrained=True,
                                         dropout=0):
    rgb_encoder = efficientnet.tf_efficientnet_b2_ns(pretrained=pretrained,
                                                     drop_path_rate=0.1)
    del rgb_encoder.classifier

    res_encoder = efficientnet.tf_efficientnet_b2_ns(pretrained=pretrained,
                                                     drop_path_rate=0.1)
    del res_encoder.classifier

    return SiameseImageAndResidualModelV2(
        rgb_encoder,
        res_encoder,
        num_classes=num_classes,
        dropout=dropout,
        mean=rgb_encoder.default_cfg["mean"],
        std=rgb_encoder.default_cfg["std"],
    )
Esempio n. 4
0
def rgb_tf_efficientnet_b2_ns(num_classes=4,
                              pretrained=True,
                              dropout=0.1,
                              need_embedding=False):
    encoder = efficientnet.tf_efficientnet_b2_ns(pretrained=pretrained,
                                                 drop_path_rate=0.1)
    del encoder.classifier

    return TimmRgbModel(encoder,
                        num_classes=num_classes,
                        dropout=dropout,
                        need_embedding=need_embedding)
def rgb_tf_efficientnet_b2_ns_avgmax(num_classes=4,
                                     pretrained=True,
                                     dropout=0):
    encoder = efficientnet.tf_efficientnet_b2_ns(pretrained=pretrained)
    del encoder.classifier

    return TimmRgbModelAvgMax(
        encoder,
        num_classes=num_classes,
        dropout=dropout,
        mean=encoder.default_cfg["mean"],
        std=encoder.default_cfg["std"],
    )
    def __init__(self, pretrained=True, layers=[1, 2, 3, 4], act_layer=Swish, no_stride=False):
        from timm.models.efficientnet import tf_efficientnet_b2_ns

        encoder = tf_efficientnet_b2_ns(
            pretrained=pretrained, features_only=True, act_layer=act_layer, drop_path_rate=0.1
        )
        strides = [2, 4, 8, 16, 32]
        if no_stride:
            encoder.blocks[5][0].conv_dw.stride = (1, 1)
            encoder.blocks[5][0].conv_dw.dilation = (2, 2)

            encoder.blocks[3][0].conv_dw.stride = (1, 1)
            encoder.blocks[3][0].conv_dw.dilation = (2, 2)
            strides[3] = 8
            strides[4] = 8
        super().__init__([16, 24, 48, 120, 352], strides, layers)
        self.encoder = encoder
Esempio n. 7
0
def rgb_qf_tf_efficientnet_b2_ns(num_classes=4, pretrained=True, dropout=0):
    encoder = efficientnet.tf_efficientnet_b2_ns(pretrained=pretrained)
    del encoder.classifier

    return ImageAndQFModel(encoder, num_classes=num_classes, dropout=dropout)
Esempio n. 8
0
def res_tf_efficientnet_b2_ns(num_classes=4, pretrained=True, dropout=0):
    encoder = efficientnet.tf_efficientnet_b2_ns(pretrained=pretrained,
                                                 drop_path_rate=0.1)
    del encoder.classifier

    return ResidualOnlyModel(encoder, num_classes=num_classes, dropout=dropout)