SqueezeBrains SDK 1.18
SVL - Training

Collection of functions to manage SVL or training of Retina and Surface. More...

Collaboration diagram for SVL - Training:

Modules

 Features defines
 

Data Structures

struct  sb_t_svl_pre_elaboration
 Contains the results of the image pre-processing. More...
 
struct  sb_t_svl_dl_par_network
 Deep Learning network parameters. More...
 
struct  sb_t_svl_dl_par_perturbation
 Describes the perturbation of the image / defect. More...
 
struct  sb_t_svl_dl_tiling_par
 Image tiling parameters. More...
 
struct  sb_t_svl_dl_par
 SVL parameters to configure the Deep Learning training. More...
 
struct  sb_t_svl_sl_par
 SVL parameters that configure the Shallow Learning training. More...
 
struct  sb_t_devices_par
 Property of computational devices. More...
 
struct  sb_t_svl_par
 SVL parameters. More...
 
struct  sb_t_svl_err
 Contains information regarding the error of the SVL. More...
 
struct  sb_t_svl_res_image
 Defines the results of the elaboration of the SVL of an image. More...
 
struct  sb_t_svl_res_images
 Defines the results of the elaboration of the SVL images. More...
 
struct  sb_t_svl_res_epoch
 Results of a training epoch. More...
 
struct  sb_t_svl_res_epochs
 Results of the training epochs. More...
 
struct  sb_t_svl_res_level
 Results of the SVL of a level per model. More...
 
struct  sb_t_svl_res_levels
 Results of the SVL of a levels processed. More...
 
struct  sb_t_svl_res_model
 Results of the SVL of a specific model. More...
 
struct  sb_t_svl_res_models
 Results of the SVL of a models processed. More...
 
struct  sb_t_svl_res
 Defines the results of SVL. More...
 

Macros

#define SB_PAR_FEATURES_NAMES_LEN   256
 Maximum length, in byte, of the features names string.
 
#define SB_PRE_TRAINING_EXT   "ptf"
 Extension of the SqueezeBrains pre-training network file.
 
#define SB_DEVICES_MAX_NUMBER   4
 Maximum number of computational devices managed by the sb library. More...
 
#define SB_CLS_0   "cls0"
 classificator type 0
 
#define SB_CLS_1   "cls1"
 classificator type 1
 
#define SB_FEATURES
 < List of all the features separated by SB_DELIMITER
 
#define SB_SVL_STEP_INITIALIZATION   "initializing data for svl"
 SVL step: initialization.
 
#define SB_SVL_STEP_SEARCHING_RECIPE   "choosing recipe"
 SVL step: choosing recipe.
 
#define SB_SVL_STEP_TRAINING_RECIPE   "training recipe"
 SVL step: training recipe.
 
#define SB_SVL_STEP_FINALIZATION   "finalization of svl"
 SVL step: finalization of svl.
 
#define SB_SVL_STEP_FINISHED   "svl has finished"
 SVL step: svl has finished.
 

Typedefs

typedef sb_t_err(* sb_fp_svl_pre_elaboration) (const SB_HANDLE image_info, void *const user_data, const char *const image_file, int image_index, sb_t_svl_pre_elaboration *const pre_elaboration)
 Definition of the callback for image pre elaboration. More...
 
typedef sb_t_err(* sb_fp_svl_progress) (void *const user_data, sb_t_svl_res *res, int force)
 Definition of the callback for the working progress. More...
 
typedef sb_t_err(* sb_fp_svl_command) (void *const user_data, sb_t_svl_res *res, sb_t_svl_command *const command, const char *const msg)
 Definition of the callback that the SVL calls when it needs to know how to continue. More...
 

Enumerations

enum  sb_t_svl_command {
  SB_SVL_COMMAND_STOP = 0 , SB_SVL_COMMAND_CONTINUE , SB_SVL_COMMAND_ABORT , SB_SVL_COMMAND_CONTINUE_NO_RESET ,
  SB_SVL_COMMAND_NEXT_STEP
}
 Enumerates the actions that SVL has to do after a stop. More...
 
enum  sb_t_svl_par_optimization_mode { SB_SVL_PAR_OPTIMIZATION_TIME_SLOW = 0 , SB_SVL_PAR_OPTIMIZATION_TIME_MEDIUM , SB_SVL_PAR_OPTIMIZATION_TIME_FAST , SB_SVL_PAR_OPTIMIZATION_USE_SELECTED }
 Describes the optimization mode of SVL. More...
 
enum  sb_t_network_type {
}
 Deep learning network types. More...
 
enum  sb_t_network_freeze_mode { SB_NETWORK_FREEZE_MODE_NONE = 0 , SB_NETWORK_FREEZE_MODE_FIRST_BLOCK = 1000 , SB_NETWORK_FREEZE_MODE_ENCODER = 2000 , SB_NETWORK_FREEZE_MODE_ENCODER_DECODER = 3000 , SB_NETWORK_FREEZE_MODE_END }
 Deep learning network freeze mode. More...
 
