CropBox GUI implementation (#1205)

* fixed an exception bug in case of num_samples is 0

fixed an exception bug when num samples is 0 , 
"IndexError tensors used as indices must be long, byte or bool tensors"

change type to long ( was float32)

* implemented crop box in gui. For now works on instant-ngp-bounded

* fixed import bugs

* update aabb every time and not only on training

* prevent crash when chosing accomulation and crop box

* Checkbox

* max_box is bounded by scevne box in the gui

* implemented altenative intesection to nerfacc

* convert str to bool correctly

* fixed isort bug

* fixed isort bug2

* update viewer version

* remove json bug

* Update UI

* Force black background

* Fix formatting

Co-authored-by: dror <you@example.com>
Co-authored-by: Matt Tancik <tancik@berkeley.edu>
Co-authored-by: Matthew Tancik <mattt4001@gmail.com>
This commit is contained in:
authored and GitHub committed 2023-01-19 17:39:37 -08:00
1 parent fef6b861be
commit 2120bd5dd9
12 files changed
+518 -25

No files matched your search

+1
View File
@@ -36,6 +36,7 @@ def apply_colormap(image: TensorType["bs":..., 1], cmap="viridis") -> TensorType
colormap = cm.get_cmap(cmap)
colormap = torch.tensor(colormap.colors).to(image.device) # type: ignore
image = torch.nan_to_num(image, 0)
image_long = (image * 255).long()
image_long_min = torch.min(image_long)
image_long_max = torch.max(image_long)
+46
View File
@@ -191,3 +191,49 @@ def expected_sin(x_means: torch.Tensor, x_vars: torch.Tensor) -> torch.Tensor:
"""
return torch.exp(-0.5 * x_vars) * torch.sin(x_means)
def intersect_aabb(origins, directions, aabb):
"""
pytorch implementation of ray intersection with AABB box
:param origin: N,3 tensor of 3d positions
:param direction: N,3 tensor of normalized directions
:param aabb: 6,1 array of aabb box in the form of [x_min, y_min, z_min, x_max, y_max, z_max]
:return: t_min, t_max - two tensors of shapes N,1 representing the intersection signed distance from
the origin. t_min is clipped to 0 in case it is negative, in case of no intersection t_min is 1e10.
"""
max_bound = 1e10
tx_min = (aabb[0] - origins[:, 0]) / directions[:, 0]
tx_max = (aabb[3] - origins[:, 0]) / directions[:, 0]
t_min = torch.min(tx_min, tx_max)
t_max = torch.max(tx_min, tx_max)
ty_min_temp = (aabb[1] - origins[:, 1]) / directions[:, 1]
ty_max_temp = (aabb[4] - origins[:, 1]) / directions[:, 1]
ty_min = torch.min(ty_min_temp, ty_max_temp)
ty_max = torch.max(ty_min_temp, ty_max_temp)
cond = torch.logical_or((t_min > ty_max), (ty_min > t_max))
t_min = torch.where(cond, max_bound, t_min)
t_max = torch.where(cond, max_bound, t_max)
t_min = torch.max(t_min, ty_min)
t_max = torch.min(t_max, ty_max)
tz_min_temp = (aabb[2] - origins[:, 2]) / directions[:, 2]
tz_max_temp = (aabb[5] - origins[:, 2]) / directions[:, 2]
tz_min = torch.min(tz_min_temp, tz_max_temp)
tz_max = torch.max(tz_min_temp, tz_max_temp)
cond = torch.logical_or((t_min > tz_max), tz_min > t_max)
t_min = torch.where(cond, max_bound, t_min)
t_max = torch.where(cond, max_bound, t_max)
t_min = torch.max(t_min, tz_min)
t_max = torch.min(t_max, tz_max)
t_min = torch.where(t_min > 0, t_min, 0)
t_max = torch.where(t_min == max_bound, max_bound, t_max)
return t_min, t_max