torch-ngp icon indicating copy to clipboard operation
torch-ngp copied to clipboard

Question about render image and depth

Open mah-asd opened this issue 2 years ago • 2 comments

Hello, thank you for your work and for answering questions. I have a question about the function which renders image and depth values based on input rays. to be more specific: renderer.py > class NeRFRenderer > run_cuda > raymarching.composite_rays when I pass a ray with requires_grad=True, depth is with .grad attribute, but the image is not. What is the reason? how can I have image as an output with .grad attribute?

Is it okay to delete all " .detach, torch_no_grad(), and @staticmethod" in the code?

mah-asd avatar Aug 19 '22 18:08 mah-asd

@mah-asd Hi, do you mean composite_rays_train or composite_rays (for inference)? In fact both depth and image should have None for .grad, since they are not leaf nodes. Only tensor with is_leaf == True and requires_grad == True will get its grad after a later backward(). Maybe you can check this.

ashawkey avatar Aug 20 '22 01:08 ashawkey

Hi Ashawkey, Thank you for replying. I'm using rays_o and rays_d with required_grad = True as inputs, But I'm getting output without autograd attribute. Somewhere in the process, it becomes disabled. I'm using this line of code: **outputs = model.render(rays_o, rays_d, staged=True, bg_color=None, perturb=False, force_all_rays=False, vars(opt))

mah-asd avatar Aug 22 '22 17:08 mah-asd