HKUST-3DV / DIM-SLAM

This is official repo for ICLR 2023 Paper "DENSE RGB SLAM WITH NEURAL IMPLICIT MAPS"
195 stars 11 forks source link

Questions about the warping part of the code #12

Closed JerryPW closed 11 months ago

JerryPW commented 11 months ago

Hi ! Recently, I've been using these codes to complement my warping constrains. However, I've found something strange.

batch_patch_gt_color = (
    torch.nn.functional.grid_sample(
        batch_patch_gt_color.permute(0, 3, 1, 2),
        batch_patch_uv.view(batch_patch_uv.shape[0], batch_patch_gt_color.shape[0], -1, 2).permute(1, 0, 2, 3),
        mode="bilinear",
        padding_mode='border'
    )
    .permute(2, 0, 3, 1)
    .contiguous()
    .view(-1, 3)
)

Specifically, as I focus on 1 patch of image and tuning the patch_size into the whole picture, the output, i.e. batch_patch_gt_color, suppose to be exactly the same with input image. Whereas, the output is the input with rotate 90 degree and flipped. Here's the input and the output image:

截屏2023-08-15 14 27 49 截屏2023-08-15 14 28 05

Do you know why is that happened? Hoping for your reply soon!

poptree commented 11 months ago

Hi,

It seems like the batch_patch_uv is wrong. batch_patch_uv[...,0] should be the x-axis of the image, which is usually along the width.

Please refer to line 113 of utils.py , where the first entry is width.

BTW, LINE 120 has a similar coordinate error on width and height, so I rewrite a new function get_samples_by_indices_batch instead of using get_samples_batch.

poptree commented 11 months ago

You could find more detail on pytorch grid sample.

Hope it will be helpful.

poptree commented 11 months ago

Besides, you know, some individuals may feel uncomfortable when viewing medical images. While I believe the pictures you posted are synthetic, this won't alleviate the discomfort.

🙏Maybe you could replace it with other images next time. I will close this issue since I cannot stay on it anymore.

JerryPW commented 11 months ago

Hi,

It seems like the batch_patch_uv is wrong. batch_patch_uv[...,0] should be the x-axis of the image, which is usually along the width.

Please refer to line 113 of utils.py , where the first entry is width.

BTW, LINE 120 has a similar coordinate error on width and height, so I rewrite a new function get_samples_by_indices_batch instead of using get_samples_batch.

Thanks a lot !!!!!! I've been working on this problem for all day!!! And I will notice the 'medical image problem' you just mentioned next time! Thanks for remind me that!