csyxwei / FFWM

Learning Flow-based Feature Warping for Face Frontalization with Illumination Inconsistent Supervision (ECCV 2020).
MIT License
129 stars 24 forks source link

Parameter settings in AffineRegularizationLoss function #8

Closed AndrewChiyz closed 2 years ago

AndrewChiyz commented 2 years ago

Hi, Thanks for sharing the code!

I have a few questions on the implementation of the AffineRegularizationLoss function. It seems the prediction of the optical already contains the identity mesh grid, and coordinates are normalized to [-1, 1]. so the flow warping process is directly applying the F.grid_sample function on the image or the feature maps.

For the AffineRegularizationLoss function, in line 222, the losses.py,

https://github.com/csyxwei/FFWM/blob/d42c578cabe1b81c6b1bb0c3cb707b190fca3c68/models/losses.py#L222

It seems the mesh grid should be re-normalized back to the range of [h,w]. So I wonder, why the parameter of tensor.mul() should be 128.0. I mean, for flow field flow128, it should be ok, but for different sizes of the flow fields, say,flow64 and flow32, the number should be different? Is that right? or is it the intended case?

Thanks a lot! :)

csyxwei commented 2 years ago

Hi,

You are right. For different sizes of flow fields, the number should be different, i.e., 64 for flow64 and 32 for flow32. Thanks for pointing out this error! The code should be:

b, c, h, w = flow_field.size()
grid = flow_field.add(1.0).div(2.0).mul(h)

By the way, as the AffineRegularizationLoss constrains transformation between the source coordinate matrix and target coordinate matrix is an affine transformation, multiplying a coefficient to the target coordinate matrix (128) does not conflict with it. This error will not affect the training of FlowNet.

AndrewChiyz commented 2 years ago

Thanks for the prompt reply and clarification, I will close this issue.

Thanks a lot!