Pytorch-Correlation-extension
Pytorch-Correlation-extension copied to clipboard
Parameters for correlation
Hello,
I'm trying to make the following code work on Collab:https://github.com/ZhenboSong/mono_velocity/blob/master/train_crop_velocity.py But since I can't install their Correlation function. self.corr = Correlation(pad_size=md, kernel_size=1, max_displacement=md, stride1=1, stride2=1, corr_multiply=1)
I found myself using your SpatialCorrelationSampler. I need help figuring which parameter values to use to make the output of the correlation between two tensors of shape [8, 196, 6, 7] to be of size [128,81,3,3]. Now using the following definition for the correlation: self.corr = SpatialCorrelationSampler(kernel_size=1, patch_size=2*md+1, stride=1, padding=0, dilation_patch=1) I get an output with shape: torch.Size([8, 9, 9, 6, 7])
Do you have any clue to what's happening?
Thank you for your time,
Hi, @marcbo12, This is my solution
from spatial_correlation_sampler import SpatialCorrelationSampler as Correlation
self._corr = Correlation(kernel_size=1, patch_size=9, stride=1, padding=0, dilation_patch=1)
def corr(self, input1, input2):
out_corr = self._corr(input1, input2)
# collate dimensions 1 and 2 in order to be treated as a
# regular 4D tensor
b, ph, pw, h, w = out_corr.size()
out_corr = out_corr.view(b, ph * pw, h, w)/input1.size(1)
return out_corr
Hi sorry for the lack of response. Closing it as it is quite old now.
Feel free to repon it if you need.
I don't think the reported size are good. The 81 comes from collapsing the 9x9 displacement dimension, but I have no idea why the batch dimension becomes128 or why the h and w are transformed from [6,7] to [3,3].