teddykoker / unsupervised-deep-homography

PyTorch implementation of Unsupervised Deep Homography: https://arxiv.org/abs/1709.03966
62 stars 22 forks source link

Redundant homography matrix inversion #24

Open wtyuan96 opened 1 year ago

wtyuan96 commented 1 year ago

Thanks for your great work!

In the original paper of Unsupervised deep homography, authors use the spatial transformation layer to perform inverse warping to get the warped image. If I'm not mistaken, for the above reason, there are some torch.inverse functions in your reproduced code, specifically, dataset.py, model.py and test.py .

But, the warp_perspective function in kornia has a homography normalizad inversion operation internally, please refer to the source code of warp_perspective here and a related issue here. ( the version of kornia is consistent with yours. )

So the torch.inverse functions in your code maybe are redundant.

Also, there is an example of how to warp image using perspective transform with kornia, torch.inverse is not used in the example.

teddykoker commented 1 year ago

Hi @wtyuan96, thanks for the issue. At the time of writing I wasn't aware of the error in the kornia documentation, which led to me using the torch.inverse function as you point out. I believe this is a mistake and can be removed; I presume the current code will still work, but just produce delta values that produce an inverted homography matrix instead of the correct one. If you are working in this space feel free to make some modifications and let me know how it works out! Otherwise I'll see if I can fix this when I have some free time.