enum  sb_t_tiling_mode { SB_TILING_MODE_MANUAL = 0 , SB_TILING_MODE_AUTO }
 Enumerates the tiling mode. More...
 
enum  sb_t_loss_fn_type { SB_LOSS_FN_TYPE_CCE = 0 , SB_LOSS_FN_TYPE_FOCAL , SB_LOSS_FN_TYPE_BCE }
 Enumerates the loss functions. More...
 
enum  sb_t_image_borders_extension_mode {
  SB_IMAGE_BORDERS_EXTENSION_MODE_NONE = 0 , SB_IMAGE_BORDERS_EXTENSION_MODE_V_0 , SB_IMAGE_BORDERS_EXTENSION_MODE_V_127 , SB_IMAGE_BORDERS_EXTENSION_MODE_V_255 ,
  SB_IMAGE_BORDERS_EXTENSION_MODE_LAST , SB_IMAGE_BORDERS_EXTENSION_MODE_IMAGE_AVG , SB_IMAGE_BORDERS_EXTENSION_MODE_KERNEL_AVG , SB_IMAGE_BORDERS_EXTENSION_MODE_MIRRORING ,
  SB_IMAGE_BORDERS_EXTENSION_MODE_BORDER_AVG , SB_IMAGE_BORDERS_EXTENSION_MODE_BORDER_AVG_LOCAL , SB_IMAGE_BORDERS_EXTENSION_MODE_KERNEL_AVG_17x1
}
 Enumerate the image borders extension mode. More...
 
enum  sb_t_perturbation_mode { SB_PERTURBATION_MODE_ONLINE = 0 , SB_PERTURBATION_MODE_OFFLINE , SB_PERTURBATION_MODE_BOTH }
 Enumerates the mode of the perturbations. More...
 
enum  sb_t_perturbation_type { SB_PERTURBATION_TYPE_IMAGE = 0 , SB_PERTURBATION_TYPE_DEFECTS , SB_PERTURBATION_TYPE_BOTH }
 Enumerates the range of application of the perturbations. More...
 
enum  sb_t_svl_stop_reason {
  SB_SVL_STOP_NONE = 0 , SB_SVL_STOP_CONFLICT , SB_SVL_STOP_USER_REQUEST , SB_SVL_STOP_MEMORY ,
  SB_SVL_STOP_RESET_MANDATORY , SB_SVL_STOP_RESET_OPTIONAL , SB_SVL_STOP_WARNING
}
 Enumerates the reasons why SVL is terminated or why the callback sb_t_svl_par::fp_command has been called. More...
 

Functions

const char * sb_svl_command_format (sb_t_svl_command command)
 Returns the string of the SVL command. More...
 
const char * sb_svl_par_optimization_mode_format (sb_t_svl_par_optimization_mode mode)
 Returns the string of the SVL optimization mode. More...
 
const char * sb_network_type_format (sb_t_network_type type)
 Returns the string of the network type. More...
 
const char * sb_network_freeze_mode_format (sb_t_network_freeze_mode freeze_mode)
 Returns the string of the network freeze mode. More...
 
const char * sb_tiling_mode_format (sb_t_tiling_mode mode)
 Returns the string of the tiling mode. More...
 
const char * sb_loss_fn_type_format (sb_t_loss_fn_type type)
 Returns the string of the loss function type. More...
 
const char * sb_image_borders_extension_mode_format (sb_t_image_borders_extension_mode mode)
 Returns the string of the image borders extension mode. More...
 
const char * sb_perturbation_mode_format (sb_t_perturbation_mode mode)
 Returns the string of the Deep Learning SVL image perturbation mode. More...
 
const char * sb_perturbation_type_format (sb_t_perturbation_type type)
 Returns the string of the Deep Learning SVL image perturbation type. More...
 
const char * sb_feature_description (const char *const feature)
 Returns a string with a brief description of a feature. More...
 
sb_t_err sb_svl_run (SB_HANDLE handle)
 Runs the SVL. More...
 
sb_t_err sb_svl_reset (SB_HANDLE handle)
 Resets the history of previous executions of the SVL. More...
 
sb_t_err sb_svl_stop_request (SB_HANDLE handle)
 Sends a request to the SVL for stop. More...
 
sb_t_err sb_svl_get_res (SB_HANDLE handle, sb_t_svl_res **const res)
 Retrieves the results of SVL. More...
 
sb_t_err sb_svl_destroy_res (sb_t_svl_res **const res)
 Destroys the structure of the results of SVL. More...
 
sb_t_err sb_svl_clone_res (sb_t_svl_res **const dst, const sb_t_svl_res *const src)
 Copies the structure of the results of SVL. More...
 
sb_t_err sb_svl_save_pre_training (SB_HANDLE handle, const char *const file_name)
 Saves the current SVL parameter configuration into a pre-training file. More...
 
