naver / r2d2

Other
461 stars 86 forks source link

How to extract patch descriptor only? #30

Open ducha-aiki opened 3 years ago

ducha-aiki commented 3 years ago

Hi,

Is there a way of getting single descriptor out of 32x32 patch similar to HardNet or SIFT? The reason is that I am interested to run original HPatches, patch-based protocol. I do realize, that it is not the working mode, R2D2 is optimized for, but would like to have some results anyway.

If I do smth like:

out = r2d2([torch.zeros(1,3,32,32)])['descriptors'][0]

then I have [1,128,32,32] tensor, while I would like [1,128,1,1].

jerome-revaud commented 3 years ago

Hi This is not the prettiest solution, but you can just sample the descriptor in the middle:

dense_descriptors = r2d2([torch.zeros(1,3,32,32)])['descriptors'][0]
patch_descriptor = out[0,0,:,16,16]

Each descriptor is supposed to cover a 32x32 receptive field (in reality, it's actually more like 40x40), so the one in the center will be covering the patch well.