ufukefe / DFM

Python (Pytorch) and Matlab (MatConvNet) implementations of CVPR 2021 Image Matching Workshop paper DFM: A Performance Baseline for Deep Feature Matching
Other
197 stars 22 forks source link

Confuse about meaning of score in refine_points function in python wrapper #7

Closed bladesaber closed 2 years ago

bladesaber commented 2 years ago

Dear All: Thanks for great idea of DFM. Although I read paper and check the code, I still confuse about how to refine points.

In python document, DeepFeatureMatcher.py, in line 313 with code scores[:, i, j] = torch.sum(act_A * act_B, 0).

I suppose the score here is something similar to correlation(the higher the better). Because I find that DFM use torch.topk to find the best match in line 316 after finish computing the scores. But I find that in line 351, DFM discard the match with higher score in order to limit the num of the output points and the tag show that the score is SSE(Sum of square error).

That make me confused, if the score here is SSE, when we find the best match, shouldn't it use torch.topk(scores, 2, dim=2, largest=False) in line 316, lower SSE means better match, right ??

Looking forward to your response. ^_^

ufukefe commented 2 years ago

Hi, thanks for your interest in DFM!

In lines 313 and 316, we calculate the correlation as you mentioned. Then in line 317, we convert it to the MSE.

Here is the mathematical expression; Sum((x-y)^2) = sum(x^2) – 2sum(xy)+sum(y^2) As x and y are normalized, sum(x^2) = 1, sum(y^2) = 1, then Sum((x-y)^2) = 2 – 2sum(xy) = 2 -2*<x,y>

So we first get the inner product and select the candidates with greatest inner product (correlation score), then we convert from similarity (inner product) to difference (mse).