Package qupath.opencv.dnn
Interface DnnModel
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
AbstractDnnModel
,OpenCVDnn
General interface for implementing 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.
Implementations should provide 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
If only a single input and output are required, then only predict(Mat)
needs to be implemented.
Note: This was originally implemented in QuPath v0.3.0, but simplified for
QuPath v0.5.0. It no longer takes a generic parameter or requires
'blob' and 'prediction' functions to be defined.
This makes it easier to implement, and also to handle memory management.
If you want the old behavior, see AbstractDnnModel
.
- Since:
- 0.5.0
- Author:
- Pete Bankhead
- See Also:
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionbatchPredict
(List<? extends Mat> mats) Prediction function that can take a batch of inputs and gives a corresponding batch of outputs.default void
close()
Close this model if it will not be needed again.Prediction function that can take multiple inputs.default Mat
Prediction function that takes a single input and gives a single output.
-
Field Details
-
DEFAULT_INPUT_NAME
Default input layer name. This should be used when the input layer name is known or unimportant (e.g. the common case of a single input).- See Also:
-
DEFAULT_OUTPUT_NAME
Default output layer name. This should be used when the output layer name is known or unimportant (e.g. the common case of a single output).- See Also:
-
-
Method Details
-
predict
Prediction function that can take multiple inputs.- Parameters:
blobs
-- Returns:
-
predict
Prediction function that takes a single input and gives a single output.- Parameters:
mat
-- Returns:
-
batchPredict
Prediction function that can take a batch of inputs and gives a corresponding batch of outputs. Each input is expected to have a single output.- Parameters:
mats
-- Returns:
-
close
Close this model if it will not be needed again. Subclasses that require cleanup may override this. The default implementation does nothing.- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-