mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-08-02 03:42:50 +08:00
replicate_last_interval in raymarcher
Summary: Add option to flat pad the last delta. Might to help when training on rgb only. Reviewed By: shapovalov Differential Revision: D40587475 fbshipit-source-id: c763fa38948600ea532c730538dc4ff29d2c3e0a
This commit is contained in:
parent
ff933ab82b
commit
611aba9a20
@ -235,6 +235,7 @@ model_factory_ImplicitronModelFactory_args:
|
|||||||
surface_thickness: 1
|
surface_thickness: 1
|
||||||
bg_color:
|
bg_color:
|
||||||
- 0.0
|
- 0.0
|
||||||
|
replicate_last_interval: False
|
||||||
background_opacity: 0.0
|
background_opacity: 0.0
|
||||||
density_relu: true
|
density_relu: true
|
||||||
blend_output: false
|
blend_output: false
|
||||||
@ -242,6 +243,7 @@ model_factory_ImplicitronModelFactory_args:
|
|||||||
surface_thickness: 1
|
surface_thickness: 1
|
||||||
bg_color:
|
bg_color:
|
||||||
- 0.0
|
- 0.0
|
||||||
|
replicate_last_interval: False
|
||||||
background_opacity: 10000000000.0
|
background_opacity: 10000000000.0
|
||||||
density_relu: true
|
density_relu: true
|
||||||
blend_output: false
|
blend_output: false
|
||||||
|
@ -55,8 +55,11 @@ class AccumulativeRaymarcherBase(RaymarcherBase, torch.nn.Module):
|
|||||||
surface_thickness: The thickness of the raymarched surface.
|
surface_thickness: The thickness of the raymarched surface.
|
||||||
bg_color: The background color. A tuple of either 1 element or of D elements,
|
bg_color: The background color. A tuple of either 1 element or of D elements,
|
||||||
where D matches the feature dimensionality; it is broadcast when necessary.
|
where D matches the feature dimensionality; it is broadcast when necessary.
|
||||||
background_opacity: The raw opacity value (i.e. before exponentiation)
|
replicate_last_interval: If True, the ray length assigned to the last interval
|
||||||
of the background.
|
for the opacity delta calculation is copied from the penultimate interval.
|
||||||
|
background_opacity: The length over which the last raw opacity value
|
||||||
|
(i.e. before exponentiation) is considered to apply, for the delta
|
||||||
|
calculation. Ignored if replicate_last_interval=True.
|
||||||
density_relu: If `True`, passes the input density through ReLU before
|
density_relu: If `True`, passes the input density through ReLU before
|
||||||
raymarching.
|
raymarching.
|
||||||
blend_output: If `True`, alpha-blends the output renders with the
|
blend_output: If `True`, alpha-blends the output renders with the
|
||||||
@ -76,6 +79,7 @@ class AccumulativeRaymarcherBase(RaymarcherBase, torch.nn.Module):
|
|||||||
|
|
||||||
surface_thickness: int = 1
|
surface_thickness: int = 1
|
||||||
bg_color: Tuple[float, ...] = (0.0,)
|
bg_color: Tuple[float, ...] = (0.0,)
|
||||||
|
replicate_last_interval: bool = False
|
||||||
background_opacity: float = 0.0
|
background_opacity: float = 0.0
|
||||||
density_relu: bool = True
|
density_relu: bool = True
|
||||||
blend_output: bool = False
|
blend_output: bool = False
|
||||||
@ -151,13 +155,14 @@ class AccumulativeRaymarcherBase(RaymarcherBase, torch.nn.Module):
|
|||||||
density_1d=True,
|
density_1d=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
deltas = torch.cat(
|
ray_lengths_diffs = ray_lengths[..., 1:] - ray_lengths[..., :-1]
|
||||||
(
|
if self.replicate_last_interval:
|
||||||
ray_lengths[..., 1:] - ray_lengths[..., :-1],
|
last_interval = ray_lengths_diffs[..., -1:]
|
||||||
self.background_opacity * torch.ones_like(ray_lengths[..., :1]),
|
else:
|
||||||
),
|
last_interval = torch.full_like(
|
||||||
dim=-1,
|
ray_lengths[..., :1], self.background_opacity
|
||||||
)
|
)
|
||||||
|
deltas = torch.cat((ray_lengths_diffs, last_interval), dim=-1)
|
||||||
|
|
||||||
rays_densities = rays_densities[..., 0]
|
rays_densities = rays_densities[..., 0]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user