Skip to content

Commit f9d3a5a

Browse files
committedOct 6, 2018
Fix
1 parent 3d2d628 commit f9d3a5a

File tree

3 files changed

+5
-23
lines changed

3 files changed

+5
-23
lines changed
 

‎model/cnn_geometric_model.py

+2-15
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
def featureL2Norm(feature):
1717
epsilon = 1e-6
18-
# print(feature.size())
19-
# print(torch.pow(torch.sum(torch.pow(feature,2),1)+epsilon,0.5).size())
2018
norm = torch.pow(torch.sum(torch.pow(feature, 2), 1) + epsilon,
2119
0.5).unsqueeze(1).expand_as(feature)
2220
return torch.div(feature, norm)
@@ -136,12 +134,7 @@ def __init__(self, shape='3D', normalization=True):
136134
self.shape = shape
137135
self.ReLU = nn.ReLU()
138136

139-
def forward(self, feature_A, feature_B, cues_A, cues_B):
140-
if cues_A is None or cues_B is None:
141-
# localization cues are available
142-
pass # TODO: create uniform localization weight over all the images.
143-
144-
# TODO: update this to use localization cues.
137+
def forward(self, feature_A, feature_B):
145138
b, c, h, w = feature_A.size()
146139
if self.shape == '3D':
147140
# reshape features for matrix multiplication
@@ -223,9 +216,6 @@ def __init__(
223216
use_cuda=True,
224217
delf_path=''
225218
):
226-
# regressor_channels_1 = 128,
227-
# regressor_channels_2 = 64):
228-
229219
super(CNNGeometric, self).__init__()
230220
self.use_cuda = use_cuda
231221
self.feature_self_matching = feature_self_matching
@@ -259,11 +249,8 @@ def forward(self, tnf_batch):
259249
# feature extraction
260250
feature_A = self.FeatureExtraction(tnf_batch['source_image'])
261251
feature_B = self.FeatureExtraction(tnf_batch['target_image'])
262-
# localization cues
263-
cues_A = tnf_batch.get('source_cues')
264-
cues_B = tnf_batch.get('target_cues')
265252
# feature correlation
266-
correlation = self.FeatureCorrelation(feature_A, feature_B, cues_A, cues_B)
253+
correlation = self.FeatureCorrelation(feature_A, feature_B)
267254
# regression to tnf parameters theta
268255
theta = self.FeatureRegression(correlation)
269256

‎model/delf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,5 @@ def forward(self, batch):
7474
interim = F.relu(self.bn1(interim))
7575
interim = self.conv2(interim)
7676
attention = F.softplus(interim)
77-
weight = (attention - attention.min())/(attention.max() - attention.min())
78-
return weight*feature_maps
77+
weight = (attention - attention.min()) / (attention.max() - attention.min())
78+
return weight * feature_maps

‎options/options.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,7 @@ def add_cnn_model_parameters(self):
264264
default='',
265265
help='feature extraction CNN last layer'
266266
)
267-
model_params.add_argument(
268-
'--delf-path',
269-
type=str,
270-
default='',
271-
help='DELF checkpoint path'
272-
)
267+
model_params.add_argument('--delf-path', type=str, default='', help='DELF checkpoint path')
273268
model_params.add_argument(
274269
'--fr-feature-size', type=int, default=15, help='image input size'
275270
)

0 commit comments

Comments
 (0)
Please sign in to comment.