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

AABB Conflict FIx #3422

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Anthony-Tafoya
Copy link
Contributor

@Anthony-Tafoya Anthony-Tafoya commented Sep 11, 2024

This PR relates to issue #3405. Credit to hoanle for finding the issue.

Background:
OccGridEstimator uses different levels of AABBs to determine where to sample the points from with varying levels of detail.

        # multiple levels of aabbs
        aabbs = torch.stack(
            [_enlarge_aabb(roi_aabb, 2**i) for i in range(levels)], dim=0
        )

But those samples outside the original AABB are not used anyway if we disable the scene contraction:

        if self.spatial_distortion is not None:
            positions = ray_samples.frustums.get_positions()
            positions = self.spatial_distortion(positions)
            positions = (positions + 2.0) / 4.0
        else:
            positions = SceneBox.get_normalized_positions(
                ray_samples.frustums.get_positions(), self.aabb
            )

Since the positions (if distortion is disabled) are taken from a normalized standpoint until the self.aabb parameter is passed in.

Problem:
The problem is that if we begin with the scene_aabb, the outermost AABB, we will not use any of the other resolutions in our enlargement calculations. Therefore, we need to start from the innermost AABB depending on the number of levels.

@jb-ye
Copy link
Collaborator

jb-ye commented Sep 18, 2024

would you want to rebase your PR?

@Anthony-Tafoya
Copy link
Contributor Author

would you want to rebase your PR?

I can rebase no worries

@Anthony-Tafoya Anthony-Tafoya force-pushed the Anthony/AABB-Conflict-With-Instant-ngp branch 2 times, most recently from a952142 to c9a8bf4 Compare September 19, 2024 22:17
@Anthony-Tafoya Anthony-Tafoya force-pushed the Anthony/AABB-Conflict-With-Instant-ngp branch from c9a8bf4 to f86dbe6 Compare September 20, 2024 00:13
@Anthony-Tafoya Anthony-Tafoya force-pushed the Anthony/AABB-Conflict-With-Instant-ngp branch 2 times, most recently from 3d14c25 to 8e400c4 Compare September 20, 2024 00:24
@Anthony-Tafoya Anthony-Tafoya force-pushed the Anthony/AABB-Conflict-With-Instant-ngp branch from 8e400c4 to 715f96e Compare September 20, 2024 00:31
@Anthony-Tafoya
Copy link
Contributor Author

I am unsure at the moment of how to test this properly, so open to thoughts. Will look at other PR's and try to create something

@@ -118,7 +118,7 @@ def populate_modules(self):
self.config.render_step_size = ((self.scene_aabb[3:] - self.scene_aabb[:3]) ** 2).sum().sqrt().item() / 1000
# Occupancy Grid.
self.occupancy_grid = nerfacc.OccGridEstimator(
roi_aabb=self.scene_aabb,
Copy link
Contributor

@hoanhle hoanhle Sep 24, 2024

Choose a reason for hiding this comment

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

I'm pretty sure that this would uniformly shrink or grow the scene_aabb from the origin, without considering the center.

A correct approach would be to first implement something like this in SceneBox

    def get_scaled_scene_box(self, scale_factor: Union[float, torch.Tensor] = 1.5):
        """Returns a new box that has been scaled by the given factor while
        maintaining its center.

        Args:
            scale_factor: How much to scale the bounding box by.

        Returns:
            SceneBox: A new SceneBox with the scaled bounding box.
        """
        center = self.get_center()
        scaled_aabb = (self.aabb - center) * scale_factor + center
        return SceneBox(aabb=scaled_aabb)

and then , call this function where needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

It would be great if you could include this. I can review the PR once it's up. Also, I think it would be a good idea to disable scene contraction by default in instant-ngp.

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