sb_t_err sb_pre_training_get_par (sb_t_par **const par, const char *const file_name)
 Retrieves the project parameter structure of a pre-training file. More...
 

Detailed Description

Collection of functions to manage SVL or training of Retina and Surface.

See SVL - training for more information.

Macro Definition Documentation

◆ SB_DEVICES_MAX_NUMBER

#define SB_DEVICES_MAX_NUMBER   4

Maximum number of computational devices managed by the sb library.

See also
sb_t_devices_par

Definition at line 11226 of file sb.h.

Typedef Documentation

◆ sb_fp_svl_command

typedef sb_t_err(* sb_fp_svl_command) (void *const user_data, sb_t_svl_res *res, sb_t_svl_command *const command, const char *const msg)

Definition of the callback that the SVL calls when it needs to know how to continue.

Attention
You must destroy the parameter res with sb_svl_destroy_res function before exit the callback
Parameters
[in,out]user_dataPointer to the user data.
[in]rescurrent results of the SVL.
[out]commandPointer to the SVL command. The user can decided what SVL has to do.
[in]msgMessage for the user.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.
See also
SVL Callbacks
sb_svl_destroy_res

Definition at line 10398 of file sb.h.

◆ sb_fp_svl_pre_elaboration

typedef sb_t_err(* sb_fp_svl_pre_elaboration) (const SB_HANDLE image_info, void *const user_data, const char *const image_file, int image_index, sb_t_svl_pre_elaboration *const pre_elaboration)

Definition of the callback for image pre elaboration.

Parameters
[in]image_infoSqueezeBrains image info handle.
[in,out]user_dataPointer to the user data.
[in]image_fileImage file name.
[in]image_indexIndex of the image.
[out]pre_elaborationPointer to the structure where the user implements the pre-elaboration of the images and set the ROI
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.
See also
SVL Callbacks

Definition at line 10373 of file sb.h.

◆ sb_fp_svl_progress

typedef sb_t_err(* sb_fp_svl_progress) (void *const user_data, sb_t_svl_res *res, int force)

Definition of the callback for the working progress.

Attention
You must destroy the parameter res with sb_svl_destroy_res function before exit the callback
Parameters
[in,out]user_dataPointer to the user data.
[in]rescurrent results of the SVL.
[in]forceIf different that 0 means that in the results something is changed.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.
See also
SVL Callbacks
sb_svl_destroy_res

Definition at line 10385 of file sb.h.

Enumeration Type Documentation

◆ sb_t_image_borders_extension_mode

Enumerate the image borders extension mode.

Enumerator
SB_IMAGE_BORDERS_EXTENSION_MODE_NONE 

Undefined extension mode.

No extension algorithm is applied

SB_IMAGE_BORDERS_EXTENSION_MODE_V_0 

Zero extension mode.

All the border pixels are set to value 0

SB_IMAGE_BORDERS_EXTENSION_MODE_V_127 

Grey extension mode.

All the border pixels are set to value 127

SB_IMAGE_BORDERS_EXTENSION_MODE_V_255 

Grey extension mode.

All the border pixels are set to value 255

SB_IMAGE_BORDERS_EXTENSION_MODE_LAST 

Last pixel extension mode.

Last pixel of the image is replicated till the end of the image. First Horizontally and then vertically.

SB_IMAGE_BORDERS_EXTENSION_MODE_IMAGE_AVG 

Image average extension mode.

All the pixels in borders are set to a constant value equal to the average of all the pixels of the image

SB_IMAGE_BORDERS_EXTENSION_MODE_KERNEL_AVG 

Local average extension mode.

For every outer pixel of the image an average of its neighborhood is computed by a kernel and the result is propagated till the end of the image. First Horizontally and then vertically.

SB_IMAGE_BORDERS_EXTENSION_MODE_MIRRORING 

Mirroring extension mode.

Borders are filled by mirroring the image. If an image dimension is lower than corresponding border thickness, mirroring is applied multiple times.

SB_IMAGE_BORDERS_EXTENSION_MODE_BORDER_AVG 

Last line average extension mode.

For each outer pixel of the image, the average is computed on the edge and its value replicated till the end of the image.

SB_IMAGE_BORDERS_EXTENSION_MODE_BORDER_AVG_LOCAL 

Last line local average extension mode.

For each outer pixel of the of the image, an average of its neighbor pixel on the edge is computed and the result is replicated till the end of the image.

SB_IMAGE_BORDERS_EXTENSION_MODE_KERNEL_AVG_17x1 

Horizontal local average extension mode.

For every outer pixel of the image, an average of its 9 horizontal neighbor pixels belonging to the image is computed by a kernel and the result is propagated till the end of the image. First Horizontally and then vertically.

Definition at line 10723 of file sb.h.

◆ sb_t_loss_fn_type

Enumerates the loss functions.

Enumerator
SB_LOSS_FN_TYPE_CCE 

Categorical Cross Entropy loss.

loss used for (mutual-exclusive) multi-class classification/segmentation task. The loss is computed only considering the error of the model associated to the target instance. The instance is an image, in the case of Deep Cortex project, or a pixel, in the case of Deep Surface.
The loss value at the end of each epoch is obtained by averaging all the loss instances over SVL batch.
Further information at https://towardsdatascience.com/cross-entropy-loss-function-f38c4ec8643e .

SB_LOSS_FN_TYPE_FOCAL 

Focal loss.

loss used for multi-class classification/segmentation task. The loss is computed only considering the error of the model associated to the target instance. The instance is an image, in the case of Deep Cortex project, or a pixel, in the case of Deep Surface. The particularity of this loss is that the training focuses on target instances harder to disciminate.
The loss value at the end of each epoch is obtained by averaging all the loss instances over SVL batch.
Further information at https://towardsdatascience.com/focal-loss-a-better-alternative-for-cross-entropy-1d073d92d075 .

SB_LOSS_FN_TYPE_BCE 

SB Binary Cross Entropy loss.

loss used for (non-exclusive) multi-class binary classification/segmentation task. The loss is computed considering the error occurred for all the models on the current SVL instance. The instance may have at most one model assigned (or also none) and its loss is equal to the sum of the error on the associated model (higher if it is not detected) and the errors associated to the other models (higher if they are detected). The instance is an image, in the case of Deep Cortex project, or a pixel, in the case of Deep Surface. The loss value at the end of each epoch is obtained by averaging all the loss instances over SVL batch.
Further information at https://towardsdatascience.com/understanding-binary-cross-entropy-log-loss-a-visual-explanation-a3ac6025181a .

Definition at line 10663 of file sb.h.

◆ sb_t_network_freeze_mode

Deep learning network freeze mode.

Enumerator
SB_NETWORK_FREEZE_MODE_NONE 

Freeze mode disabled.

No parameters of any layers are frozen. It corresponds to let the network free to learn during the training without any constraint.

SB_NETWORK_FREEZE_MODE_FIRST_BLOCK 

Freeze the first block of the newtork.

Only the parameters of the first block of the network are frozen and thus not trainable. Block means a group of layer which performs operation strictly related to each other.

SB_NETWORK_FREEZE_MODE_ENCODER 

Freeze the network encoder.

Only encoder parameters are frozen, i.e. all those parameters which contributes to update and extract features from training images. Use this option if you want to fix the set of fetaures and specialize the training on the new dataset only by changing the way in which feautures are combined.

SB_NETWORK_FREEZE_MODE_ENCODER_DECODER 

Freeze both encoder and decoder.

Encoder and decoder parameters are frozen. Decoder refers to all those layers used to expand and combine the compressed features at the encoder output in order to get features at higher resolution. This freeze modality does not lock into account the part of the network resposable of genereting the classification associated to each pixel.

Note
Setting this mode makes sense only on Deep Surface project.
On Deep Cortex projects it equals setting SB_NETWORK_FREEZE_MODE_ENCODER option.

Definition at line 10472 of file sb.h.

◆ sb_t_network_type

Deep learning network types.

Enumerator
SB_NETWORK_TYPE_EFFICIENTNET_B0 

Deep Learning EfficientNet b0.

Note
The value sb_t_svl_dl_par_network.input_size must be (224,224)
SB_NETWORK_TYPE_EFFICIENTNET_B1 

Deep Learning EfficientNet b1.

Note
The value sb_t_svl_dl_par_network.input_size must be (240,240)
SB_NETWORK_TYPE_EFFICIENTNET_B2 

Deep Learning EfficientNet b2.

Note
The value sb_t_svl_dl_par_network.input_size must be (260,260)
SB_NETWORK_TYPE_SDINET0 

Deep Learning Surface Defects Inspection Network 0 with variable input size.

SB_NETWORK_TYPE_ICNET0_64 

Deep Learning Image Classification Network 0 with input size 64x64.

Note
The value sb_t_svl_dl_par_network.input_size must be (64,64)
SB_NETWORK_TYPE_ICNET0_128 

Deep Learning Image Classification Network 0 with input size 128x128.

Note
The value sb_t_svl_dl_par_network.input_size must be (128,128)
SB_NETWORK_TYPE_ODNET0 

Deep Learning Object Detection Network 0 with input size 416x416.

Note
The value sb_t_svl_dl_par_network.input_size must be (416, 416)

Definition at line 10403 of file sb.h.

◆ sb_t_perturbation_mode

Enumerates the mode of the perturbations.

See also
Deep Learning Perturbations
Enumerator
SB_PERTURBATION_MODE_ONLINE 

Online perturbation.

Images are perturbated at the beginning of each epoch in a repeatable pseudo randomic way, different for each epoch

SB_PERTURBATION_MODE_OFFLINE 

Offline perturbation.

the learning images set is increased by perturbating the images before the training starts.

SB_PERTURBATION_MODE_BOTH 

Both online and offline perturbations.

Definition at line 10799 of file sb.h.

◆ sb_t_perturbation_type

Enumerates the range of application of the perturbations.

See also
Deep Learning Perturbations
Enumerator
SB_PERTURBATION_TYPE_IMAGE 

The whole image is perturbated.

SB_PERTURBATION_TYPE_DEFECTS 

Only the defect area is perturbated.

SB_PERTURBATION_TYPE_BOTH 

Both image and defects perturbation type.

Definition at line 10832 of file sb.h.

◆ sb_t_svl_command

Enumerates the actions that SVL has to do after a stop.

On a stop the sb_svl_run calls the callback sb_t_svl_par::fp_command.
The values are 32 bits both for 32 and 64 bits library version.

See also
SVL Callbacks
sb_t_svl_par::fp_command
sb_t_svl_stop_reason
Enumerator
SB_SVL_COMMAND_STOP 

The SVL stops and exits, applying the training to the module.

After the sb_svl_run finished, you can call sb_project_save to save the results.

SB_SVL_COMMAND_CONTINUE 

The SVL continues and, if necessary, resets the training.

SB_SVL_COMMAND_ABORT 

The SVL stops and exits, without applying the training reached to the module.

After the sb_svl_run finished, You can not call sb_project_save to save the results.

SB_SVL_COMMAND_CONTINUE_NO_RESET 

The SVL continues without reset.

SB_SVL_COMMAND_NEXT_STEP 

The SVL go to next step.

Definition at line 10286 of file sb.h.

◆ sb_t_svl_par_optimization_mode

Describes the optimization mode of SVL.

The values are 32 bits both for 32 and 64 bits library version.

See also
License configurations
SVL - training
Features
sb_t_svl_sl_par::optimization_mode
Enumerator
SB_SVL_PAR_OPTIMIZATION_TIME_SLOW 

SVL promotes accuracy with respect to execution time.

  • Retina: it chooses the best classificator and the most significant features independently for each model.
  • Surface: SVL chooses the best classificator and the most significant features independently for each model. At least three features are chosen.
SB_SVL_PAR_OPTIMIZATION_TIME_MEDIUM 
  • Retina: SVL chooses the best classificator and the best feature for each model, only one feature for each model.
  • Surface: SVL chooses the best classificator and the most significant features independently for each model. At least two features are chosen.
SB_SVL_PAR_OPTIMIZATION_TIME_FAST 
  • Retina: SVL finds the best classificator and the best feature and sets them for all model.
  • Surface: SVL chooses the best classificator and the most significant features independently for each model. At least one feature is chosen.
SB_SVL_PAR_OPTIMIZATION_USE_SELECTED 

SVL will use the features selected by the user and which are compatible with the data set. The user can select the features with the parameter sb_t_svl_sl_par.features.

Definition at line 10329 of file sb.h.

◆ sb_t_svl_stop_reason

Enumerates the reasons why SVL is terminated or why the callback sb_t_svl_par::fp_command has been called.

The values are 32 bits both for 32 and 64 bits library version.
See sb_svl_run for the default action in case the sb_t_svl_par::fp_command is not set.

See also
SVL Callbacks
sb_t_svl_res::stop_reason
Enumerator
SB_SVL_STOP_NONE 

SVL finishes without errors.

SB_SVL_STOP_CONFLICT 

There are errors which can not be eliminated.

The function sb_svl_run calls sb_t_svl_par.fp_command with sb_t_svl_res::stop_reason equal to SB_SVL_STOP_CONFLICT in the following case:

  1. If after a few attempts some FALSE NEGATIVE and FALSE POSITIVE samples remain, the sb_svl_run function ask the user if stop or continue the SVL.
    Retina and Surface projects only.
SB_SVL_STOP_USER_REQUEST 

The user has stopped the SVL.

SB_SVL_STOP_MEMORY 

Insufficient memory to complete the SVL.

SB_SVL_STOP_RESET_MANDATORY 

Request for a mandatory reset of SVL.

The function sb_svl_run calls sb_t_svl_par.fp_command with sb_t_svl_res::stop_reason equal to SB_SVL_STOP_RESET_MANDATORY in the following case:

  1. the features selected in the previous SVL are not more compatible with the format (BW, color) of the images in the data set for SVL. It happen when a new training image is added which is not compatible with the current feature set, for example you add a BW image but there is a feature exclusively for color images.
    Retina and Surface projects only.
  2. the number of features is greater than the maximum allowed based on the license configuration.
    Retina and Surface projects only
  3. some images used for previous training will be used for validation.
    Deep Cortex and Deep Surface projects only

The check for automatic reset is done separately for each model.

SB_SVL_STOP_RESET_OPTIONAL 

Ask for an optional reset of SVL.

