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
model
Binary file contains trained weights.
config
Text 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
model
Binary file contains trained weights.
-
Set flag crop for frame.
Declaration
Objective-C
- (nonnull Model *)setInputCrop:(BOOL)crop;
Swift
func setInputCrop(crop: Bool) -> Model
Parameters
crop
Flag 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) -> Model
Parameters
scale
Multiplier 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) -> Model
Parameters
width
New input width.
height
New input height.
-
Set flag swapRB for frame.
Declaration
Objective-C
- (nonnull Model *)setInputSwapRB:(BOOL)swapRB;
Swift
func setInputSwapRB(swapRB: Bool) -> Model
Parameters
swapRB
Flag 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
outs
Allocated output blobs, which will store results of the computation.
-
Set preprocessing parameters for frame.
Declaration
Parameters
size
New input size.
mean
Scalar with mean values which are subtracted from channels.
scale
Multiplier for frame values.
swapRB
Flag which indicates that swap first and last channels.
crop
Flag 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
size
New input size.
mean
Scalar with mean values which are subtracted from channels.
scale
Multiplier for frame values.
swapRB
Flag 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
size
New input size.
mean
Scalar with mean values which are subtracted from channels.
scale
Multiplier 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
size
New input size.
scale
Multiplier 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
scale
Multiplier 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()