Skip to content

Commit

Permalink
better implicit function #channels errors
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bottler authored and facebook-github-bot committed Oct 13, 2022
1 parent 17bc043 commit a607dd0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pytorch3d/implicitron/models/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,11 @@ def sample(tensor, mode):

def _rgb_metrics(images, images_pred, masks, masks_pred, masks_crop):
assert masks_crop is not None
if images.shape[1] != images_pred.shape[1]:
raise ValueError(
f"Network output's RGB images had {images_pred.shape[1]} "
f"channels. {images.shape[1]} expected."
)
rgb_squared = ((images_pred - images) ** 2).mean(dim=1, keepdim=True)
rgb_loss = utils.huber(rgb_squared, scaling=0.03)
crop_mass = masks_crop.sum().clamp(1.0)
Expand Down
1 change: 1 addition & 0 deletions pytorch3d/renderer/implicit/raymarching.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def _check_raymarcher_inputs(
if density_1d and rays_densities.shape[-1] != 1:
raise ValueError(
"The size of the last dimension of rays_densities has to be one."
+ f" Got shape {rays_densities.shape}."
)

rays_shape = rays_densities.shape[:-1]
Expand Down

0 comments on commit a607dd0

Please sign in to comment.