def area(masks):
  """Computes area of masks.

  Args:
    masks: Numpy array with shape [N, height, width] holding N masks. Masks
      values are of type np.uint8 and values are in {0,1}.

  Returns:
    a numpy array with shape [N*1] representing mask areas.

  Raises:
    ValueError: If masks.dtype is not np.uint8
  """
  if masks.dtype != np.uint8:
    raise ValueError('Masks type should be np.uint8')
  return np.sum(masks, axis=(1, 2), dtype=np.float32)
Computes area of masks.

  Args:
    masks: Numpy array with shape [N, height, width] holding N masks. Masks
      values are of type np.uint8 and values are in {0,1}.

  Returns:
    a numpy array with shape [N*1] representing mask areas.

  Raises:
    ValueError: If masks.dtype is not np.uint8
  
inference_api/src/main/object_detection/utils/np_mask_ops.py