Package qupath.opencv.dnn
Class AbstractDnnModel<T>
java.lang.Object
qupath.opencv.dnn.AbstractDnnModel<T>
- Type Parameters:
T
-
- All Implemented Interfaces:
AutoCloseable
,DnnModel
- Direct Known Subclasses:
OpenCVDnn
Wrapper for a deep learning model in a pipeline using OpenCV.
It can encapsulate a custom method needed to convert the input Mat(s) into the appropriate format,
and the output back into one or more Mats.
This provides convenience methods to both convert and predict for three common scenarios:
- Single input, single output; batch size 1
- Single or multiple inputs, single or multiple outputs; batch size 1
- Single input, single output; batch size > 1
- Author:
- Pete Bankhead
- See Also:
-
Field Summary
Fields inherited from interface qupath.opencv.dnn.DnnModel
DEFAULT_INPUT_NAME, DEFAULT_OUTPUT_NAME
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbatchPredict
(List<? extends Mat> mats) Convenience method to convert one or more image patches to a blob, apply thePredictionFunction
, and convert the output to standard Mats.abstract BlobFunction
<T> Get the function that can convert one or more OpenCV Mats into a blob supported by the prediction function for the first (or only) input.abstract BlobFunction
<T> getBlobFunction
(String name) Get the function that can convert one or more OpenCV Mats into a blob supported by the prediction function for a specified input layer.abstract PredictionFunction
<T> Get the prediction function that can apply a prediction with one or more blobs as input.Convenience method to convert input image patches to a blobs, apply aPredictionFunction
(optionally with multiple inputs/outputs), and convert the output to a standardMat
.Convenience method to convert a single image patch to a blob, apply thePredictionFunction
, and convert the output to a standardMat
.
-
Constructor Details
-
AbstractDnnModel
public AbstractDnnModel()
-
-
Method Details
-
getBlobFunction
Get the function that can convert one or more OpenCV Mats into a blob supported by the prediction function for the first (or only) input.- Returns:
-
getBlobFunction
Get the function that can convert one or more OpenCV Mats into a blob supported by the prediction function for a specified input layer.- Parameters:
name
-- Returns:
-
getPredictionFunction
Get the prediction function that can apply a prediction with one or more blobs as input.- Returns:
-
predict
Convenience method to convert input image patches to a blobs, apply aPredictionFunction
(optionally with multiple inputs/outputs), and convert the output to a standardMat
.Note that this only supports a batch size of 1. For larger batches or more control,
getBlobFunction(String)
andgetPredictionFunction()
should be used directly. -
predict
Convenience method to convert a single image patch to a blob, apply thePredictionFunction
, and convert the output to a standardMat
.Note that this only supports a batch size of 1. For larger batches or more control,
getBlobFunction(String)
andgetPredictionFunction()
should be used directly. -
batchPredict
Convenience method to convert one or more image patches to a blob, apply thePredictionFunction
, and convert the output to standard Mats. This method is intended for cases where the batch size should be greater than one; for a batch size of one,predict(Mat)
can be used instead.- Specified by:
batchPredict
in interfaceDnnModel
- Parameters:
mats
-- Returns:
-