dcnum.segm.segm_torch ===================== .. py:module:: dcnum.segm.segm_torch Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/dcnum/segm/segm_torch/segm_torch_base/index /autoapi/dcnum/segm/segm_torch/segm_torch_mpo/index /autoapi/dcnum/segm/segm_torch/segm_torch_sto/index /autoapi/dcnum/segm/segm_torch/torch_model/index /autoapi/dcnum/segm/segm_torch/torch_postproc/index /autoapi/dcnum/segm/segm_torch/torch_preproc/index /autoapi/dcnum/segm/segm_torch/torch_setup/index Classes ------- .. autoapisummary:: dcnum.segm.segm_torch.SegmentTorchMPO dcnum.segm.segm_torch.SegmentTorchSTO Package Contents ---------------- .. py:class:: SegmentTorchMPO(*, kwargs_mask: dict | None = None, debug: bool = False, **kwargs) Bases: :py:obj:`dcnum.segm.segm_torch.segm_torch_base.TorchSegmenterBase`, :py:obj:`dcnum.segm.segmenter_mpo.MPOSegmenter` Base segmenter class This is the base segmenter class for the multiprocessing operation segmenter :class:`.segmenter_mpo.MPOSegmenter` (multiple subprocesses are spawned and each of them works on a queue of images) and the single-threaded operation segmenter :class:`.segmenter_sto.STOSegmenter` (e.g. for batch segmentation on a GPU). :param kwargs_mask: Keyword arguments for mask post-processing (see `process_labels`) :type kwargs_mask: dict :param debug: Enable debugging mode (e.g. CPU segmenter runs in one thread) :type debug: bool :param kwargs: Additional, optional keyword arguments for `segment_batch`. .. py:method:: segment_algorithm(image, *, model_file: str | None = None) :staticmethod: :param image: event image :type image: 2d ndarray :param model_file: path to or name of a dcnum model file (.dcnm); if only a name is provided, then the "torch_model_files" directory paths are searched for the file name :type model_file: str :returns: **mask** -- mask or labeling image for the give index :rtype: 2d boolean or integer ndarray .. py:class:: SegmentTorchSTO(*, kwargs_mask: dict | None = None, debug: bool = False, **kwargs) Bases: :py:obj:`dcnum.segm.segm_torch.segm_torch_base.TorchSegmenterBase`, :py:obj:`dcnum.segm.STOSegmenter` Base segmenter class This is the base segmenter class for the multiprocessing operation segmenter :class:`.segmenter_mpo.MPOSegmenter` (multiple subprocesses are spawned and each of them works on a queue of images) and the single-threaded operation segmenter :class:`.segmenter_sto.STOSegmenter` (e.g. for batch segmentation on a GPU). :param kwargs_mask: Keyword arguments for mask post-processing (see `process_labels`) :type kwargs_mask: dict :param debug: Enable debugging mode (e.g. CPU segmenter runs in one thread) :type debug: bool :param kwargs: Additional, optional keyword arguments for `segment_batch`. .. py:method:: log_info(logger, gpu_id=None) Allow segmenter to write informative log messages .. py:method:: is_available() :staticmethod: Subclasses may override this method e.g. if dependencies exist .. py:method:: _segment_in_batches(images, model, model_meta, device) :staticmethod: Segment image data in batches Return mask array with same shape as `images`. .. py:method:: segment_algorithm(images, gpu_id: str | None = None, *, model_file: str | None = None) :staticmethod: :param images: array of N event images of shape (N, H, W) :type images: 3d ndarray :param gpu_id: optional argument specifying the GPU to use :type gpu_id: str :param model_file: path to or name of a dcnum model file (.dcnm); if only a name is provided, then the "torch_model_files" directory paths are searched for the file name :type model_file: str :returns: **mask** -- mask images of shape (N, H, W) :rtype: 2d boolean or integer ndarray