Class SegmentStackIntoObjectsPooled<T extends InferenceModel>

Object
org.anchoranalysis.bean.AnchorBean<B>
org.anchoranalysis.bean.initializable.InitializableBean<T,​org.anchoranalysis.image.bean.nonbean.init.ImageInitialization>
org.anchoranalysis.image.bean.ImageBean<T>
org.anchoranalysis.image.bean.segment.SegmentationBean<SegmentStackIntoObjectsPooled<T>>
org.anchoranalysis.image.inference.bean.segment.instance.SegmentStackIntoObjectsPooled<T>
Type Parameters:
T - model-type
Direct Known Subclasses:
SegmentStackIntoObjectsScaleDecode, SuppressNonMaximum

public abstract class SegmentStackIntoObjectsPooled<T extends InferenceModel>
extends org.anchoranalysis.image.bean.segment.SegmentationBean<SegmentStackIntoObjectsPooled<T>>
A base class for algorithms to segment a stack into one or more objects - using a pool of models

These models are typically CNN deep-learning models.

Author:
Owen Feehan
  • Constructor Details

  • Method Details

    • segment

      public SegmentedObjects segment​(Stack stack, ExecutionTimeRecorder executionTimeRecorder) throws org.anchoranalysis.image.bean.nonbean.segment.SegmentationFailedException
      Segments individually using a pool of size 1 just for one stack.

      See segment(Stack, ConcurrentModelPool, ExecutionTimeRecorder) for more details.

      Parameters:
      stack - the stack to segment.
      executionTimeRecorder - for measuring execution-times of operations.
      Returns:
      a collection of objects with corresponding confidence scores.
      Throws:
      org.anchoranalysis.image.bean.nonbean.segment.SegmentationFailedException - if anything goes wrong during the segmentation.
    • createModelPool

      public abstract ConcurrentModelPool<T> createModelPool​(ConcurrencyPlan plan, Logger logger) throws CreateModelFailedException
      Creates the model pool (to be used by multiple threads).
      Parameters:
      plan - the number and types of processors available for concurrent execution.
      logger - the logger.
      Returns:
      the newly created model pool.
      Throws:
      CreateModelFailedException - if a model cannot be created.
    • segment

      public abstract SegmentedObjects segment​(Stack stack, ConcurrentModelPool<T> modelPool, ExecutionTimeRecorder executionTimeRecorder) throws org.anchoranalysis.image.bean.nonbean.segment.SegmentationFailedException
      Segments a stack to produce an object-collection.

      Any created objects will always exist inside the stack's Extent.

      Parameters:
      stack - the stack to segment.
      modelPool - the pool of model instances which can each be used for inference (in parallel).
      executionTimeRecorder - measures execution-times of particular operations.
      Returns:
      a collection of objects with corresponding confidence scores.
      Throws:
      org.anchoranalysis.image.bean.nonbean.segment.SegmentationFailedException - if anything goes wrong during the segmentation.
    • resolve

      protected Path resolve​(String modelFilename) throws InitializeException
      Resolves a relative filename for a model into a path, relative to the model directory.
      Parameters:
      modelFilename - the filename for the model (to the model directory).
      Returns:
      an absolute path to the model.
      Throws:
      InitializeException - if a bean requires initialization, but has not been initialized.