dcnum.segm.segm_torch.segm_torch_base

Classes

TorchSegmenterBase

Base segmenter class

Module Contents

class dcnum.segm.segm_torch.segm_torch_base.TorchSegmenterBase(*, kwargs_mask: dict | None = None, debug: bool = False, **kwargs)[source]

Bases: dcnum.segm.segmenter.Segmenter

Base segmenter class

This is the base segmenter class for the multiprocessing operation segmenter segmenter_mpo.MPOSegmenter (multiple subprocesses are spawned and each of them works on a queue of images) and the single-threaded operation segmenter segmenter_sto.STOSegmenter (e.g. for batch segmentation on a GPU).

Parameters:
  • kwargs_mask (dict) – Keyword arguments for mask post-processing (see process_labels)

  • debug (bool) – Enable debugging mode (e.g. CPU segmenter runs in one thread)

  • kwargs – Additional, optional keyword arguments for segment_batch.

requires_background_correction = False

Whether the segmenter requires a background-corrected image

mask_postprocessing = True

Whether to enable mask post-processing. If disabled, you should make sure that your mask is properly defined and cleaned or you have to call process_labels in your segment_algorithm implementation.

mask_default_kwargs

Default keyword arguments for mask post-processing. See process_labels for available options.

classmethod get_ppid_from_ppkw(kwargs, kwargs_mask=None)[source]

Return the pipeline ID from given keyword arguments

See also

get_ppid

Same method for class instances

classmethod validate_applicability(segmenter_kwargs: dict, meta: dict | None = None, logs: dict | None = None)[source]

Validate the applicability of this segmenter for a dataset

The applicability is defined by the metadata in the segmentation model.

Parameters:
  • segmenter_kwargs (dict) – Keyword arguments for the segmenter

  • meta (dict) –

    Dictionary of metadata from an hdf5_data.HDF5Data

    instance

  • logs (dict) – Dictionary of logs from an hdf5_data.HDF5Data instance

Returns:

applicable – True if the segmenter is applicable to the dataset

Return type:

bool

Raises:

SegmenterNotApplicable – If the segmenter is not applicable to the dataset

static _validate_applicability_item(item, data_dict, reasons_list)[source]

Populate reasons_list with invalid entries

Example data_dict:

{"type": "meta",
 "key": "setup:region",
 "allow-missing-key": False,
 "regexp": "^channel$",
 "regexp-negate": False,
 "reason": "only channel region supported",
 }
static is_available()[source]

Subclasses may override this method e.g. if dependencies exist