lppllppl920 / EndoscopyDepthEstimation-Pytorch

Official Repo for the paper "Dense Depth Estimation in Monocular Endoscopy with Self-supervised Learning Methods" (TMI)
GNU General Public License v3.0
127 stars 28 forks source link

depth_maps_2_calculate in function `_warp_coordinate_generate` and `_depth_warping` #21

Closed YanhaoZhang closed 4 years ago

YanhaoZhang commented 4 years ago

Hi @lppllppl920 I notice that the variable depth_maps_2_calculate is a little bit different in those two functions. In _warp_coordinate_generate, the zeros in img_masks are set as 1.0e30 here, while in _depth_warping, they are given a small value as epsilon here. May I ask if you could explain a bit more on this? Many thanks.

lppllppl920 commented 4 years ago

Hi Yanhao,

The main purpose of using either a small number or value here is to make sure the mask boundary is warped correctly. With the current PyTorch interpolation method, you can set both of these to epsilon because the interpolation allows you to assign a constant value to locations where the specified coordinates are out of boundary.

YanhaoZhang commented 4 years ago

Hi @lppllppl920 Thanks for your reply. Do you mean either a very large or a very small value will all work for warping the mask? Sorry I did not get what do you mean by "with the current PyTorch interpolation method". Do you mean for the latest PyTorch, I can use the very small value for warping the mask? Many thanks.

lppllppl920 commented 4 years ago

In _depth_warping function, the interpolation method provided by Pytorch is used and has an argument named something like constant_value. That value will be used to fill in regions where coordinate values are out of the image region. With a very small value epsilon, coordinate values will be out of the image region and a zero value will be assigned to the corresponding location.

In _warp_coordinate_generate function, for simplicity reason, a large value is assigned to depth_maps_2_calcualte and this will make all warped coordinates out of the boundary to be (0, 0). Because the sparse flow loss won't see these regions because of the binary masks, any arbitrary handling is fine. One example is just what I did in this function.

YanhaoZhang commented 4 years ago

@lppllppl920 Thanks a lot for your detailed explanation. I now understand it. :)