mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-01 21:39:06 +08:00
RGBA renderer for splatfacto (#3307)
* Update base_model.py * Update render.py * Update render.py * fixing error * Update render.py * Update render.py
This commit is contained in:
1 parent
f86dbe6d45
commit
d67b281f7d
2 files changed
+11
-6
No files matched your search
@@ -214,11 +214,7 @@ class Model(nn.Module):
|
|||||||
RGBA image.
|
RGBA image.
|
||||||
"""
|
"""
|
||||||
accumulation_name = output_name.replace("rgb", "accumulation")
|
accumulation_name = output_name.replace("rgb", "accumulation")
|
||||||
if (
|
if accumulation_name not in outputs:
|
||||||
not hasattr(self, "renderer_rgb")
|
|
||||||
or not hasattr(self.renderer_rgb, "background_color")
|
|
||||||
or accumulation_name not in outputs
|
|
||||||
):
|
|
||||||
raise NotImplementedError(f"get_rgba_image is not implemented for model {self.__class__.__name__}")
|
raise NotImplementedError(f"get_rgba_image is not implemented for model {self.__class__.__name__}")
|
||||||
rgb = outputs[output_name]
|
rgb = outputs[output_name]
|
||||||
if self.renderer_rgb.background_color == "random": # type: ignore
|
if self.renderer_rgb.background_color == "random": # type: ignore
|
||||||
|
|||||||
@@ -197,6 +197,9 @@ def _render_trajectory_video(
|
|||||||
outputs = pipeline.model.get_outputs_for_camera(
|
outputs = pipeline.model.get_outputs_for_camera(
|
||||||
cameras[camera_idx : camera_idx + 1], obb_box=obb_box
|
cameras[camera_idx : camera_idx + 1], obb_box=obb_box
|
||||||
)
|
)
|
||||||
|
if rendered_output_names is not None and "rgba" in rendered_output_names:
|
||||||
|
rgba = pipeline.model.get_rgba_image(outputs=outputs, output_name="rgb")
|
||||||
|
outputs["rgba"] = rgba
|
||||||
|
|
||||||
render_image = []
|
render_image = []
|
||||||
for rendered_output_name in rendered_output_names:
|
for rendered_output_name in rendered_output_names:
|
||||||
@@ -221,6 +224,8 @@ def _render_trajectory_video(
|
|||||||
.cpu()
|
.cpu()
|
||||||
.numpy()
|
.numpy()
|
||||||
)
|
)
|
||||||
|
elif rendered_output_name == "rgba":
|
||||||
|
output_image = output_image.detach().cpu().numpy()
|
||||||
else:
|
else:
|
||||||
output_image = (
|
output_image = (
|
||||||
colormaps.apply_colormap(
|
colormaps.apply_colormap(
|
||||||
@@ -790,6 +795,9 @@ class DatasetRender(BaseRender):
|
|||||||
for camera_idx, (camera, batch) in enumerate(progress.track(dataloader, total=len(dataset))):
|
for camera_idx, (camera, batch) in enumerate(progress.track(dataloader, total=len(dataset))):
|
||||||
with torch.no_grad():
|
with torch.no_grad():
|
||||||
outputs = pipeline.model.get_outputs_for_camera(camera)
|
outputs = pipeline.model.get_outputs_for_camera(camera)
|
||||||
|
if self.rendered_output_names is not None and "rgba" in self.rendered_output_names:
|
||||||
|
rgba = pipeline.model.get_rgba_image(outputs=outputs, output_name="rgb")
|
||||||
|
outputs["rgba"] = rgba
|
||||||
|
|
||||||
gt_batch = batch.copy()
|
gt_batch = batch.copy()
|
||||||
gt_batch["rgb"] = gt_batch.pop("image")
|
gt_batch["rgb"] = gt_batch.pop("image")
|
||||||
@@ -841,11 +849,12 @@ class DatasetRender(BaseRender):
|
|||||||
output_image = gt_batch[output_name]
|
output_image = gt_batch[output_name]
|
||||||
else:
|
else:
|
||||||
output_image = outputs[output_name]
|
output_image = outputs[output_name]
|
||||||
del output_name
|
|
||||||
|
|
||||||
# Map to color spaces / numpy
|
# Map to color spaces / numpy
|
||||||
if is_raw:
|
if is_raw:
|
||||||
output_image = output_image.cpu().numpy()
|
output_image = output_image.cpu().numpy()
|
||||||
|
elif output_name == "rgba":
|
||||||
|
output_image = output_image.detach().cpu().numpy()
|
||||||
elif is_depth:
|
elif is_depth:
|
||||||
output_image = (
|
output_image = (
|
||||||
colormaps.apply_depth_colormap(
|
colormaps.apply_depth_colormap(
|
||||||
|
|||||||
Reference in new issue
Block a user