Interface PredictionFunction<T>

Type Parameters:
T -

public interface PredictionFunction<T>
Prediction function, typically used with a deep learning framework.

The primary intention of this interface is to provide a means to integrate machine learning libraries into existing QuPath pipelines that use OpenCV for processing (e.g. object or pixel classification).

Note that, where possible, implementations should support JSON serialization via Gson if they are intended to support serialization.

Author:
Pete Bankhead
See Also:
  • Field Details

  • Method Details

    • predict

      default Map<String,T> predict(Map<String,T> input)
      Call a function that takes one or more inputs to produce zero or more outputs.
      Parameters:
      input - map of input names and blobs
      Returns:
      map of output names and blobs
    • predict

      T predict(T input)
      Call a function that takes a single input and provides a single output.
      Parameters:
      input - input to the function
      Returns:
      output of the function
    • getInputs

      Map<String,DnnShape> getInputs()
      Get the required inputs.

      Often, this is a singleton map with key DEFAULT_INPUT_NAME for functions that take a single input.

      If the shape is known, the axis order is typically NCHW. NCHW is used by OpenCV https://docs.opencv.org/4.5.2/d6/d0f/group__dnn.html#ga29f34df9376379a603acd8df581ac8d7 and also by PyTorch; for TensorFlow some rearrangement may be needed.

      Returns:
    • getOutputs

      Map<String,DnnShape> getOutputs(DnnShape... inputShapes)
      Get the output names mapped to the output shapes.

      Often, this is a singleton map with key DEFAULT_OUTPUT_NAME for functions that provide a single output.

      Parameters:
      inputShapes - optional input shapes; if not provided, the output shapes are generally DnnShape.UNKNOWN_SHAPE
      Returns: