mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-03 22:38:48 +08:00
add number of gaussians in logger; allow testing in nerfacto
This commit is contained in:
1 parent
35be6fd421
commit
75d2d14b75
5 files changed
+29
-12
No files matched your search
@@ -88,6 +88,7 @@ class LocalWriterConfig(InstantiateConfig):
|
|||||||
writer.EventName.VIS_RAYS_PER_SEC,
|
writer.EventName.VIS_RAYS_PER_SEC,
|
||||||
writer.EventName.TEST_RAYS_PER_SEC,
|
writer.EventName.TEST_RAYS_PER_SEC,
|
||||||
writer.EventName.ETA,
|
writer.EventName.ETA,
|
||||||
|
writer.EventName.GAUSSIAN_NUM,
|
||||||
)
|
)
|
||||||
"""specifies which stats will be logged/printed to terminal"""
|
"""specifies which stats will be logged/printed to terminal"""
|
||||||
max_log_size: int = 10
|
max_log_size: int = 10
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ from nerfstudio.configs.experiment_config import ExperimentConfig
|
|||||||
from nerfstudio.data.datamanagers.base_datamanager import VanillaDataManager
|
from nerfstudio.data.datamanagers.base_datamanager import VanillaDataManager
|
||||||
from nerfstudio.engine.callbacks import TrainingCallback, TrainingCallbackAttributes, TrainingCallbackLocation
|
from nerfstudio.engine.callbacks import TrainingCallback, TrainingCallbackAttributes, TrainingCallbackLocation
|
||||||
from nerfstudio.engine.optimizers import Optimizers
|
from nerfstudio.engine.optimizers import Optimizers
|
||||||
|
from nerfstudio.models.gaussian_splatting import GaussianSplattingModel
|
||||||
from nerfstudio.pipelines.base_pipeline import VanillaPipeline
|
from nerfstudio.pipelines.base_pipeline import VanillaPipeline
|
||||||
from nerfstudio.utils import profiler, writer
|
from nerfstudio.utils import profiler, writer
|
||||||
from nerfstudio.utils.decorators import check_eval_enabled, check_main_thread, check_viewer_enabled
|
from nerfstudio.utils.decorators import check_eval_enabled, check_main_thread, check_viewer_enabled
|
||||||
@@ -262,14 +263,21 @@ class Trainer:
|
|||||||
|
|
||||||
# Skip the first two steps to avoid skewed timings that break the viewer rendering speed estimate.
|
# Skip the first two steps to avoid skewed timings that break the viewer rendering speed estimate.
|
||||||
if step > 1:
|
if step > 1:
|
||||||
writer.put_time(
|
if isinstance(self.pipeline.model, GaussianSplattingModel):
|
||||||
name=EventName.TRAIN_RAYS_PER_SEC,
|
writer.put_scalar(
|
||||||
duration=self.world_size
|
name=EventName.GAUSSIAN_NUM,
|
||||||
* self.pipeline.datamanager.get_train_rays_per_batch()
|
scalar=self.pipeline.model.get_gaussian_num,
|
||||||
/ max(0.001, train_t.duration),
|
step=step,
|
||||||
step=step,
|
)
|
||||||
avg_over_steps=True,
|
else:
|
||||||
)
|
writer.put_time(
|
||||||
|
name=EventName.TRAIN_RAYS_PER_SEC,
|
||||||
|
duration=self.world_size
|
||||||
|
* self.pipeline.datamanager.get_train_rays_per_batch()
|
||||||
|
/ max(0.001, train_t.duration),
|
||||||
|
step=step,
|
||||||
|
avg_over_steps=True,
|
||||||
|
)
|
||||||
|
|
||||||
self._update_viewer_state(step)
|
self._update_viewer_state(step)
|
||||||
|
|
||||||
|
|||||||
@@ -191,6 +191,10 @@ class GaussianSplattingModel(Model):
|
|||||||
def get_rotation(self):
|
def get_rotation(self):
|
||||||
return self.rotation_activation(self._rotation)
|
return self.rotation_activation(self._rotation)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def get_gaussian_num(self):
|
||||||
|
return self._xyz.shape[0]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def get_xyz(self):
|
def get_xyz(self):
|
||||||
return self._xyz
|
return self._xyz
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ class EventName(enum.Enum):
|
|||||||
TRAIN_RAYS_PER_SEC = "Train Rays / Sec"
|
TRAIN_RAYS_PER_SEC = "Train Rays / Sec"
|
||||||
TEST_RAYS_PER_SEC = "Test Rays / Sec"
|
TEST_RAYS_PER_SEC = "Test Rays / Sec"
|
||||||
VIS_RAYS_PER_SEC = "Vis Rays / Sec"
|
VIS_RAYS_PER_SEC = "Vis Rays / Sec"
|
||||||
|
GAUSSIAN_NUM = "Number of Gaussians"
|
||||||
CURR_TEST_PSNR = "Test PSNR"
|
CURR_TEST_PSNR = "Test PSNR"
|
||||||
|
|
||||||
|
|
||||||
@@ -468,7 +469,7 @@ class LocalWriter:
|
|||||||
if name in self.stats_to_track:
|
if name in self.stats_to_track:
|
||||||
if "(time)" in name:
|
if "(time)" in name:
|
||||||
v = _format_time(v)
|
v = _format_time(v)
|
||||||
elif "Rays" in name:
|
elif "Rays" in name or "Gaussians" in name:
|
||||||
v = human_format(v)
|
v = human_format(v)
|
||||||
else:
|
else:
|
||||||
v = f"{v:0.4f}"
|
v = f"{v:0.4f}"
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import torch
|
|||||||
from nerfstudio.cameras.cameras import Cameras
|
from nerfstudio.cameras.cameras import Cameras
|
||||||
from nerfstudio.model_components.renderers import \
|
from nerfstudio.model_components.renderers import \
|
||||||
background_color_override_context
|
background_color_override_context
|
||||||
|
from nerfstudio.models.gaussian_splatting import GaussianSplattingModel
|
||||||
from nerfstudio.utils import colormaps, writer
|
from nerfstudio.utils import colormaps, writer
|
||||||
from nerfstudio.utils.writer import GLOBAL_BUFFER, EventName, TimeWriter
|
from nerfstudio.utils.writer import GLOBAL_BUFFER, EventName, TimeWriter
|
||||||
from nerfstudio.viewer.server import viewer_utils
|
from nerfstudio.viewer.server import viewer_utils
|
||||||
@@ -129,7 +130,9 @@ class RenderStateMachine(threading.Thread):
|
|||||||
|
|
||||||
with self.viewer.train_lock if self.viewer.train_lock is not None else contextlib.nullcontext():
|
with self.viewer.train_lock if self.viewer.train_lock is not None else contextlib.nullcontext():
|
||||||
#TODO jake-austin: Make this check whether the model inherits from a camera based model or a ray based model
|
#TODO jake-austin: Make this check whether the model inherits from a camera based model or a ray based model
|
||||||
if True:
|
#TODO Zhuoyang: First made some dummy judgements, need to be fixed later
|
||||||
|
isGaussianSplattingModel = isinstance(self.viewer.get_model(), GaussianSplattingModel)
|
||||||
|
if isGaussianSplattingModel:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
camera_ray_bundle = camera.generate_rays(camera_indices=0, aabb_box=self.viewer.get_model().render_aabb)
|
camera_ray_bundle = camera.generate_rays(camera_indices=0, aabb_box=self.viewer.get_model().render_aabb)
|
||||||
@@ -147,13 +150,13 @@ class RenderStateMachine(threading.Thread):
|
|||||||
device=self.viewer.get_model().device,
|
device=self.viewer.get_model().device,
|
||||||
)
|
)
|
||||||
with background_color_override_context(background_color), torch.no_grad():
|
with background_color_override_context(background_color), torch.no_grad():
|
||||||
if True:
|
if isGaussianSplattingModel:
|
||||||
outputs = self.viewer.get_model().get_outputs_for_camera_ray_bundle(camera)
|
outputs = self.viewer.get_model().get_outputs_for_camera_ray_bundle(camera)
|
||||||
else:
|
else:
|
||||||
outputs = self.viewer.get_model().get_outputs_for_camera_ray_bundle(camera_ray_bundle)
|
outputs = self.viewer.get_model().get_outputs_for_camera_ray_bundle(camera_ray_bundle)
|
||||||
else:
|
else:
|
||||||
with torch.no_grad():
|
with torch.no_grad():
|
||||||
if True:
|
if isGaussianSplattingModel:
|
||||||
outputs = self.viewer.get_model().get_outputs_for_camera_ray_bundle(camera)
|
outputs = self.viewer.get_model().get_outputs_for_camera_ray_bundle(camera)
|
||||||
else:
|
else:
|
||||||
outputs = self.viewer.get_model().get_outputs_for_camera_ray_bundle(camera_ray_bundle)
|
outputs = self.viewer.get_model().get_outputs_for_camera_ray_bundle(camera_ray_bundle)
|
||||||
|
|||||||
Reference in new issue
Block a user