Esempio n. 1
0
    def __init__(self, base_model_architecture="resnet50_128", num_clusters=8, vset_dim=128,
                 pooling='vlad', vlad_v2=False):
        super(HashSetNet, self).__init__()

        if base_model_architecture == "resnet50_128":
            self.base_model = resnet50_128(ROOT_DIR + '/Models_weights/resnet50_128.pth')
            dim = 128
        elif base_model_architecture == "senet50_128":
            self.base_model = senet50_128(ROOT_DIR + '/Models_weights/senet50_128.pth')
            dim = 128
        elif base_model_architecture == "resnet50_2048":
            self.base_model = resnet50_ft(ROOT_DIR + '/Models_weights/resnet50_ft_dims_2048.pth')
            dim = 2048
        elif base_model_architecture == "senet50_2048":
            self.base_model = senet50_ft(ROOT_DIR + '/Models_weights/senet50_ft_dims_2048.pth')
            dim = 2048
        self.pooling = pooling
        if self.pooling == 'vlad':
            self.net_vlad = NetVLAD(num_clusters=num_clusters, dim=dim, vset_dim=vset_dim,
                                    vlad_v2=vlad_v2, normalize_input=True)
        elif self.pooling == 'gem':
            self.gem_pooling = GeM(p=3, eps=1e-6)

        elif self.pooling == 'sum':
            self.sum_pooling = SumPooling()
        self.bn_x = nn.BatchNorm1d(dim, affine=False)
Esempio n. 2
0
 def __init__(self, model_type="resnet50_128"):
     super(Net, self).__init__()
     if model_type == "resnet50_128":
         self.base_model = resnet50_128(ROOT_DIR + '/Models_weights/resnet50_128.pth')
         self.encoder_dim = 128
     elif model_type == "senet50_128":
         self.base_model = senet50_128(ROOT_DIR + '/Models_weights/senet50_128.pth')
         self.encoder_dim = 128
     elif model_type == "resnet50_2048":
         self.base_model = resnet50_ft(ROOT_DIR + '/Models_weights/resnet50_ft_dims_2048.pth')
         self.encoder_dim = 2048
     elif model_type == "senet50_2048":
         self.base_model = senet50_ft(ROOT_DIR + '/Models_weights/senet50_ft_dims_2048.pth')
         self.encoder_dim = 2048
Esempio n. 3
0
    def __init__(self,
                 base_model_architecture="resnet50_128",
                 num_clusters=8,
                 vset_dim=128,
                 pooling='vlad',
                 vlad_v2=False,
                 step_size=200):
        super(HashSetNet, self).__init__()

        if base_model_architecture == "resnet50_128":
            self.base_model = resnet50_128(ROOT_DIR +
                                           '/Models_weights/resnet50_128.pth')
            dim = 128
        elif base_model_architecture == "senet50_128":
            self.base_model = senet50_128(ROOT_DIR +
                                          '/Models_weights/senet50_128.pth')
            dim = 128
        elif base_model_architecture == "resnet50_2048":
            self.base_model = resnet50_ft(
                ROOT_DIR + '/Models_weights/resnet50_ft_dims_2048.pth')
            dim = 2048
        elif base_model_architecture == "senet50_2048":
            self.base_model = senet50_ft(
                ROOT_DIR + '/Models_weights/senet50_ft_dims_2048.pth')
            dim = 2048
        self.pooling = pooling
        if self.pooling == 'vlad':
            self.net_vlad = NetVLAD(num_clusters=num_clusters,
                                    dim=dim,
                                    vset_dim=vset_dim,
                                    vlad_v2=vlad_v2,
                                    normalize_input=True)
        elif self.pooling == 'gem':
            self.gem_pooling = GeM(p=3, eps=1e-6)

        elif self.pooling == 'sum':
            self.sum_pooling = SumPooling()
        self.bn_x = nn.BatchNorm1d(dim, affine=False)

        self.iter_num = 0
        self.step_size = step_size
        self.gamma = 0.005
        self.power = 0.5
        self.init_scale = 1.0
        self.activation = nn.Tanh()
        self.scale = self.init_scale
        self.first_flag = True
Esempio n. 4
0
 def __init__(self, base_model_architecture="resnet50_128", num_clusters=8, vlad_dim=128, vlad_v2=False):
     super(SetNet, self).__init__()
     if base_model_architecture == "resnet50_128":
         self.base_model = resnet50_128(ROOT_DIR + '/Models_weights/resnet50_128.pth')
         dim = 128
     elif base_model_architecture == "senet50_128":
         self.base_model = senet50_128(ROOT_DIR + '/Models_weights/senet50_128.pth')
         dim = 128
     elif base_model_architecture == "resnet50_2048":
         self.base_model = resnet50_ft(ROOT_DIR + '/Models_weights/resnet50_ft_dims_2048.pth')
         dim = 2048
     elif base_model_architecture == "senet50_2048":
         self.base_model = senet50_ft(ROOT_DIR + '/Models_weights/senet50_ft_dims_2048.pth')
         dim = 2048
     self.net_vlad = NetVLAD(num_clusters=num_clusters, dim=dim, vlad_dim=vlad_dim,
                             vlad_v2=vlad_v2, normalize_input=True)
     self.bn_x = nn.BatchNorm1d(dim, affine=False)
Esempio n. 5
0
 def __init__(self, base_model_architecture="resnet50_128"):
     super(Baseline, self).__init__()
     if base_model_architecture == "resnet50_128":
         self.base_model = resnet50_128(ROOT_DIR +
                                        '/Models_weights/resnet50_128.pth')
         dim = 128
     elif base_model_architecture == "senet50_128":
         self.base_model = senet50_128(ROOT_DIR +
                                       '/Models_weights/senet50_128.pth')
         dim = 128
     elif base_model_architecture == "resnet50_2048":
         self.base_model = resnet50_ft(
             ROOT_DIR + '/Models_weights/resnet50_ft_dims_2048.pth')
         dim = 2048
     elif base_model_architecture == "senet50_2048":
         self.base_model = senet50_ft(
             ROOT_DIR + '/Models_weights/senet50_ft_dims_2048.pth')
         dim = 2048
     self.sum_pooling = SumPooling()
     self.bn_x = nn.BatchNorm1d(dim, affine=False)