dunbar12138 / DSNeRF

Code release for DS-NeRF (Depth-supervised Neural Radiance Fields)
https://www.cs.cmu.edu/~dsnerf/
MIT License
746 stars 126 forks source link

Some problems with the code about implementing the deep supervision part #77

Open YZsZY opened 1 year ago

YZsZY commented 1 year ago

Hello, I recently tried to add depth KL scatter loss to my own project, and found the core code corresponding to this section was then found to be here https://github.com/dunbar12138/DSNeRF/blob/d9deb70ac1464348aebbe5e32fc98aeca1920f70/loss.py#L87 But in my actual use I found a problem that the weights will often be 0 image So when calculating the loss, if you put the weights directly into the log function, this can easily result in results with inf image But I looked at the code and found that there was nothing to prevent this situation

So I would like to ask guys if anyone has encountered this situation, and I think a very small number can be added to the weights to prevent this as follows:

-torch.log(weights+1e-10) * torch.exp(-(z_vals - depths[:,None]) ** 2 / (2 * err)) * dists

Sorry for disturbing you and hope to receive an answer, thans a lot (^▽^) !

YZsZY commented 1 year ago

Oh, I found there exists a same issue


We added a small eps (~1e-5) to weights to prevent NaN. Originally posted by @dunbar12138 in https://github.com/dunbar12138/DSNeRF/issues/69#issuecomment-1287234426