def classification_model_dpn92(**kwargs):
    base_model = pretrainedmodels.dpn92()
    return ClassificationModelDPN(base_model,
                                  base_model_features=2688,
                                  nb_features=6,
                                  base_model_l1_outputs=64,
                                  **kwargs)
Exemple #2
0
    def __init__(self):
        self.model = dpn92(pretrained='imagenet+5k')

        def base_arch(pretrained=True):
            return nn.Sequential(*list(self.model.children()))

        self.base_arch = base_arch
Exemple #3
0
 def __init__(self,
              dpn_version='dpn68',
              input_size=128,
              num_classes=340,
              pretrained='imagenet',
              dropout_rate=0.):
     super(GeneralizedDPN, self).__init__()
     if dpn_version == 'dpn68':
         self.pretrained_model = dpn68(pretrained=pretrained)
         self.fc_input = 832
     elif dpn_version == 'dpn92':
         self.pretrained_model = dpn92(
             pretrained='imagenet+5k'
             if pretrained else None)  # TODO: ugly hard coded
         self.fc_input = 2688
     elif dpn_version == 'dpn98':
         self.pretrained_model = dpn98(pretrained=pretrained)
         self.fc_input = 2688
     elif dpn_version == 'dpn107':
         self.pretrained_model = dpn107(
             pretrained='imagenet+5k'
             if pretrained else None)  # TODO: ugly hard coded
         self.fc_input = 2688
     elif dpn_version == 'dpn131':
         self.pretrained_model = dpn131(pretrained=pretrained)
         self.fc_input = 2688
     else:
         raise NotImplementedError('No implementation')
     self.features = self.pretrained_model.features
     self.relu = nn.ReLU()
     self.avg_pool = nn.AvgPool2d(input_size // 32, stride=1, padding=0)
     self.dropout = nn.Dropout(p=dropout_rate)
     self.last_linear = nn.Linear(self.fc_input, num_classes)
Exemple #4
0
    def __init__(self, num_classes=2, arch="dpn92"):
        super().__init__()
        backbone = dpn92(pretrained='imagenet+5k').features

        self.conv0 = nn.Sequential(backbone[0])
        self.block1 = nn.Sequential(*backbone[1:4])
        self.block2 = nn.Sequential(*backbone[4:8])
        self.block3 = nn.Sequential(*backbone[8:28])
        self.block4 = nn.Sequential(*backbone[28:])
Exemple #5
0
def get_features(network):
    if network == 'resnet50':
        rn = resnet50(True)
        features = nn.ModuleList([
            nn.Sequential(rn.conv1, rn.bn1, rn.relu, rn.maxpool, rn.layer1),
            rn.layer2, rn.layer3, rn.layer4
        ])
        channels = 256, 512, 1024, 2048
    elif network == 'resnext101_32x4d':
        features = nn.ModuleList(list(resnext101_32x4d().features)[:8])
        features = nn.ModuleList([
            nn.Sequential(*features[:5]),
            features[5],
            features[6],
            features[7],
        ])
        channels = 256, 512, 1024, 2048
    elif network == 'dpn68b':
        dpn = list(dpn68b().features)
        features = nn.ModuleList([
            nn.Sequential(*dpn[:4]),
            nn.Sequential(*dpn[4:8]),
            nn.Sequential(*dpn[8:20]),
            nn.Sequential(*dpn[20:23])
        ])
        channels = 144, 320, 704, 832
    elif network == 'dpn92':
        dpn = list(dpn92().features)
        features = nn.ModuleList([
            nn.Sequential(*dpn[:4]),
            nn.Sequential(*dpn[4:8]),
            nn.Sequential(*dpn[8:28]),
            nn.Sequential(*dpn[28:31])
        ])
        channels = 336, 704, 1552, 2688
    else:
        raise ValueError(network)
    return features, channels