mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-04 23:08:44 +08:00
Stricter typing, update docstrings (#226)
This commit is contained in:
1 parent
395b03f48c
commit
44a7fa288c
10 files changed
+181
-181
No files matched your search
+28
-28
@@ -31,19 +31,19 @@ from nerfactory.utils.tensor_dataclass import TensorDataclass
|
||||
class Frustums(TensorDataclass):
|
||||
"""Describes region of space as a frustum.
|
||||
|
||||
Args:
|
||||
origins (TensorType[..., 3]): xyz coordinate for ray origin.
|
||||
directions (TensorType[..., 3]): Direction of ray.
|
||||
starts (TensorType[..., num_samples, 1]): Where the frustum starts along a ray.
|
||||
ends (TensorType[..., num_samples, 1]): Where the frustum ends along a ray.
|
||||
pixel_area (TensorType[..., 1]): Projected area of pixel a distance 1 away from origin.
|
||||
Attributes:
|
||||
origins: xyz coordinate for ray origin.
|
||||
directions: Direction of ray.
|
||||
starts: Where the frustum starts along a ray.
|
||||
ends: Where the frustum ends along a ray.
|
||||
pixel_area: Projected area of pixel a distance 1 away from origin.
|
||||
"""
|
||||
|
||||
origins: TensorType[..., 3]
|
||||
directions: TensorType[..., 3]
|
||||
starts: TensorType[..., 1]
|
||||
ends: TensorType[..., 1]
|
||||
pixel_area: TensorType[..., 1]
|
||||
origins: TensorType["bs":..., 3]
|
||||
directions: TensorType["bs":..., 3]
|
||||
starts: TensorType["bs":..., 1]
|
||||
ends: TensorType["bs":..., 1]
|
||||
pixel_area: TensorType["bs":..., 1]
|
||||
|
||||
def get_positions(self) -> TensorType[..., 3]:
|
||||
"""Calulates "center" position of frustum. Not weighted by mass.
|
||||
@@ -90,17 +90,17 @@ class RaySamples(TensorDataclass):
|
||||
"""Samples along a ray
|
||||
|
||||
Args:
|
||||
frustums (Frustums): Frustums along ray.
|
||||
camera_indices (TensorType[..., 1]): Camera index.
|
||||
valid_mask (TensorType[..., 1]): Rays that are valid.
|
||||
deltas (TensorType[..., 1]): "width" of each sample.
|
||||
ts (TensorType[..., 1]): sample-camera distance of each sample.
|
||||
frustums: Frustums along ray.
|
||||
camera_indices: Camera index.
|
||||
valid_mask: Rays that are valid.
|
||||
deltas: "width" of each sample.
|
||||
ts: sample-camera distance of each sample.
|
||||
"""
|
||||
|
||||
frustums: Frustums
|
||||
camera_indices: TensorType[..., 1] = None
|
||||
valid_mask: TensorType[..., 1] = None
|
||||
deltas: TensorType[..., 1] = None
|
||||
camera_indices: TensorType["bs":..., 1] = None
|
||||
valid_mask: TensorType["bs":..., 1] = None
|
||||
deltas: TensorType["bs":..., 1] = None
|
||||
|
||||
def get_weights(self, densities: TensorType[..., "num_samples", 1]) -> TensorType[..., "num_samples", 1]:
|
||||
"""Return weights based on predicted densities
|
||||
@@ -152,13 +152,13 @@ class RayBundle(TensorDataclass):
|
||||
"""A bundle of ray parameters.
|
||||
|
||||
Args:
|
||||
origins (TensorType[..., 3]): Ray origins (XYZ)
|
||||
directions (TensorType[..., 3]): Unit ray direction vector
|
||||
pixel_area (TensorType[..., 1]): Projected area of pixel a distance 1 away from origin.
|
||||
camera_indices (TensorType[..., 1]): Camera indices
|
||||
nears (TensorType[..., 1]): Distance along ray to start sampling
|
||||
fars (TensorType[..., 1]): Rays Distance along ray to stop sampling
|
||||
valid_mask (TensorType[..., 1]): Rays that are valid
|
||||
origins: Ray origins (XYZ)
|
||||
directions: Unit ray direction vector
|
||||
pixel_area: Projected area of pixel a distance 1 away from origin.
|
||||
camera_indices: Camera indices
|
||||
nears: Distance along ray to start sampling
|
||||
fars: Rays Distance along ray to stop sampling
|
||||
valid_mask: Rays that are valid
|
||||
"""
|
||||
|
||||
origins: TensorType["num_rays", 3]
|
||||
@@ -167,7 +167,7 @@ class RayBundle(TensorDataclass):
|
||||
camera_indices: Optional[TensorType["num_rays", 1]] = None
|
||||
nears: Optional[TensorType["num_rays", 1]] = None
|
||||
fars: Optional[TensorType["num_rays", 1]] = None
|
||||
valid_mask: Optional[TensorType["num_rays", 1]] = None
|
||||
valid_mask: Optional[TensorType["num_rays", 1, bool]] = None
|
||||
num_rays_per_chunk: int = None
|
||||
|
||||
def move_to_device(self, device: torch.device) -> None:
|
||||
@@ -220,7 +220,7 @@ class RayBundle(TensorDataclass):
|
||||
return self.flatten()[start_idx:end_idx]
|
||||
|
||||
def get_ray_samples(
|
||||
self, bin_starts: TensorType[..., "num_samples", 1], bin_ends: TensorType[..., "num_samples", 1]
|
||||
self, bin_starts: TensorType["bs":..., "num_samples", 1], bin_ends: TensorType["bs":..., "num_samples", 1]
|
||||
) -> RaySamples:
|
||||
"""Produces samples for each ray by projection points along the ray direction.
|
||||
|
||||
|
||||
Reference in new issue
Block a user