Class ImageTransformer

java.lang.Object
org.tribuo.interop.onnx.ImageTransformer
All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable, com.oracle.labs.mlrg.olcut.provenance.Provenancable<com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance>, Serializable, ExampleTransformer

public class ImageTransformer extends Object implements ExampleTransformer
Image transformer. Assumes the feature id numbers are linearised ids of the form [0,0,0] = 0, [1,0,0] = 1, ..., [i,0,0] = i, [0,1,0] = i+1, ..., [i,j,0] = i*j, ... [0,0,1] = (i*j)+1, ..., [i,j,k] = i*j*k.

ONNX expects images in the format [channels,height,width].

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    ImageTransformer(int channels, int height, int width)
    Constructs an image transformer with the specified parameters.
  • Method Summary

    Modifier and Type
    Method
    Description
    com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance
     
    void
    Used by the OLCUT configuration system, and should not be called by external code.
     
    ai.onnxruntime.OnnxTensor
    transform(ai.onnxruntime.OrtEnvironment env, List<SparseVector> vectors)
    Converts a list of SparseVectors representing a batch of features into a OnnxTensor.
    ai.onnxruntime.OnnxTensor
    transform(ai.onnxruntime.OrtEnvironment env, SparseVector vector)
    Converts a SparseVector representing the features into a OnnxTensor.

    Methods inherited from class java.lang.Object

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

    • ImageTransformer

      public ImageTransformer(int channels, int height, int width)
      Constructs an image transformer with the specified parameters.
      Parameters:
      channels - The number of colour channels.
      height - The height.
      width - The width.
  • Method Details

    • postConfig

      public void postConfig()
      Used by the OLCUT configuration system, and should not be called by external code.
      Specified by:
      postConfig in interface com.oracle.labs.mlrg.olcut.config.Configurable
    • transform

      public ai.onnxruntime.OnnxTensor transform(ai.onnxruntime.OrtEnvironment env, SparseVector vector) throws ai.onnxruntime.OrtException
      Description copied from interface: ExampleTransformer
      Converts a SparseVector representing the features into a OnnxTensor.

      It generates it as a single example minibatch.

      Specified by:
      transform in interface ExampleTransformer
      Parameters:
      env - The OrtEnvironment to create the tensor in.
      vector - The features to convert.
      Returns:
      A dense OnnxTensor representing this vector.
      Throws:
      ai.onnxruntime.OrtException - if the transformation failed.
    • transform

      public ai.onnxruntime.OnnxTensor transform(ai.onnxruntime.OrtEnvironment env, List<SparseVector> vectors) throws ai.onnxruntime.OrtException
      Description copied from interface: ExampleTransformer
      Converts a list of SparseVectors representing a batch of features into a OnnxTensor.
      Specified by:
      transform in interface ExampleTransformer
      Parameters:
      env - The OrtEnvironment to create the tensor in.
      vectors - The batch of features to convert.
      Returns:
      A dense OnnxTensor representing this minibatch.
      Throws:
      ai.onnxruntime.OrtException - if the transformation failed.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getProvenance

      public com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance getProvenance()
      Specified by:
      getProvenance in interface com.oracle.labs.mlrg.olcut.provenance.Provenancable<com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance>