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

Computing and predicting normals #905

Merged
merged 28 commits into from
Nov 20, 2022
Merged

Computing and predicting normals #905

merged 28 commits into from
Nov 20, 2022

Conversation

ethanweber
Copy link
Collaborator

@ethanweber ethanweber commented Nov 6, 2022

This PR gives fields the options to compute and predict normals.

ns-train nerfacto --pipeline.model.use-pred-normals True

@ethanweber ethanweber force-pushed the ethan/adding_normals branch from 0016d84 to 89a2c94 Compare November 6, 2022 17:26
@ethanweber ethanweber changed the title Computing normals [WIP] Computing normals Nov 7, 2022
@ethanweber ethanweber changed the title [WIP] Computing normals [WIP] Computing and predicting normals Nov 8, 2022
@terrancewang terrancewang requested a review from tancik November 17, 2022 04:44
@terrancewang
Copy link
Contributor

reconstruction
normals
normals_trainrayssec

@ethanweber ethanweber changed the title [WIP] Computing and predicting normals Computing and predicting normals Nov 18, 2022
Copy link
Collaborator Author

@ethanweber ethanweber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. Left some comments that you can address before we merge @terrancewang.

@@ -260,9 +289,19 @@ def get_outputs(self, ray_samples: RaySamples, density_embedding: Optional[Tenso
dim=-1,
)
# print(semantics_input)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete (although not a change you made)

@@ -281,6 +334,12 @@ def get_image_metrics_and_images(

images_dict = {"img": combined_rgb, "accumulation": combined_acc, "depth": combined_depth}

# normals to RGB for visualization. TODO: use a colormap
if "normals" in outputs:
images_dict["normals"] = outputs["normals"]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this not need to be scaled into the range [0, 1]? Normals would be in the range [-1, -1].

Copy link
Collaborator Author

@ethanweber ethanweber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! LGTM, but I'm not sure what you are doing with TensoRF. I'd either remove it or make sure it raises an error if you try to to use predict_normals=True (since it looks like it won't work).

@@ -219,7 +223,9 @@ def get_outputs(self, ray_bundle: RayBundle):
ray_samples_pdf = self.sampler_pdf(ray_bundle, ray_samples_uniform, weights)

# fine field:
field_outputs_fine = self.field.forward(ray_samples_pdf, acc_mask, colors.WHITE.to(weights.device))
field_outputs_fine = self.field.forward(
ray_samples_pdf, self.predict_normals, acc_mask, colors.WHITE.to(weights.device)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will TensoRF work with predicted normals?

Copy link
Collaborator Author

@ethanweber ethanweber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last comment.

self, ray_samples: RaySamples, mask: Optional[TensorType] = None, bg_color: Optional[TensorType] = None
self,
ray_samples: RaySamples,
compute_normals: bool = False,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or raise on error if compute_normals is True.

@terrancewang terrancewang merged commit b829499 into main Nov 20, 2022
@terrancewang terrancewang deleted the ethan/adding_normals branch November 20, 2022 21:22
chris838 pushed a commit to chris838/nerfstudio that referenced this pull request Apr 22, 2023
* staring normals PR

* code runs but visualization looks bad

* Camera and world coordinate conventions (nerfstudio-project#889)

* documented coordinate conventions without a figure for now

* another sentence

* update frames docs

* explain intrinsics and extrinsics

* more comments

* fix build

* Start viewer with more accurate speed calculation (nerfstudio-project#899)

Start viewer with more accurate speed calc

* Minor doc updates (nerfstudio-project#903)

* fix conflicts

* code runs but visualization looks bad

* normals implemented and vis fixed. still debugging quality

* minor name change

* comment

* fix black

* lint

* predicting normals

* adding detach

* predicted normals

* improved normals prediction performance

* cleaning code

* cleaning code

* cleaning code

* adding type to function param

* fixing tensorf forward func

* reverting tensorf changes

* fix style with tensorf field

* adding normals check to tensorffield

Co-authored-by: Matthew Tancik <[email protected]>
Co-authored-by: terrance <[email protected]>
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

Successfully merging this pull request may close these issues.

3 participants