Class SegmentObjectsFromONNXModel

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<org.anchoranalysis.image.inference.bean.segment.instance.SegmentStackIntoObjectsPooled<T>>
org.anchoranalysis.image.inference.bean.segment.instance.SegmentStackIntoObjectsPooled<S>
org.anchoranalysis.image.inference.bean.segment.instance.SegmentStackIntoObjectsScaleDecode<ai.onnxruntime.OnnxTensor,​OnnxModel>
org.anchoranalysis.plugin.onnx.bean.object.segment.stack.SegmentObjectsFromONNXModel

public class SegmentObjectsFromONNXModel
extends org.anchoranalysis.image.inference.bean.segment.instance.SegmentStackIntoObjectsScaleDecode<ai.onnxruntime.OnnxTensor,​OnnxModel>
Performs instance-segmentation using the ONNX Runtime and an .onnx model file.
Author:
Owen Feehan
  • Constructor Summary

    Constructors 
    Constructor Description
    SegmentObjectsFromONNXModel()  
  • Method Summary

    Modifier and Type Method Description
    org.anchoranalysis.inference.concurrency.ConcurrentModelPool<OnnxModel> createModelPool​(org.anchoranalysis.inference.concurrency.ConcurrencyPlan plan, org.anchoranalysis.core.log.Logger logger)  
    protected ai.onnxruntime.OnnxTensor deriveInput​(org.anchoranalysis.image.core.stack.Stack stack, Optional<double[]> subtractMeans)  
    String getInputName()
    The name of the input in the ONNX model.
    String getModelPath()
    Relative-path to the model file in ONNX form, relative to the models/ directory in the Anchor distribution.
    protected Optional<String> inputName()  
    boolean isIncludeBatchDimension()
    If true, a 4-dimensional tensor is created (with the first dimension describing a batch-size of 1), instead of the usual 3-dimensional tensor describing channel, height, width.
    boolean isInterleaveChannels()
    If true, the channels are placed as the final position of the tensor (**after** width/height) instead of **before** width/height.
    boolean isReadFromResources()
    When true, rather than reading modelPath from the file-system, it is read from Java resources on the class-path.
    void setIncludeBatchDimension​(boolean includeBatchDimension)
    If true, a 4-dimensional tensor is created (with the first dimension describing a batch-size of 1), instead of the usual 3-dimensional tensor describing channel, height, width.
    void setInputName​(String inputName)
    The name of the input in the ONNX model.
    void setInterleaveChannels​(boolean interleaveChannels)
    If true, the channels are placed as the final position of the tensor (**after** width/height) instead of **before** width/height.
    void setModelPath​(String modelPath)
    Relative-path to the model file in ONNX form, relative to the models/ directory in the Anchor distribution.
    void setReadFromResources​(boolean readFromResources)
    When true, rather than reading modelPath from the file-system, it is read from Java resources on the class-path.

    Methods inherited from class org.anchoranalysis.image.inference.bean.segment.instance.SegmentStackIntoObjectsScaleDecode

    getClassLabelsPath, getDecode, getDisplayer, getInterpolator, getScaleInput, getSubtractMean, segment, setClassLabelsPath, setDecode, setDisplayer, setInterpolator, setScaleInput, setSubtractMean

    Methods inherited from class org.anchoranalysis.image.inference.bean.segment.instance.SegmentStackIntoObjectsPooled

    resolve, segment

    Methods inherited from class org.anchoranalysis.bean.initializable.InitializableBean

    getInitialization, getLogger, getPropertyInitializer, initialize, initializeRecursive, initRecursiveWithInitializer, isInitialized, onInitialization

    Methods inherited from class org.anchoranalysis.bean.AnchorBean

    checkMisconfigured, describeBean, describeChildren, duplicateBean, fields, findFieldsOfClass, getBeanName, getLocalPath, localise, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

  • Method Details

    • createModelPool

      public org.anchoranalysis.inference.concurrency.ConcurrentModelPool<OnnxModel> createModelPool​(org.anchoranalysis.inference.concurrency.ConcurrencyPlan plan, org.anchoranalysis.core.log.Logger logger) throws org.anchoranalysis.inference.concurrency.CreateModelFailedException
      Specified by:
      createModelPool in class org.anchoranalysis.image.inference.bean.segment.instance.SegmentStackIntoObjectsPooled<OnnxModel>
      Throws:
      org.anchoranalysis.inference.concurrency.CreateModelFailedException
    • deriveInput

      protected ai.onnxruntime.OnnxTensor deriveInput​(org.anchoranalysis.image.core.stack.Stack stack, Optional<double[]> subtractMeans) throws org.anchoranalysis.core.exception.OperationFailedException
      Specified by:
      deriveInput in class org.anchoranalysis.image.inference.bean.segment.instance.SegmentStackIntoObjectsScaleDecode<ai.onnxruntime.OnnxTensor,​OnnxModel>
      Throws:
      org.anchoranalysis.core.exception.OperationFailedException
    • inputName

      protected Optional<String> inputName()
      Specified by:
      inputName in class org.anchoranalysis.image.inference.bean.segment.instance.SegmentStackIntoObjectsScaleDecode<ai.onnxruntime.OnnxTensor,​OnnxModel>
    • getModelPath

      public String getModelPath()
      Relative-path to the model file in ONNX form, relative to the models/ directory in the Anchor distribution.

      If readFromResources==true, it is read instead from resources on the class-path.

    • setModelPath

      public void setModelPath​(String modelPath)
      Relative-path to the model file in ONNX form, relative to the models/ directory in the Anchor distribution.

      If readFromResources==true, it is read instead from resources on the class-path.

    • isReadFromResources

      public boolean isReadFromResources()
      When true, rather than reading modelPath from the file-system, it is read from Java resources on the class-path.
    • setReadFromResources

      public void setReadFromResources​(boolean readFromResources)
      When true, rather than reading modelPath from the file-system, it is read from Java resources on the class-path.
    • getInputName

      public String getInputName()
      The name of the input in the ONNX model.
    • setInputName

      public void setInputName​(String inputName)
      The name of the input in the ONNX model.
    • isIncludeBatchDimension

      public boolean isIncludeBatchDimension()
      If true, a 4-dimensional tensor is created (with the first dimension describing a batch-size of 1), instead of the usual 3-dimensional tensor describing channel, height, width.
    • setIncludeBatchDimension

      public void setIncludeBatchDimension​(boolean includeBatchDimension)
      If true, a 4-dimensional tensor is created (with the first dimension describing a batch-size of 1), instead of the usual 3-dimensional tensor describing channel, height, width.
    • isInterleaveChannels

      public boolean isInterleaveChannels()
      If true, the channels are placed as the final position of the tensor (**after** width/height) instead of **before** width/height.

      Consequently, in terms of raw order in a FloatBuffer, RGB values become interleaved.

    • setInterleaveChannels

      public void setInterleaveChannels​(boolean interleaveChannels)
      If true, the channels are placed as the final position of the tensor (**after** width/height) instead of **before** width/height.

      Consequently, in terms of raw order in a FloatBuffer, RGB values become interleaved.