The function sb_svl_run calls sb_t_svl_par.fp_command with sb_t_svl_res::stop_reason equal to SB_SVL_STOP_RESET_OPTIONAL in the following case:

  1. internal differences in current SB SDK version compared to that has been used for the existing training
  2. if optimization_mode is equal fast and some models are trained and some are not.
    Retina and Surface projects only
  3. if optimization_mode is equal to fast and models has different feature.
    Retina and Surface projects only
  4. the optimization_mode is changed.
    Retina and Surface projects only
  5. some features used by the current training are removed from sb_t_svl_sl_par::features.
    Retina and Surface projects only
  6. the features available (sb_t_svl_sl_par.features) when the last SVL was done are changed.
    Retina and Surface projects only
  7. During the SVL step equal to SB_SVL_STEP_INITIALIZATION it warms if some images or tiles used for previous training will be used for validation.
    Deep Cortex and Deep Surface projects only
  8. During the SVL step equal to SB_SVL_STEP_INITIALIZATION it warms if the SVL version less than 1.12.2.
    Deep Surface projects only
  9. During the SVL step equal to SB_SVL_STEP_INITIALIZATION it warms if the pre-training file is changed.
    Deep Cortex and Deep Surface projects only

The check for automatic reset is done separately for each model.

SB_SVL_STOP_WARNING 

Send a warning message.

The function sb_svl_run calls sb_t_svl_par.fp_command with sb_t_svl_res::stop_reason equal to SB_SVL_STOP_WARNING in the following case:

  1. During the sb_t_svl_res.running_step "SVL step" equal to SB_SVL_STEP_SEARCHING_RECIPE, if no suitable features set can be found, the sb_svl_run function asks if the user want to proceed anyway using all selected features.
    Retina and Surface projects only
  2. if optimization_mode is equal to fast and no suitable common features set can be found for all models, the sb_svl_run function asks if the user want to proceed anyway using all chosen features.
    Retina and Surface projects only
  3. During the SVL step equal to SB_SVL_STEP_INITIALIZATION, if no perturbation is set, the sb_svl_run function suggests the user to stop the SVL and set some perturbations before running the SVL.
    Deep Cortex and Deep Surface projects only
  4. During the SVL step equal to SB_SVL_STEP_INITIALIZATION it warms if the data is missing to make an incremental svl, in this case the sb_svl_run function will perform an SVL from scratch.
    This happen when the project has been save with parameter mode equal to SB_PROJECT_MODE_DETECTION_ONLY, see sb_project_save.
    Deep Cortex and Deep Surface projects only

Definition at line 13862 of file sb.h.

◆ sb_t_tiling_mode

Enumerates the tiling mode.

"Tiling" refers to that image processing operation that consists in subdividing the elaborated image into multiple sub-images.

  • If the number of tiles > 1, the tiles will overlap in order to interpolate the vote plane to avoid sudden jumps between local values. In this case the tile gets partially out of the image in order to equally consider internal and external (those tile on the image border) tiles.
    In images referred to SB_TILING_MODE_MANUAL it's possible to see that in case of 2x1 tiles on the vertical axis there is only one tile and so it does not go out of the image, while on the horizontal axis there are two tiles and therefore they get out of the image to the same extent as they overlap.
    Parts of tile which are not superimposed to the image (i.e. the borders) are filled in according to the sb_t_svl_dl_par::borders_extension_mode parameter. These edge zones, even if they are not directly considered during training for metrics evaluation, still influence the analysis.
  • Note that, in the case of SB_TILING_MODE_AUTO, the analysis time increases in proportion with the image resolution as the automatic tiling procedure will have to use more tiles to cover the image. But there is also a large range of image size variability so the number of tiles does not vary as shown in the image below.
    Horizontal image resolution range with 3 tiles
    See also
    sb_t_res::tiles
    sb_image_info_get_tiles_svl
    sb_tiles_info_no_overlap
Enumerator
SB_TILING_MODE_MANUAL 

Manual tiling.

Tiling scheme, i.e. the number of horizontal and vertical tiles, to apply to the images is fixed.
This modality does not take into account the resolution of the image, so allows you to vary the real resolution with which the image is processed. In the images below some examples of manual tiling grid.

Manual tiling grid 2x1
Manual tiling grid 4x2
SB_TILING_MODE_AUTO 

Auto tiling.

Tiling scheme is automatically applied in according to the sb_t_svl_dl_tiling_par::scale parameter in order to keep constant the pixel/mm ratio used by the algorithm to process the images.
This mode facilitates the use of the library in case you need to analyze images with variable resolution.

  • The tiles are placed so that the image is centered.
  • Images with different resolution may be subdivided by different number of tiles.
  • The overlap between the tiles is not fixed as in SB_TILING_MODE_MANUAL but may increased in order to reduce the part of the tile that comes out of the image.
    Tiles can overlap of a maximum of their half so that no more than 2 tiles can overlap along a dimension in the same place.

The image below shows the case with 3x2 tiles.
The upper left black tile, having no analysis roi, will not be processed, on the contrary to the white ones.

