mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-01 13:28:59 +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
@@ -21,9 +21,8 @@ from typing import Dict, Optional, Tuple
|
||||
|
||||
import numpy as np
|
||||
import torch
|
||||
from torch import nn
|
||||
from torch import Tensor, nn
|
||||
from torch.nn.parameter import Parameter
|
||||
from torchtyping import TensorType
|
||||
|
||||
from nerfstudio.cameras.rays import RaySamples
|
||||
from nerfstudio.data.scene_box import SceneBox
|
||||
@@ -83,7 +82,7 @@ class TCNNNerfactoField(Field):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
aabb: TensorType,
|
||||
aabb: Tensor,
|
||||
num_images: int,
|
||||
num_layers: int = 2,
|
||||
hidden_dim: int = 64,
|
||||
@@ -224,7 +223,7 @@ class TCNNNerfactoField(Field):
|
||||
},
|
||||
)
|
||||
|
||||
def get_density(self, ray_samples: RaySamples) -> Tuple[TensorType, TensorType]:
|
||||
def get_density(self, ray_samples: RaySamples) -> Tuple[Tensor, Tensor]:
|
||||
"""Computes and returns the densities."""
|
||||
if self.spatial_distortion is not None:
|
||||
positions = ray_samples.frustums.get_positions()
|
||||
@@ -251,8 +250,8 @@ class TCNNNerfactoField(Field):
|
||||
return density, base_mlp_out
|
||||
|
||||
def get_outputs(
|
||||
self, ray_samples: RaySamples, density_embedding: Optional[TensorType] = None
|
||||
) -> Dict[FieldHeadNames, TensorType]:
|
||||
self, ray_samples: RaySamples, density_embedding: Optional[Tensor] = None
|
||||
) -> Dict[FieldHeadNames, Tensor]:
|
||||
assert density_embedding is not None
|
||||
outputs = {}
|
||||
if ray_samples.camera_indices is None:
|
||||
@@ -332,7 +331,7 @@ class TorchNerfactoField(Field):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
aabb: TensorType,
|
||||
aabb: Tensor,
|
||||
num_images: int,
|
||||
position_encoding: Encoding = HashEncoding(),
|
||||
direction_encoding: Encoding = SHEncoding(),
|
||||
@@ -375,7 +374,7 @@ class TorchNerfactoField(Field):
|
||||
for field_head in self.field_heads:
|
||||
field_head.set_in_dim(self.mlp_head.get_out_dim()) # type: ignore
|
||||
|
||||
def get_density(self, ray_samples: RaySamples) -> Tuple[TensorType, TensorType]:
|
||||
def get_density(self, ray_samples: RaySamples) -> Tuple[Tensor, Tensor]:
|
||||
if self.spatial_distortion is not None:
|
||||
positions = ray_samples.frustums.get_positions()
|
||||
positions = self.spatial_distortion(positions)
|
||||
@@ -387,8 +386,8 @@ class TorchNerfactoField(Field):
|
||||
return density, base_mlp_out
|
||||
|
||||
def get_outputs(
|
||||
self, ray_samples: RaySamples, density_embedding: Optional[TensorType] = None
|
||||
) -> Dict[FieldHeadNames, TensorType]:
|
||||
self, ray_samples: RaySamples, density_embedding: Optional[Tensor] = None
|
||||
) -> Dict[FieldHeadNames, Tensor]:
|
||||
outputs_shape = ray_samples.frustums.directions.shape[:-1]
|
||||
|
||||
if ray_samples.camera_indices is None:
|
||||
|
||||
Reference in new issue
Block a user