Open onpix opened 3 years ago
I too noticed this and simply rescaled the values of guidemap_guide
to the expected range (i.e [-1, 1]
).
This better to be tested. cause it's hard to say how grid_sample behave
ive added bilateral_slice from original repo compiled for jit. But still has some problems with optimization for some reason. So i think grid_sample was working correctly
After some comparison with my customized tri-linear interpolation, which consists of multiple 2D bilinear interpolation, I'm now pretty sure that the second argument to F.grid_sample
(grid
) should be something like
torch.cat([wg, hg, guidemap], dim=3).unsqueeze(1)
instead of
torch.cat([hg, wg, guidemap], dim=3).unsqueeze(1)
Furthermore, elements in grid
along all axes should be in [-1, 1] range, not [0, 1], which means in the guidance net, the activation should be torch.tanh
, instead of torch.sigmoid
.
The result of my customized slicing oprator is very similar to the F.grid_sample
with inputs formatted mentioned above. The abs error is smaller than 1E-5:
all close with atol=1E-6: False
all close with atol=1E-5: True
I check the PyTorch doc and found that in function
grid_sample
:and
, which means that
guidemap_guide[m, d, h, w]
should be in range[-1, 1]
. In code, you normalizehg
andwg
to[-1, 1]
but keepguidemap
its original value in[0, 1]
. Does it seem thatguidemap
should also be normalized to[-1, 1]
?