Automatic tiling grid without image extension
Note
  • if sb_t_svl_dl_tiling_par.scale.min = sb_t_svl_dl_tiling_par.scale.max the mode is equivalent to the obsolete mode SB_TILING_MODE_AUTO_WITHOUT_IMAGE_EXT ;
  • if sb_t_svl_dl_tiling_par.scale.min = SB_DL_SCALE_MIN the mode is similar (but not equal!) to the obsolete mode SB_TILING_MODE_AUTO_WITH_IMAGE_EXT because exists also a minimum scale and therefore it is not possibile do have backwards compatibility in any conditions. In the obsolete SB_TILING_MODE_AUTO_WITH_IMAGE_EXT method the scale was not bounded below as in the new method.

Definition at line 10609 of file sb.h.

Function Documentation

◆ sb_feature_description()

const char * sb_feature_description ( const char *const  feature)

Returns a string with a brief description of a feature.

In the description returned by the function there is also information about the image format compatible with the feature.

  • There is the string "BW" if the feature is compatible with BW image
  • There is the string "color" if the feature is compatible with color images (BGR or RGB)
  • There is the string "BW, color" if the feature is compatible both with BW and color images
    Attention
    The string must not be freed.
    Parameters
    [in]featureString with the feature name. It should be one of the define SB_RETINA_FEATURE_XY.
    Returns
    A C-string containing a brief description for a feature.
    See also
    Features defines
    Features

◆ sb_image_borders_extension_mode_format()

const char * sb_image_borders_extension_mode_format ( sb_t_image_borders_extension_mode  mode)

Returns the string of the image borders extension mode.

Interprets the contents of the code and converts it to a C-string containing a human-readable version of the corresponding value.

Warning
The string must not be freed.
Parameters
[in]modeImage borders extension mode.
Returns
A C-string containing the image borders extension mode in a human-readable format.

◆ sb_loss_fn_type_format()

const char * sb_loss_fn_type_format ( sb_t_loss_fn_type  type)

Returns the string of the loss function type.

Interprets the contents of the code and converts it to a C-string containing a human-readable version of the corresponding value.

Warning
The string must not be freed.
Parameters
[in]typeLoss function type.
Returns
A C-string containing the loss function type in a human-readable format.

◆ sb_network_freeze_mode_format()

const char * sb_network_freeze_mode_format ( sb_t_network_freeze_mode  freeze_mode)

Returns the string of the network freeze mode.

Interprets the contents of the code and converts it to a C-string containing a human-readable version of the corresponding value.

Warning
The string must not be freed.
Parameters
[in]freeze_modeFreeze mode.
Returns
A C-string containing the network freeze mode in a human-readable format.

◆ sb_network_type_format()

const char * sb_network_type_format ( sb_t_network_type  type)

Returns the string of the network type.

Interprets the contents of the code and converts it to a C-string containing a human-readable version of the corresponding value.

Warning
The string must not be freed.
Parameters
[in]typeNetwork type.
Returns
A C-string containing the network type in a human-readable format.

◆ sb_perturbation_mode_format()

const char * sb_perturbation_mode_format ( sb_t_perturbation_mode  mode)

Returns the string of the Deep Learning SVL image perturbation mode.

Interprets the contents of the mode and converts it to a C-string containing a human-readable version of the corresponding perturbation mode.
The string must not be freed.

Parameters
[in]modeDeep Learning SVL image perturbation mode.
Returns
A C-string containing the perturbation mode in a human-readable format.

◆ sb_perturbation_type_format()

const char * sb_perturbation_type_format ( sb_t_perturbation_type  type)

Returns the string of the Deep Learning SVL image perturbation type.

Interprets the contents of the type and converts it to a C-string containing a human-readable version of the corresponding perturbation type.
The string must not be freed.

Parameters
[in]typeDeep Learning SVL image perturbation type.
Returns
A C-string containing the perturbation type in a human-readable format.

◆ sb_pre_training_get_par()

sb_t_err sb_pre_training_get_par ( sb_t_par **const  par,
const char *const  file_name 
)

Retrieves the project parameter structure of a pre-training file.

Parameters
[in]file_nameName of the file.
[out]parPointer to the parameters structure.
On successful return, this parameter will be filled with the pointer to sb_t_par structure.
The structure should be freed using the function sb_par_destroy.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.
See also
sb_svl_save_pre_training
sb_par_destroy
sb_par_clone
sb_par_copy
sb_par_format

◆ sb_svl_clone_res()

sb_t_err sb_svl_clone_res ( sb_t_svl_res **const  dst,
const sb_t_svl_res *const  src 
)

Copies the structure of the results of SVL.

Parameters
[out]dstThe variable will be filled with the pointer of the new structure.
[in]srcPointer of the structure to be copied.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.
See also
SVL - training

◆ sb_svl_command_format()

const char * sb_svl_command_format ( sb_t_svl_command  command)

Returns the string of the SVL command.

