ucbdrive / hd3

Code for Hierarchical Discrete Distribution Decomposition for Match Density Estimation (CVPR 2019)
BSD 3-Clause "New" or "Revised" License
204 stars 32 forks source link

Question on the flow normalization #11

Closed ghost closed 5 years ago

ghost commented 5 years ago

Hello, Could I ask why you normalize the flow by vgrid[:,0,:,:] = 2.0*vgrid[:,0,:,:].clone() / max(W-1,1)-1.0 in the warping function?

Due to minus value in flow, the vgrid could also have minus and then the result of that line could be less then -1. Isnt that out of purposed vgrid range [-1, 1]?

Can we assume that vgrid == sum(grid, flow) always stay larger than 0?

yzcjtr commented 5 years ago

Hi, the normalization operation transforms sampled coordinates from [0, W-1][0, H-1] to [-1, 1] [-1,1]. The normalized flow certainly contains values less than -1, in which case the original coordinate should be less than 0 and the sampler would use border values as padding.

ghost commented 5 years ago

Thanks for replying quickly.

If the main purpose is normalizing coord into [-1, 1], will it be better to normalize coord and flow separately into the range first then, add them together? currently with the coord focused normalizing , it seems large negative flows like -10, -30 all become -1.x and lose their intensity by changed with padding value.

Is there any intention or benefit that i missed why "add an unnormalized [-x, x] flow into [0, h] coord then normalize together" instead of "normalize separately and then add together"?

Thanks

On Mon, Jul 22, 2019, 21:03 Zhichao Yin notifications@github.com wrote:

Hi, the normalization operation transforms sampled coordinates from [0, W-1][0, H-1] to [-1, 1] [-1,1]. The normalized flow certainly contains values less than -1, in which case the original coordinate should be less than 0 and the sampler which using border values as padding.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ucbdrive/hd3/issues/11?email_source=notifications&email_token=AMR5FVU3K4GZETT36CUHD5LQAWOZ3A5CNFSM4IFVMBJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2PWN4Q#issuecomment-513763058, or mute the thread https://github.com/notifications/unsubscribe-auth/AMR5FVXAKLGIGGCA3GPZ4CDQAWOZ3ANCNFSM4IFVMBJQ .

yzcjtr commented 5 years ago

The purpose of the normalization is to make the sampling coordinates compatible with PyTorch's bilinear sampler API. I would suggest you figure out the mechanism of differentiable warping guided by optical flow first.

ghost commented 5 years ago

Thanks! I will read that. Could you help with one more guide for starter: what is an expected range of the flow when it given as input to the warping function?

ghost commented 5 years ago

Thanks! I will read that. Could you help with one more guide for starter: what is an expected range of the flow when it given as input to the warping function?

yzcjtr commented 5 years ago

You can find this at https://pytorch.org/docs/1.0.0/nn.html?highlight=grid_sample#torch.nn.functional.grid_sample.