Skip to content

Commit a607dd0

Browse files
bottlerfacebook-github-bot
authored andcommitted
better implicit function #channels errors
Summary: More helpful errors when the output channels aren't 1 for density and 3 for color Reviewed By: shapovalov Differential Revision: D40341088 fbshipit-source-id: 6074bf7fefe11c8e60fee4db2760b776419bcfee
1 parent 17bc043 commit a607dd0

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

pytorch3d/implicitron/models/metrics.py

+5
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,11 @@ def sample(tensor, mode):
362362

363363
def _rgb_metrics(images, images_pred, masks, masks_pred, masks_crop):
364364
assert masks_crop is not None
365+
if images.shape[1] != images_pred.shape[1]:
366+
raise ValueError(
367+
f"Network output's RGB images had {images_pred.shape[1]} "
368+
f"channels. {images.shape[1]} expected."
369+
)
365370
rgb_squared = ((images_pred - images) ** 2).mean(dim=1, keepdim=True)
366371
rgb_loss = utils.huber(rgb_squared, scaling=0.03)
367372
crop_mass = masks_crop.sum().clamp(1.0)

pytorch3d/renderer/implicit/raymarching.py

+1
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ def _check_raymarcher_inputs(
215215
if density_1d and rays_densities.shape[-1] != 1:
216216
raise ValueError(
217217
"The size of the last dimension of rays_densities has to be one."
218+
+ f" Got shape {rays_densities.shape}."
218219
)
219220

220221
rays_shape = rays_densities.shape[:-1]

0 commit comments

Comments
 (0)