visinf / self-mono-sf

Self-Supervised Monocular Scene Flow Estimation (CVPR 2020)
Apache License 2.0
248 stars 47 forks source link

How to handle this error in the warping_package if I want to run my code under pytorch 1.1 #17

Closed RokiaAbdeen closed 2 years ago

RokiaAbdeen commented 2 years ago

Hi , I got this error while I am trying to compile the warping_package image how could I handle this error please thanks in advance

RokiaAbdeen commented 2 years ago

I found these lines in forwad_warp_cuda.cpp `// Because of the incompatible of Pytorch 1.0 && Pytorch 0.4, we have to annotation this.

define CHECK_CUDA(x) AT_ASSERT(x.type().is_cuda(), #x " must be a CUDA tensor")

define CHECK_CONTIGUOUS(x) AT_ASSERT(x.is_contiguous(), #x " must be contiguous")

define CHECK_INPUT(x) CHECK_CUDA(x); CHECK_CONTIGUOUS(x)

` I didn't understand what should I modify exactly to solve this error

hurjunhwa commented 2 years ago

It seems like the macro AT_ASSERT takes different types or numbers of arguments in different PyTorch versions. You can probably look up the PyTorch documentation & modify the function according to your pytorch version.

Or, you can also comment out the lines using CHECK_INPUT.

For more details on the forward warping function, you can refer to this repository: https://github.com/lizhihao6/Forward-Warp

RokiaAbdeen commented 2 years ago

the problem is solved by commenting out these two lines : `#define CHECK_CUDA(x) AT_ASSERT(x.type().is_cuda(), #x " must be a CUDA tensor")

define CHECK_CONTIGUOUS(x) AT_ASSERT(x.is_contiguous(), #x " must be contiguous") `

thank you so much

RokiaAbdeen commented 2 years ago

Another question please, the function _adaptive_disocc_detection_disp() in losses.py file is used to find the dis-occluded regions for the left disparity only ? can it be used for the right disparity too ? how can it find the occlusion from one disp map only ? why do you use the value 0.5 as a threshold why not a 0.3 ? thanks in advance ..

hurjunhwa commented 2 years ago

It's because I only used the left image for the loss calculation. I guess it's a design choice, and you can also include the loss for the right disparity by calculating its occlusion map from the left disparity.

The occlusion map for the left disparity is the inverse of the disocclusion map from the right disparity (the disocclusion map is obtained by forward-warping the right disparity). You can probably refer to the Fig. 3 in our previous paper.

The threshold 0.5 can be a hyper-parameter.

RokiaAbdeen commented 2 years ago

I mean you have used _adaptive_disocc_detection_disp() in losses.py file to find the left occlusion , its input is the right disparity. Can I use the left disparity as an input to find the right occlusion too?

hurjunhwa commented 2 years ago

Yes, that's possible too.

RokiaAbdeen commented 2 years ago

left_diss_occlusion_map=_adaptive_disocc_detection_disp(right_disp) left_occ_map=~left_diss_occlusion_map and the same for the right_occ_map, right ?

hurjunhwa commented 2 years ago

left_diss_occlusion_map=_adaptive_disocc_detection_disp(right_disp) Probably you need to reverse the sign of the disparity because it is in the opposite direction. right_disp -> -right_disp

left_occ_map=~left_diss_occlusion_map Yes, you can do it that way. Then, in that case, occluded pixels will have True. If you are not sure, you can always visualize the result and check if it makes sense.