This commit is contained in:
Matt Tancik committed 2023-03-22 14:37:05 -07:00
1 parent 6db1d314cc
commit 3ec8c06e83
7 files changed
+18 -1

No files matched your search

+1 -1
View File
@@ -338,7 +338,7 @@ class MiDaSMSELoss(nn.Module):
def __init__(self, reduction_type: Literal["image", "batch"] = "batch"): def __init__(self, reduction_type: Literal["image", "batch"] = "batch"):
super().__init__() super().__init__()
self.reduction_type = reduction_type self.reduction_type: Literal["image", "batch"] = reduction_type
# reduction here is different from the image/batch-based reduction. This is either "mean" or "sum" # reduction here is different from the image/batch-based reduction. This is either "mean" or "sum"
self.mse_loss = MSELoss(reduction="none") self.mse_loss = MSELoss(reduction="none")
@@ -641,6 +641,7 @@ class NeuSSampler(Sampler):
# Start with uniform sampling # Start with uniform sampling
if ray_samples is None: if ray_samples is None:
ray_samples = self.uniform_sampler(ray_bundle, num_samples=self.num_samples) ray_samples = self.uniform_sampler(ray_bundle, num_samples=self.num_samples)
assert ray_samples is not None
total_iters = 0 total_iters = 0
sorted_index = None sorted_index = None
@@ -697,6 +698,7 @@ class NeuSSampler(Sampler):
""" """
batch_size = ray_samples.shape[0] batch_size = ray_samples.shape[0]
prev_sdf, next_sdf = sdf[:, :-1], sdf[:, 1:] prev_sdf, next_sdf = sdf[:, :-1], sdf[:, 1:]
assert ray_samples.deltas is not None
deltas = ray_samples.deltas[:, :-1, 0] deltas = ray_samples.deltas[:, :-1, 0]
mid_sdf = (prev_sdf + next_sdf) * 0.5 mid_sdf = (prev_sdf + next_sdf) * 0.5
cos_val = (next_sdf - prev_sdf) / (deltas + 1e-5) cos_val = (next_sdf - prev_sdf) / (deltas + 1e-5)
@@ -738,6 +740,9 @@ class NeuSSampler(Sampler):
ray_samples_2 : ray_samples to merge ray_samples_2 : ray_samples to merge
""" """
assert ray_samples_1.spacing_starts is not None and ray_samples_2.spacing_starts is not None
assert ray_samples_1.spacing_ends is not None and ray_samples_2.spacing_ends is not None
assert ray_samples_1.spacing_to_euclidean_fn is not None
starts_1 = ray_samples_1.spacing_starts[..., 0] starts_1 = ray_samples_1.spacing_starts[..., 0]
starts_2 = ray_samples_2.spacing_starts[..., 0] starts_2 = ray_samples_2.spacing_starts[..., 0]
+1
View File
@@ -101,6 +101,7 @@ class Model(nn.Module):
# NOTE: call `super().populate_modules()` in subclasses # NOTE: call `super().populate_modules()` in subclasses
if self.config.enable_collider: if self.config.enable_collider:
assert self.config.collider_params is not None
self.collider = NearFarCollider( self.collider = NearFarCollider(
near_plane=self.config.collider_params["near_plane"], far_plane=self.config.collider_params["far_plane"] near_plane=self.config.collider_params["near_plane"], far_plane=self.config.collider_params["far_plane"]
) )
+3
View File
@@ -90,6 +90,8 @@ class TensoRFModel(Model):
config: TensoRF configuration to instantiate model config: TensoRF configuration to instantiate model
""" """
config: TensoRFModelConfig
def __init__( def __init__(
self, self,
config: TensoRFModelConfig, config: TensoRFModelConfig,
@@ -303,6 +305,7 @@ class TensoRFModel(Model):
image = batch["image"].to(outputs["rgb"].device) image = batch["image"].to(outputs["rgb"].device)
rgb = outputs["rgb"] rgb = outputs["rgb"]
acc = colormaps.apply_colormap(outputs["accumulation"]) acc = colormaps.apply_colormap(outputs["accumulation"])
assert self.config.collider_params is not None
depth = colormaps.apply_depth_colormap( depth = colormaps.apply_depth_colormap(
outputs["depth"], outputs["depth"],
accumulation=outputs["accumulation"], accumulation=outputs["accumulation"],
+1
View File
@@ -201,6 +201,7 @@ class NeRFModel(Model):
rgb_fine = outputs["rgb_fine"] rgb_fine = outputs["rgb_fine"]
acc_coarse = colormaps.apply_colormap(outputs["accumulation_coarse"]) acc_coarse = colormaps.apply_colormap(outputs["accumulation_coarse"])
acc_fine = colormaps.apply_colormap(outputs["accumulation_fine"]) acc_fine = colormaps.apply_colormap(outputs["accumulation_fine"])
assert self.config.collider_params is not None
depth_coarse = colormaps.apply_depth_colormap( depth_coarse = colormaps.apply_depth_colormap(
outputs["depth_coarse"], outputs["depth_coarse"],
accumulation=outputs["accumulation_coarse"], accumulation=outputs["accumulation_coarse"],
+2
View File
@@ -95,6 +95,7 @@ class Pipeline(nn.Module):
datamanager: DataManager datamanager: DataManager
_model: Model _model: Model
world_size: int
@property @property
def model(self): def model(self):
@@ -201,6 +202,7 @@ class VanillaPipelineConfig(cfg.InstantiateConfig):
class VanillaPipeline(Pipeline): class VanillaPipeline(Pipeline):
"""The pipeline class for the vanilla nerf setup of multiple cameras for one or a few scenes. """The pipeline class for the vanilla nerf setup of multiple cameras for one or a few scenes.
Args:
config: configuration to instantiate pipeline config: configuration to instantiate pipeline
device: location to place model and data device: location to place model and data
test_mode: test_mode:
+5
View File
@@ -75,6 +75,11 @@ def run_hloc(
camera_model: Camera model to use. camera_model: Camera model to use.
gpu: If True, use GPU. gpu: If True, use GPU.
verbose: If True, logs the output of the command. verbose: If True, logs the output of the command.
matching_method: Method to use for matching images.
feature_type: Type of visual features to use.
matcher_type: Type of feature matcher to use.
num_matched: Number of image pairs for loc.
refine_pixsfm: If True, refine the reconstruction using pixel-perfect-sfm.
""" """
if not _HAS_HLOC: if not _HAS_HLOC:
CONSOLE.print( CONSOLE.print(