Interprets the contents of the command and converts it to a C-string containing a human-readable version of the corresponding command.
The string must not be freed.

Parameters
[in]commandSVL command.
Returns
A C-string containing the command in a human-readable format.

◆ sb_svl_destroy_res()

sb_t_err sb_svl_destroy_res ( sb_t_svl_res **const  res)

Destroys the structure of the results of SVL.

Parameters
[in,out]resPointer to the structure. It is set to NULL.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.
See also
SVL - training

◆ sb_svl_get_res()

sb_t_err sb_svl_get_res ( SB_HANDLE  handle,
sb_t_svl_res **const  res 
)

Retrieves the results of SVL.

Parameters
[in]handleProject handle.
[out]resPointer to the structure of SVL results.
On successful return, this parameter will be filled with the pointer of the structure sb_t_svl_res.
The structure should be freed using the function sb_svl_destroy_res.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.
See also
SVL - training
sb_svl_destroy_res

◆ sb_svl_par_optimization_mode_format()

const char * sb_svl_par_optimization_mode_format ( sb_t_svl_par_optimization_mode  mode)

Returns the string of the SVL optimization mode.

Interprets the contents of the mode and converts it to a C-string containing a human-readable version of the corresponding mode.
The string must not be freed.

Parameters
[in]modeSVL running mode.
Returns
A C-string containing the mode in a human-readable format.

◆ sb_svl_reset()

sb_t_err sb_svl_reset ( SB_HANDLE  handle)

Resets the history of previous executions of the SVL.

Parameters
handleProject handle
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.
See also
SVL - training
sb_svl_run

◆ sb_svl_run()

sb_t_err sb_svl_run ( SB_HANDLE  handle)

Runs the SVL.

The functions calls some callbacks to interact with the caller. See SVL Callbacks for more information.
The function uses the images in the folder specified with the parameter sb_t_svl_par::project_path.
In particular it uses the images with type equal to SB_IMAGE_INFO_TYPE_SVL , see sb_image_info_set_type.
For each image the function calls the callback sb_t_svl_par::fp_pre_elaboration, if set, otherwise it calls the function sb_image_info_load to get the analysis roi, the samples in case of Retina or Deep Cortex projects, the defects ROI in case of Surface or Deep Surface projects.
In same cases, when the user modifies the SVL parameters or the dataset, a reset of the training may be required. There are also a set of conditions in which the reset is only optional and the final decision is left to the user using the callback sb_t_svl_par::fp_command.
If the callback sb_t_svl_par::fp_command is not set, the function automatically manages the particular situations that occur during training.
The table below shows what the function does depending on the value of the sb_t_svl_res::stop_reason parameter:

sb_t_svl_res::stop_reason action
SB_SVL_STOP_CONFLICT stop
SB_SVL_STOP_USER_REQUEST stop
SB_SVL_STOP_MEMORY stop
SB_SVL_STOP_RESET_MANDATORY reset
SB_SVL_STOP_RESET_OPTIONAL reset
SB_SVL_STOP_WARNING continue, Retina or Surface stop, Deep Cortex or Deep Surface

If you need to do the detection using Intel OpenVino technology on a device between SB_DEVICE_CPU , SB_DEVICE_IGPU_INTEL or SB_DEVICE_DGPU_INTEL , you have to call sb_project_openvino_conversion function after sb_svl_run in order to generate the openvino weights.

Note
The function needs that the license be active and valid.
Parameters
[in]handleProject handle.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.
If a Deep Cortex or Deep Surface project returns error code SB_ERR_DL_CUDA_OUT_OF_MEMORY, try do decrease batch size or use a network with lower input size.
See also
SVL - training
License configurations
Solution structure
How to do labeling
ROI management
sb_svl_reset
sb_project_load
sb_project_openvino_conversion

◆ sb_svl_save_pre_training()

sb_t_err sb_svl_save_pre_training ( SB_HANDLE  handle,
const char *const  file_name 
)

Saves the current SVL parameter configuration into a pre-training file.

It is possible to load the saved training parameters and used as pre-training for next SVL on different projects.
It works only for Deep Cortex and Deep Surface projects.

Parameters
[in]handleProject handle.
[in]file_nameName of the file.
We recommend using the SB_PRE_TRAINING_EXT extension.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.
See also
sb_t_svl_dl_par::pre_training_file
sb_svl_run

◆ sb_svl_stop_request()

sb_t_err sb_svl_stop_request ( SB_HANDLE  handle)

Sends a request to the SVL for stop.

Parameters
handleProject handle
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.
See also
SVL - training

◆ sb_tiling_mode_format()

const char * sb_tiling_mode_format ( sb_t_tiling_mode  mode)

Returns the string of the tiling mode.

Interprets the contents of the code and converts it to a C-string containing a human-readable version of the corresponding value.

Warning
The string must not be freed.
Parameters
[in]modeTiling mode.
Returns
A C-string containing the tiling mode in a human-readable format.