kaolin.metrics.voxel

iou(pred, gt, thresh=0.5, reduction='mean')[source]

Computes IoU across two voxel grids

Parameters
  • pred (torch.Tensor) – predicted (binary) voxel grid

  • gt (torch.Tensor) – ground-truth (binary) voxel grid

  • thresh (float) – value to threshold the prediction with

Returns

the intersection over union value

Return type

iou (torch.Tensor)

Example

>>> pred = torch.rand(32, 32, 32)
>>> gt = torch.rand(32, 32, 32) *2. // 1
>>> loss = iou(pred, gt)
>>> loss
tensor(0.3338)