Remove nerfacc aabb (#1874)

* Remove nerfacc aabb

* remove custom nerfacc logic

* lint
This commit is contained in:
Matthew Tancik authored and GitHub committed 2023-05-04 10:46:51 -07:00
1 parent 8030367e6b
commit 9ace02b3ae
2 files changed
+1 -44

No files matched your search

-4
View File
@@ -17,7 +17,6 @@ Camera Models
"""
import base64
import math
import os
from dataclasses import dataclass
from enum import Enum, auto
from typing import Dict, List, Optional, Tuple, Union
@@ -33,7 +32,6 @@ import nerfstudio.utils.poses as pose_utils
from nerfstudio.cameras import camera_utils
from nerfstudio.cameras.rays import RayBundle
from nerfstudio.data.scene_box import SceneBox
from nerfstudio.utils.misc import strtobool
from nerfstudio.utils.tensor_dataclass import TensorDataclass
TORCH_DEVICE = Union[torch.device, str] # pylint: disable=invalid-name
@@ -150,8 +148,6 @@ class Cameras(TensorDataclass):
self.__post_init__() # This will do the dataclass post_init and broadcast all the tensors
self._use_nerfacc = strtobool(os.environ.get("INTERSECT_WITH_NERFACC", "TRUE"))
def _init_get_fc_xy(self, fc_xy: Union[float, torch.Tensor], name: str) -> torch.Tensor:
"""
Parses the input focal length / principle point x or y and returns a tensor of the correct shape
+1 -40
View File
@@ -21,8 +21,6 @@ import torch
from torchtyping import TensorType
from typing_extensions import Literal
_USE_NERFACC = True
def components_from_spherical_harmonics(levels: int, directions: TensorType[..., 3]) -> TensorType[..., "components"]:
"""
@@ -198,7 +196,7 @@ def expected_sin(x_means: torch.Tensor, x_vars: torch.Tensor) -> torch.Tensor:
@torch.jit.script
def _intersect_aabb(
def intersect_aabb(
origins: torch.Tensor,
directions: torch.Tensor,
aabb: torch.Tensor,
@@ -238,43 +236,6 @@ def _intersect_aabb(
return t_min, t_max
def intersect_aabb(
origins: TensorType["N", 3],
directions: TensorType["N", 3],
aabb: TensorType[6],
) -> Tuple[TensorType["N"], TensorType["N"]]:
"""
Implementation of ray intersection with AABB box
Args:
origins: 3d positions
directions: Normalized directions
aabb: array of aabb box in the form of [x_min, y_min, z_min, x_max, y_max, z_max]
max_bound: Maximum value of t_max
invalid_value: Value to return in case of no intersection
Returns:
t_min, t_max - two tensors of shapes N representing distance of intersection from the origin.
"""
global _USE_NERFACC # pylint: disable=global-statement
if _USE_NERFACC:
try:
import nerfacc # pylint: disable=import-outside-toplevel
t_min, t_max, _ = nerfacc.ray_aabb_intersect(
origins, directions, aabb[None, :], near_plane=0, far_plane=1e10, miss_value=1e10
)
t_min, t_max = t_min.squeeze(-1), t_max.squeeze(-1)
except: # pylint: disable=bare-except
t_min, t_max = _intersect_aabb(origins, directions, aabb, max_bound=1e10, invalid_value=1e10)
_USE_NERFACC = False
else:
t_min, t_max = _intersect_aabb(origins, directions, aabb, max_bound=1e10, invalid_value=1e10)
return t_min, t_max
def safe_normalize(
vectors: TensorType["batch_dim":..., "N"],
eps: float = 1e-10,