Skip to content

Commit 5c1ca75

Browse files
bottlerfacebook-github-bot
authored andcommitted
srn/idr followups
Summary: small followup to D37172537 (cba2650) and D37209012 (81d63c6): changing default #harmonics and improving a test Reviewed By: shapovalov Differential Revision: D37412357 fbshipit-source-id: 1af1005a129425fd24fa6dd213d69c71632099a0
1 parent 3e4fb0b commit 5c1ca75

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

projects/implicitron_trainer/tests/experiment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ generic_model_args:
201201
bias: 1.0
202202
skip_in: []
203203
weight_norm: true
204-
n_harmonic_functions_xyz: -1
204+
n_harmonic_functions_xyz: 0
205205
pooled_feature_dim: 0
206206
encoding_dim: 0
207207
implicit_function_NeRFormerImplicitFunction_args:

pytorch3d/implicitron/models/implicit_function/idr_feature_field.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class IdrFeatureField(ImplicitFunctionBase, torch.nn.Module):
5858
bias: float = 1.0
5959
skip_in: Sequence[int] = ()
6060
weight_norm: bool = True
61-
n_harmonic_functions_xyz: int = -1
61+
n_harmonic_functions_xyz: int = 0
6262
pooled_feature_dim: int = 0
6363
encoding_dim: int = 0
6464

tests/implicitron/test_srn.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def test_srn_hypernet_implicit_function(self):
6969
)
7070
self.assertIsNone(rays_colors)
7171

72+
@torch.no_grad()
7273
def test_lstm(self):
7374
args = get_default_args(GenericModel)
7475
args.render_image_height = 80
@@ -80,12 +81,31 @@ def test_lstm(self):
8081
args.raysampler_NearFarRaySampler_args.n_pts_per_ray_evaluation = 1
8182
args.renderer_LSTMRenderer_args.bg_color = [0.4, 0.4, 0.2]
8283
gm = GenericModel(**args)
84+
8385
camera = PerspectiveCameras()
84-
gm.forward(
86+
image = gm.forward(
8587
camera=camera,
8688
image_rgb=None,
8789
fg_probability=None,
8890
sequence_name="",
8991
mask_crop=None,
9092
depth_map=None,
91-
)
93+
)["images_render"]
94+
self.assertEqual(image.shape, (1, 3, 80, 80))
95+
self.assertGreater(image.max(), 0.8)
96+
97+
# Force everything to be background
98+
pixel_generator = gm._implicit_functions[0]._fn.pixel_generator
99+
pixel_generator._density_layer.weight.zero_()
100+
pixel_generator._density_layer.bias.fill_(-1.0e6)
101+
102+
image = gm.forward(
103+
camera=camera,
104+
image_rgb=None,
105+
fg_probability=None,
106+
sequence_name="",
107+
mask_crop=None,
108+
depth_map=None,
109+
)["images_render"]
110+
self.assertConstant(image[:, :2], 0.4)
111+
self.assertConstant(image[:, 2], 0.2)

0 commit comments

Comments
 (0)