dnn_ClassificationModel
import { dnn_ClassificationModel } from '@banou/opencv-wasm'Use after await initOpenCV(). See the initialization and named imports guide.
Native object: release it with using or delete(). Factories can return null; check before calling methods. Inherits dnn_Model.
This class represents high-level API for classification models.
ClassificationModel allows to set params for preprocessing input image. ClassificationModel creates net from file with trained weights and config, sets preprocessing input, runs forward pass and return top-1 prediction.
Constructors and members
static new
Create classification model from network represented in one of the supported formats.
An order of model and config arguments does not matter.
new(model: EmbindString, config: EmbindString): dnn_ClassificationModel;2 available overloads
new(network: EmbindString): dnn_ClassificationModel;new(model: EmbindString, config: EmbindString): dnn_ClassificationModel;networkNet object.
modelBinary file contains trained weights.
configText file contains network configuration.
The dnn_ClassificationModel result.
static from1
Create an owned dnn_ClassificationModel instance with the supplied configuration.
This class represents high-level API for classification models.
from1(_0: dnn_Net): dnn_ClassificationModel | null;_00 argument (dnn_Net).
The dnn_ClassificationModel | null result.
clone
Create another handle to the same native object. This retains the object without copying its pixels or algorithm state; dispose both handles separately.
clone(): this;The this result.
setEnableSoftmaxPostProcessing
Set enable/disable softmax post processing option.
If this option is true, softmax is applied after forward inference within the classify() function to convert the confidences range to [0.0-1.0]. This function allows you to toggle this behavior. Please turn true when not contain softmax layer in model.
setEnableSoftmaxPostProcessing(enable: boolean): dnn_ClassificationModel;enableSet enable softmax post processing within the classify() function.
The dnn_ClassificationModel result.
getEnableSoftmaxPostProcessing
Get enable/disable softmax post processing option.
This option defaults to false, softmax post processing is not applied within the classify() function.
getEnableSoftmaxPostProcessing(): boolean;The boolean result.
classify
Given the input frame, create input blob, run net and return top-1 prediction.
classify(frame: Mat): dnn_ClassificationModel_classifyResult;frameThe input image.
The dnn_ClassificationModel_classifyResult result. Scalar output parameters are returned as named fields in this object. Release returned native handles with using or delete(), including handles nested in results.
These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.