Class Pipeline

java.lang.Object
ai.djl.translate.Pipeline

public class Pipeline extends Object
Pipeline allows applying multiple transforms on an input NDList.
  • Constructor Details

    • Pipeline

      public Pipeline()
      Creates a new instance of Pipeline that has no Transform defined yet.
    • Pipeline

      public Pipeline(Transform... transforms)
      Creates a new instance of Pipeline that can apply the given transforms on its input.

      Since no keys are provided for these transforms, they will be applied to the first element in the input NDList when the transform method is called on this object.

      Parameters:
      transforms - the transforms to be applied when the transform method is called on this object
  • Method Details

    • add

      public Pipeline add(Transform transform)
      Adds the given Transform to the list of transforms to be applied on the input when the transform method is called on this object.

      Since no keys are provided for this Transform, it will be applied to the first element in the input NDList.

      Parameters:
      transform - the Transform to be added
      Returns:
      this Pipeline
    • add

      public Pipeline add(int index, Transform transform)
      Adds the given Transform to the list of transforms to be applied on the NDArray at the given index in the input NDList.
      Parameters:
      index - the index corresponding to the NDArray in the input NDList on which the given transform must be applied to
      transform - the Transform to be added
      Returns:
      this Pipeline
    • add

      public Pipeline add(String name, Transform transform)
      Adds the given Transform to the list of transforms to be applied on the NDArray with the given key as name in the input NDList.
      Parameters:
      name - the key corresponding to the NDArray in the input NDList on which the given transform must be applied to
      transform - the Transform to be applied when the transform method is called on this object
      Returns:
      this Pipeline
    • insert

      public Pipeline insert(int position, Transform transform)
      Inserts the given Transform to the list of transforms at the given position.

      Since no keys or indices are provided for this Transform, it will be applied to the first element in the input NDList when the transform method is called on this object.

      Parameters:
      position - the position at which the Transform must be inserted
      transform - the Transform to be inserted
      Returns:
      this Pipeline
    • insert

      public Pipeline insert(int position, int index, Transform transform)
      Inserts the given Transform to the list of transforms at the given position to be applied on the NDArray at the given index in the input NDList.
      Parameters:
      position - the position at which the Transform must be inserted
      index - the index corresponding to the NDArray in the input NDList on which the given transform must be applied to
      transform - the Transform to be inserted
      Returns:
      this Pipeline
    • insert

      public Pipeline insert(int position, String name, Transform transform)
      Inserts the given Transform to the list of transforms at the given position to be applied on the NDArray with the given name in the input NDList.
      Parameters:
      position - the position at which the Transform must be inserted
      name - the key corresponding to the NDArray in the input NDList on which the given transform must be applied to
      transform - the Transform to be inserted
      Returns:
      this Pipeline
    • transform

      public NDList transform(NDList input)
      Applies the transforms configured in this object on the input NDList.

      If a key is specified with the transform, those transforms will only be applied to the NDArray in the input NDList. If a key is not specified, it will be applied to the first element in the input NDList.

      Parameters:
      input - the input NDList on which the tranforms are to be applied
      Returns:
      the output NDList after applying the tranforms