Skip to content

Commit bea84a6

Browse files
davnov134facebook-github-bot
authored andcommitted
voxel_grid_if -> remove union type from the settings.
Summary: see title Reviewed By: shapovalov Differential Revision: D40803670 fbshipit-source-id: 211189167837af577d6502a698e2f3fb3aec3e30
1 parent f711c4b commit bea84a6

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

projects/implicitron_trainer/tests/experiment.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ model_factory_ImplicitronModelFactory_args:
420420
- 128
421421
- 128
422422
scaffold_empty_space_threshold: 0.001
423-
scaffold_occupancy_chunk_size: 'inf'
423+
scaffold_occupancy_chunk_size: -1
424424
scaffold_max_pool_kernel_size: 3
425425
scaffold_filter_points: true
426426
volume_cropping_epochs: []

pytorch3d/implicitron/models/implicit_function/voxel_grid_implicit_function.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ class VoxelGridImplicitFunction(ImplicitFunctionBase, torch.nn.Module):
126126
every voxel, this calculation can be split into scaffold depth number of xy plane
127127
calculations if you want the lowest memory usage, one calculation to calculate the
128128
whole scaffold, but with higher memory footprint or any other number of planes.
129-
Setting to 'inf' calculates all planes at the same time. Defaults to 'inf'.
129+
Setting to a non-positive number calculates all planes at the same time.
130+
Defaults to '-1' (=calculating all planes).
130131
scaffold_max_pool_kernel_size (int): Size of the pooling region to use when
131132
calculating the scaffold. Defaults to 3.
132133
scaffold_filter_points (bool): If set to True the points will be filtered using
@@ -173,7 +174,7 @@ class VoxelGridImplicitFunction(ImplicitFunctionBase, torch.nn.Module):
173174
scaffold_calculating_epochs: Tuple[int, ...] = ()
174175
scaffold_resolution: Tuple[int, int, int] = (128, 128, 128)
175176
scaffold_empty_space_threshold: float = 0.001
176-
scaffold_occupancy_chunk_size: Union[str, int] = "inf"
177+
scaffold_occupancy_chunk_size: int = -1
177178
scaffold_max_pool_kernel_size: int = 3
178179
scaffold_filter_points: bool = True
179180

@@ -199,11 +200,6 @@ def __post_init__(self) -> None:
199200
)
200201
# pyre-ignore[16]
201202
self._scaffold_ready = False
202-
if type(self.scaffold_occupancy_chunk_size) != int:
203-
if self.scaffold_occupancy_chunk_size != "inf":
204-
raise ValueError(
205-
"`scaffold_occupancy_chunk_size` has to be int or 'inf'."
206-
)
207203

208204
def forward(
209205
self,
@@ -504,7 +500,7 @@ def _get_scaffold(self, epoch: int) -> bool:
504500

505501
chunk_size = (
506502
self.scaffold_occupancy_chunk_size
507-
if type(self.scaffold_occupancy_chunk_size) == int
503+
if self.scaffold_occupancy_chunk_size > 0
508504
else points.shape[-1]
509505
)
510506
for k in range(0, points.shape[-1], chunk_size):

0 commit comments

Comments
 (0)