Interface PredictionFunction<T>
- Type Parameters:
T
-
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionGet the required inputs.getOutputs
(DnnShape... inputShapes) Get the output names mapped to the output shapes.Call a function that takes one or more inputs to produce zero or more outputs.Call a function that takes a single input and provides a single output.
-
Field Details
-
DEFAULT_INPUT_NAME
Default name to use for single input.- See Also:
-
DEFAULT_OUTPUT_NAME
Default name to use for single output.- See Also:
-
-
Method Details
-
predict
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
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
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
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 generallyDnnShape.UNKNOWN_SHAPE
- Returns:
-