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
This commit is contained in:
Jeremy Reizenstein 2022-10-13 05:43:36 -07:00 committed by Facebook GitHub Bot
parent 17bc043a0c
commit a607dd063e
2 changed files with 6 additions and 0 deletions

View File

@ -362,6 +362,11 @@ class ViewMetrics(ViewMetricsBase):
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)

View File

@ -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]