mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-29 12:31:53 +08:00
torchtyping => jaxtyping (#1838)
* Run `ruff --fix` * Add jaxtyping migration script * Run migration scripts + ruff + black * Merge remote-tracking branch 'origin/main' into brent/jaxtyping * black * Fix lint * fix lint * Cleanup and more specific types * Fixed annotation errors * Fix more errors * Fix annotation * Delete _torchtyping_to_jaxtyping.py --------- Co-authored-by: Matt Tancik <mattt4001@gmail.com>
This commit is contained in:
1 parent
9b6290ea43
commit
6ba2a18b2b
65 files changed
+597
-531
No files matched your search
@@ -20,9 +20,9 @@ from abc import abstractmethod
|
||||
from typing import Callable, List, Optional, Tuple, Union
|
||||
|
||||
import torch
|
||||
from jaxtyping import Float
|
||||
from nerfacc import OccGridEstimator
|
||||
from torch import nn
|
||||
from torchtyping import TensorType
|
||||
from torch import Tensor, nn
|
||||
|
||||
from nerfstudio.cameras.rays import Frustums, RayBundle, RaySamples
|
||||
|
||||
@@ -111,7 +111,10 @@ class SpacedSampler(Sampler):
|
||||
bins = bin_lower + (bin_upper - bin_lower) * t_rand
|
||||
|
||||
s_near, s_far = (self.spacing_fn(x) for x in (ray_bundle.nears, ray_bundle.fars))
|
||||
spacing_to_euclidean_fn = lambda x: self.spacing_fn_inv(x * s_far + (1 - x) * s_near)
|
||||
|
||||
def spacing_to_euclidean_fn(x):
|
||||
return self.spacing_fn_inv(x * s_far + (1 - x) * s_near)
|
||||
|
||||
euclidean_bins = spacing_to_euclidean_fn(bins) # [num_rays, num_samples+1]
|
||||
|
||||
ray_samples = ray_bundle.get_ray_samples(
|
||||
@@ -274,7 +277,7 @@ class PDFSampler(Sampler):
|
||||
self,
|
||||
ray_bundle: Optional[RayBundle] = None,
|
||||
ray_samples: Optional[RaySamples] = None,
|
||||
weights: TensorType[..., "num_samples", 1] = None,
|
||||
weights: Float[Tensor, "*batch num_samples 1"] = None,
|
||||
num_samples: Optional[int] = None,
|
||||
eps: float = 1e-5,
|
||||
) -> RaySamples:
|
||||
@@ -382,7 +385,7 @@ class VolumetricSampler(Sampler):
|
||||
def __init__(
|
||||
self,
|
||||
occupancy_grid: OccGridEstimator,
|
||||
density_fn: Optional[Callable[[TensorType[..., 3]], TensorType[..., 1]]] = None,
|
||||
density_fn: Optional[Callable[[Float[Tensor, "*batch 3"]], Float[Tensor, "*batch 1"]]] = None,
|
||||
) -> None:
|
||||
super().__init__()
|
||||
assert occupancy_grid is not None
|
||||
@@ -429,7 +432,7 @@ class VolumetricSampler(Sampler):
|
||||
far_plane: Optional[float] = None,
|
||||
alpha_thre: float = 0.01,
|
||||
cone_angle: float = 0.0,
|
||||
) -> Tuple[RaySamples, TensorType["total_samples",]]:
|
||||
) -> Tuple[RaySamples, Float[Tensor, "total_samples "]]:
|
||||
"""Generate ray samples in a bounding box.
|
||||
|
||||
Args:
|
||||
@@ -683,8 +686,8 @@ class NeuSSampler(Sampler):
|
||||
|
||||
@staticmethod
|
||||
def rendering_sdf_with_fixed_inv_s(
|
||||
ray_samples: RaySamples, sdf: TensorType["num_samples", -1], inv_s: int
|
||||
) -> TensorType["num_samples", -1]:
|
||||
ray_samples: RaySamples, sdf: Float[Tensor, "num_samples 1"], inv_s: int
|
||||
) -> Float[Tensor, "num_samples 1"]:
|
||||
"""
|
||||
rendering given a fixed inv_s as NeuS
|
||||
|
||||
|
||||
Reference in new issue
Block a user