Ssd#

class model_api.models.ssd.BoxesLabelsParser(layers, input_size, labels_layer='labels', default_label=0)#

Bases: object

__call__(outputs)#

Call self as a function.

static find_layer_bboxes_output(layers)#
class model_api.models.ssd.MultipleOutputParser(layers, bboxes_layer='bboxes', scores_layer='scores', labels_layer='labels')#

Bases: object

__call__(outputs)#

Call self as a function.

class model_api.models.ssd.SSD(inference_adapter, configuration={}, preload=False)#

Bases: DetectionModel

Detection Model constructor

It extends the ImageModel construtor.

Parameters:
  • inference_adapter (InferenceAdapter) – allows working with the specified executor

  • configuration (dict, optional) – it contains values for parameters accepted by specific wrapper (confidence_threshold, labels etc.) which are set as data attributes

  • preload (bool, optional) – a flag whether the model is loaded to device while initialization. If preload=False, the model must be loaded via load method before inference

Raises:

WrapperError – if the model has more than 1 image inputs

postprocess(outputs, meta)#

Interface for postprocess method.

Parameters:
  • outputs (dict) –

    model raw output in the following format: {

    ’output_layer_name_1’: raw_result_1, ‘output_layer_name_2’: raw_result_2, …

    }

  • meta (dict) – the input metadata obtained from preprocess method

Returns:

  • postprocessed data in the format defined by wrapper

preprocess(inputs)#

Data preprocess method

It performs basic preprocessing of a single image:
  • Resizes the image to fit the model input size via the defined resize type

  • Normalizes the image: subtracts means, divides by scales, switch channels BGR-RGB

  • Changes the image layout according to the model input layout

Also, it keeps the size of original image and resized one as original_shape and resized_shape in the metadata dictionary.

Note

It supports only models with single image input. If the model has more image inputs or has additional supported inputs, the preprocess should be overloaded in a specific wrapper.

Parameters:

inputs (ndarray) – a single image as 3D array in HWC layout

Returns:

{

‘input_layer_name’: preprocessed_image

}

  • the input metadata, which might be used in postprocess method

Return type:

  • the preprocessed image in the following format

class model_api.models.ssd.SingleOutputParser(all_outputs)#

Bases: object

__call__(outputs)#

Call self as a function.

model_api.models.ssd.find_layer_by_name(name, layers)#