Model
This class is presented high-level API for neural networks.
Model allows to set params for preprocessing input image. Model creates net from file with trained weights and config, sets preprocessing input and runs forward pass.
Member of Dnn
-
Create model from deep learning network represented in one of the supported formats. An order of @p model and @p config arguments does not matter.
Declaration
Objective-C
- (nonnull instancetype)initWithModel:(nonnull NSString *)model config:(nonnull NSString *)config;Swift
init(model: String, config: String)Parameters
modelBinary file contains trained weights.
configText file contains network configuration.
-
Create model from deep learning network represented in one of the supported formats. An order of @p model and @p config arguments does not matter.
Declaration
Objective-C
- (nonnull instancetype)initWithModel:(nonnull NSString *)model;Swift
init(model: String)Parameters
modelBinary file contains trained weights.
-
Set flag crop for frame.
Declaration
Objective-C
- (nonnull Model *)setInputCrop:(BOOL)crop;Swift
func setInputCrop(crop: Bool) -> ModelParameters
cropFlag which indicates whether image will be cropped after resize or not.
-
Set scalefactor value for frame.
Declaration
Objective-C
- (nonnull Model *)setInputScale:(double)scale;Swift
func setInputScale(scale: Double) -> ModelParameters
scaleMultiplier for frame values.
-
Set input size for frame.
Note
If shape of the new blob less than 0, then frame size not change.Declaration
Objective-C
- (nonnull Model *)setInputSize:(int)width height:(int)height;Swift
func setInputSize(width: Int32, height: Int32) -> ModelParameters
widthNew input width.
heightNew input height.
-
Set flag swapRB for frame.
Declaration
Objective-C
- (nonnull Model *)setInputSwapRB:(BOOL)swapRB;Swift
func setInputSwapRB(swapRB: Bool) -> ModelParameters
swapRBFlag which indicates that swap first and last channels.
-
Given the @p input frame, create input blob, run net and return the output @p blobs.
Declaration
Swift
func predict(frame: Mat, outs: NSMutableArray)Parameters
outsAllocated output blobs, which will store results of the computation.
-
Set preprocessing parameters for frame.
Declaration
Parameters
sizeNew input size.
meanScalar with mean values which are subtracted from channels.
scaleMultiplier for frame values.
swapRBFlag which indicates that swap first and last channels.
cropFlag which indicates whether image will be cropped after resize or not. blob(n, c, y, x) = scale * resize( frame(y, x, c) ) - mean© )
-
Set preprocessing parameters for frame.
Declaration
Parameters
sizeNew input size.
meanScalar with mean values which are subtracted from channels.
scaleMultiplier for frame values.
swapRBFlag which indicates that swap first and last channels. blob(n, c, y, x) = scale * resize( frame(y, x, c) ) - mean© )
-
Set preprocessing parameters for frame.
Declaration
Parameters
sizeNew input size.
meanScalar with mean values which are subtracted from channels.
scaleMultiplier for frame values. blob(n, c, y, x) = scale * resize( frame(y, x, c) ) - mean© )
-
Set preprocessing parameters for frame.
Declaration
Objective-C
- (void)setInputParams:(double)scale size:(nonnull Size2i *)size;Swift
func setInputParams(scale: Double, size: Size2i)Parameters
sizeNew input size.
scaleMultiplier for frame values. blob(n, c, y, x) = scale * resize( frame(y, x, c) ) - mean© )
-
Set preprocessing parameters for frame.
Declaration
Objective-C
- (void)setInputParams:(double)scale;Swift
func setInputParams(scale: Double)Parameters
scaleMultiplier for frame values. blob(n, c, y, x) = scale * resize( frame(y, x, c) ) - mean© )
-
Set preprocessing parameters for frame. blob(n, c, y, x) = scale * resize( frame(y, x, c) ) - mean© )
Declaration
Objective-C
- (void)setInputParams;Swift
func setInputParams()
View on GitHub
Model Class Reference