SOD C/C++ API - Convolutional/Recurrent Neural Networks (CNN/RNN)

Syntax

int sod_cnn_config(sod_cnn *pNet, SOD_CNN_CONFIG conf, ...);

Description

Configure a sod_cnn handle. The second argument to sod_cnn_config() is an integer configuration option that determines what property of the CNN/RNN is to be configured. Subsequent arguments vary depending on the configuration option in the second argument. The default configuration is recommended for most applications and so this routine is usually not necessary except for the RNN architecture where you need to supply a consumer callback as defined below.

Parameters

sod_cnn    *pNet

A pointer to a valid sod_cnn object obtained from a prior successful call to via sod_cnn_create().

SOD_CNN_CONFIG    conf

An integer configuration option that determines what property of the sod_cnn is to be configured. Subsequent arguments vary depending on the configuration verb. Here is a list of the allowed configuration options:

Configuration Verb Expected Arguments Description
SOD_CNN_NETWORK_OUTPUT Two Args:
float **vector (pointer address)
int *count
Extract network output vector. This option must be called after sod_cnn_predict() in order to extract the network prediction output which is a float vector. The total number of elements in this array is copied into count, the second argument this option takes.
SOD_CNN_DETECTION_THRESHOLD One Arg:
double nms
Minimum threshold value to mark a potential region of interest (i.e. an object is detected). Default value is set to 0.24.
SOD_CNN_NMS One Arg:
double nms
Non-Maximum Suppression (NMS) threshold. Default value is set to 0.45.
SOD_CNN_TEMPERATURE One Arg:
double temp
Temperature for all network layers. Default value is set to 0.7.
SOD_CNN_LOG_CALLBACK Two Args:
ProcLogCallback xLog(),
void *pUserdata
Register a log consumer callback:
void (*xLog)(const char *zMsg, size_t msgLen, void *pUserData)
A pointer to a user defined function responsible of consuming all CNN log messages if any.
The first argument is a pointer to a null terminated string generated by the CNN that your callback have to consume (i.e. redirecting to STDOUT or some disk file for example). The second argument is the string length and the third argument is an arbitrary pointer passed verbatim by the CNN to your callback that you have to pass as second argument to this configuration option. If you do not want to share data with the callback, simply pass NULL.
SOD_RNN_SEED One Arg:
const char *zSeed
A NULL terminated string where each character may be used as a seed for the RNN architecture when generating text.
SOD_RNN_TEXT_LENGTH One Arg:
int length
Maximum text length to be generated by the RNN network. Default is set to 100 characters.
SOD_RNN_CALLBACK Two Args:
ProcRnnCallback xTextConsumer(),
void *pUserdata
Register a RNN text output consumer callback:
void (*xTextConsumer)(const char *zText, size_t textLen, void *pUserData)
A pointer to a user defined function responsible of consuming all text generated by the RNN architecture.
The first argument the callback takes is a pointer to a null terminated string generated by the RNN that your callback have to consume (i.e. redirecting to STDOUT, network socket or some disk file for example). The second argument is the string length and the third argument is an arbitrary pointer passed verbatim by the network to your callback that you have to pass as second argument to this configuration option. If you do not want to share data with your callback, simply pass NULL.

Return Value

SOD_OK is returned on success. Any other code indicates failure.

Example

Checkout the introduction course, the C/C++ samples on the download page or refer to the SOD Github Repository.

See also

sod_cnn_predictsod_cnn_createsod_cnn_prepare_imagesod_cnn_get_network_sizesod_img_load_from_filesod_cnn_destroy.


Back