Class ImageConverter

java.lang.Object
org.tribuo.interop.tensorflow.ImageConverter
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, FeatureConverter

public class ImageConverter extends Object implements FeatureConverter
Image converter. Assumes the feature id numbers are linearised ids of the form:
 [0,0,0] = 0, [0,0,1] = 1, [0,1,0] = k, [1,0,0] = j*k, ..., [i,0,0] = i*j*k,
 
That is, they are in multidimensional row major order (e.g. the order used by IDXDataSource).
See Also:
  • Constructor Details

    • ImageConverter

      public ImageConverter(String inputName, int width, int height, int channels)
      Builds an image converter for images of the supplied size.
      Parameters:
      inputName - The input name.
      width - The image width.
      height - The image height.
      channels - The number of colour channels.
  • 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
    • inputNamesSet

      public Set<String> inputNamesSet()
      Description copied from interface: FeatureConverter
      Gets a view of the names of the inputs this converter produces.
      Specified by:
      inputNamesSet in interface FeatureConverter
      Returns:
      The input names.
    • convert

      public TensorMap convert(Example<?> example, ImmutableFeatureMap featureIDMap)
      Transform implicitly pads unseen values with zero.
      Specified by:
      convert in interface FeatureConverter
      Parameters:
      example - The example to transform.
      featureIDMap - The feature id mapping to use.
      Returns:
      A 4d tensor, (1, width, height, channels) for this example.
    • convert

      public TensorMap convert(List<? extends Example<?>> examples, ImmutableFeatureMap featureIDMap)
      Transform implicitly pads unseen values with zero.

      Converts a batch of examples into a Tensor.

      Specified by:
      convert in interface FeatureConverter
      Parameters:
      examples - The examples to transform.
      featureIDMap - The feature id mapping to use.
      Returns:
      A 4d tensor, (batch-id, width, height, channels) for this example.
    • convert

      public TensorMap convert(SGDVector vector)
      Description copied from interface: FeatureConverter
      Converts a SGDVector representing the features into a TensorMap.

      It generates it as a single example minibatch.

      Specified by:
      convert in interface FeatureConverter
      Parameters:
      vector - The features to convert.
      Returns:
      A TensorMap (similar to a TF Python feed_dict) representing this vector.
    • convert

      public TensorMap convert(List<? extends SGDVector> vectors)
      Description copied from interface: FeatureConverter
      Converts a list of SGDVectors representing a batch of features into a TensorMap.
      Specified by:
      convert in interface FeatureConverter
      Parameters:
      vectors - The batch of features to convert.
      Returns:
      A TensorMap (similar to a TF Python feed_dict) representing this minibatch.
    • 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>