mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-29 12:31:53 +08:00
NeuS Implementation (#1444)
* add initial method configs and data manager * add neus scheduler * add initial surface model and neus * add Neus ray sampler * add sdf field * move scale/shift calc to math utils * add debug and fix sdf_dataset typo * update vscode neus debug * fix dataset and get initial working version * add magic number from original repo * black fixes * clean up get weights/transmittance from alphas * clean up typos in sdf datamanager * type annotations on neus scheduler and remove unused params * clean up and annotate sdf field along w/ other fixes * more clean up * remove unnessary directions norm * resolve comments * update neus scheduler to follow refactor * fix linter errors * fix some typos * remove get_weights_from_alpha * more comment fixes * more linter error fixes * clean up and add comments * more little fixes for types/comments * more comments * rename NeuS Scheduler to DelayedScheduler * rename DelayedScheduler to CosineDecayScheduler
This commit is contained in:
1 parent
1b18b44d81
commit
ddfa463f4d
16 files changed
+1376
-53
No files matched your search
@@ -17,7 +17,7 @@ Some ray datastructures.
|
||||
"""
|
||||
import random
|
||||
from dataclasses import dataclass
|
||||
from typing import Callable, Dict, Optional, Union
|
||||
from typing import Callable, Dict, Optional, Tuple, Union
|
||||
|
||||
import torch
|
||||
from torchtyping import TensorType
|
||||
@@ -56,6 +56,14 @@ class Frustums(TensorDataclass):
|
||||
pos = pos + self.offsets
|
||||
return pos
|
||||
|
||||
def get_start_positions(self) -> TensorType[..., 3]:
|
||||
"""Calulates "start" position of frustum.
|
||||
|
||||
Returns:
|
||||
xyz positions.
|
||||
"""
|
||||
return self.origins + self.directions * self.starts
|
||||
|
||||
def set_offsets(self, offsets):
|
||||
"""Sets offsets for this frustum for computing positions"""
|
||||
self.offsets = offsets
|
||||
@@ -140,6 +148,27 @@ class RaySamples(TensorDataclass):
|
||||
|
||||
return weights
|
||||
|
||||
@staticmethod
|
||||
def get_weights_and_transmittance_from_alphas(
|
||||
alphas: TensorType[..., "num_samples", 1], weights_only: bool = False
|
||||
) -> Tuple[TensorType[..., "num_samples", 1], TensorType[..., "num_samples", 1]]:
|
||||
"""Return weights based on predicted alphas
|
||||
Args:
|
||||
alphas: Predicted alphas (maybe from sdf) for samples along ray
|
||||
weights_only: If function should return only weights
|
||||
Returns:
|
||||
Tuple of weights and transmittance for each sample
|
||||
"""
|
||||
|
||||
transmittance = torch.cumprod(
|
||||
torch.cat([torch.ones((*alphas.shape[:1], 1, 1), device=alphas.device), 1.0 - alphas + 1e-7], 1), 1
|
||||
)
|
||||
|
||||
weights = alphas * transmittance[:, :-1, :]
|
||||
if weights_only:
|
||||
return weights
|
||||
return weights, transmittance
|
||||
|
||||
|
||||
@dataclass
|
||||
class RayBundle(TensorDataclass):
|
||||
|
||||
Reference in new issue
Block a user