dcnum.segm.segm_torch.torch_postproc ==================================== .. py:module:: dcnum.segm.segm_torch.torch_postproc Attributes ---------- .. autoapisummary:: dcnum.segm.segm_torch.torch_postproc.ndi Functions --------- .. autoapisummary:: dcnum.segm.segm_torch.torch_postproc.postprocess_masks Module Contents --------------- .. py:data:: ndi .. py:function:: postprocess_masks(masks, original_image_shape: tuple[int, int]) Postprocess mask images from ML segmenters The transformation includes: - Revert the cropping and padding operations done in :func:`.preprocess_images` by padding with zeros and cropping. - If the original image shape is larger than the mask image shape, also clear borders in an intermediate step (maks postprocessing using :func:`Segmenter.process_labels`). :param masks: Mask data in shape (batch_size, 1, imagex_size, imagey_size) or (batch_size, imagex_size, imagey_size). :type masks: 3d or 4d ndarray :param original_image_shape: The required output mask shape for one event. This required for doing the inverse of what is done in :func:`.preprocess_images`. :type original_image_shape: tuple of (int, int) :returns: **labels_proc** -- An integer array with the same dimensions as the original image data passed to :func:`.preprocess_images`. The shape of this array is (batch_size, original_image_shape[0], original_image_shape[1]). :rtype: np.ndarray .. rubric:: Notes This method is only called by the overarching logic when the preprocessing/model output produces images of different shape. It causes an obvious overhead that we want to avoid.