Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nice! Would you release your implementation of the loss function? #2

Closed
YotYot opened this issue Jul 14, 2019 · 14 comments
Closed

Nice! Would you release your implementation of the loss function? #2

YotYot opened this issue Jul 14, 2019 · 14 comments

Comments

@YotYot
Copy link

YotYot commented Jul 14, 2019

I'm working on a relative article that use your great work, and would like to use your loss function.

Thanks in advance!

@dvdhfnr
Copy link
Collaborator

dvdhfnr commented Jul 16, 2019

@leonzfa
Copy link

leonzfa commented Jul 16, 2019

@dvdhfnr I implemented the loss by myself. I found that the range of prediction is unstable. It can be -3 -- 8, -10 -- 30, -200 -- 1000, in differernt training attempts. I wonder if your met the problem when you trained the network. Thank you very much.

@dvdhfnr
Copy link
Collaborator

dvdhfnr commented Jul 16, 2019

No, I did not met this problem. Did you scale/shift the target depths to [0, 10], as described in the paper?

@leonzfa
Copy link

leonzfa commented Jul 16, 2019

@dvdhfnr I train my model on NYUDepthV2, and scale/shift the depth value by

mask  = target > 0
target[mask] = (target[mask] - target[mask].min()) / (target[mask].max() - target[mask].min()) * 9 + 1
target[mask] = 10. / target[mask]
target[~mask] = 0.

How did you scale/shift the depth map?

@dvdhfnr
Copy link
Collaborator

dvdhfnr commented Jul 17, 2019

To be more precise:
"For all datasets, we shift and scale the ground-truth inverse depth to the range [0, 10]."

@leonzfa
Copy link

leonzfa commented Jul 17, 2019

I test the provided midas_loss. It also leads to unstable output range. The output range is influenced by the initial weights.
I trained the network with different initial weights, and got the following results, in which the three numbers are the min, mean and max of prediction:
Screenshot from 2019-07-17 16-15-54
Screenshot from 2019-07-18 00-53-04

Maybe there should be additional constraints on the prediction to restrict the output range.
Finally, I am looking forward to the scripts that are used to produce the data set.

@dvdhfnr
Copy link
Collaborator

dvdhfnr commented Jul 18, 2019

The predictions resemble the target inverse depths up to a scale and shift.

@ranftlr
Copy link
Collaborator

ranftlr commented Jul 18, 2019

As @dvdhfnr mentioned: This is by construction, as the value of the loss is independent of the output scale. Thus the ranges are dependent on the initialization. If you need a fixed scale range, you could try to add a (scaled) sigmoid to the output activations. However, this might change training behavior and you likely need a sensible initialization.

@aiforworlds
Copy link

Hi! Please see: https://gist.github.com/dvdhfnr/732c26b61a0e63a0abc8a5d769dbebd0

Hi this link is failed, could you share a new one
Thanks.

@kebijuelun
Copy link

kebijuelun commented Feb 23, 2022

To be more precise: "For all datasets, we shift and scale the ground-truth inverse depth to the range [0, 10]."

@dvdhfnr Hi, I found the normalization range is [0, 1] in original paper, so which range is correct?

image

thx

@dvdhfnr
Copy link
Collaborator

dvdhfnr commented Mar 4, 2022

For the latest version of the paper we used the range [0, 1] (https://arxiv.org/pdf/1907.01341v3.pdf, Page 7).

#2 (comment) was referring to an earlier version (https://arxiv.org/pdf/1907.01341v1.pdf, Page 6).

@JohnG0024
Copy link

@dvdhfnr Hi, did you use this loss function for MiDaS v3.0 as well?

@Twilight89
Copy link

@dvdhfnr @ranftlr Hi,
I want to know how did you rescale the ground truths depth to range [0,1].
As my understanding, the following steps are done:

  1. Get the ground truth inverse depth
  2. Normalize like this inverse_depth_normalization = (inverse_depth- inverse_depth.min()) / (inverse_depth.max() - inverse_depth.min())

Does my understanding right? if not, could you please tell us how do you do "For all datasets, we shift and scale the ground-truth inverse depth to the range [0, 1]."?

Thx.

@CJCHEN1230
Copy link

CJCHEN1230 commented Sep 19, 2023

@Twilight89
Same problem. I think the author will never reply. Do you have any conclusion? Or do you implement the training process?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants