RetinaNet Exporter Module

class RetinanetToPmml(model, input_shape, backbone_name, input_format='image', trained_classes=None, pmml_file_name='from_retinanet.pmml', script_args=None, model_name=None, description=None)[source]

Bases: object

Write a PMML file for RetinaNet model.

Parameters:
  • model – RetinaNet model object
  • input_shape (tuple) – Expected shape of the images to be scored
  • backbone_name (string) – Name of backbone used to build the model. Valid values are [‘resnet’, ‘mobilenet’, ‘densenet’, ‘vgg’]
  • input_format (string (optional. default='image')) –
    Input format to be used during inference with the PMML. Valid values are -
    “image” : Original image in png format “encoded” : Base64 encoded string of the image
  • trained_classes (list or tuple) – List of the classes on which the model was trained. If not provided, default(1 to 80) classes will be used
  • pmml_file_name (string (default='from_retinanet.pmml')) – Name of the PMML file
  • script_args (Dictionary or None) –

    Contains information of the script to be used to convert image data into base64 string. Required when dataSet=`image`. Required attributes -

    content : string or function
    The content of the script
    def_name : string
    name of the function to be used. Required when content is string
    return_type : string
    The return type of the function. Valid values are (‘string’, ‘double’, ‘float’,’integer’)
    encode : boolean
    The representation of the script in PMML. If True, the script will be represented as base64 encoded string, else as plain text. If not provided, default value True is considered.
  • model_name (string (optional)) – Name of the model
  • description (string (optional)) – Description of the model
Returns:

Return type:

Creates Nyoka’s PMML object and exports it to pmml_file_name

def assign_shapes(model, input_shape, pmml_without_shape)[source]
def backbone_name_error()[source]
def generate_beckbone_anchors(model, input_format, trained_classes)[source]

Generates PMML object for the backbone + anchors

Parameters:
  • model – RetinaNet model object
  • input_format (string) –
    Input format to be used during inference with the PMML. Valid values are -
    “image” : Original image in png format “encoded” : Base64 encoded string of the image
  • trained_classes (List) – List of class names for which the model was trained
Returns:

Return type:

Nyoka’s PMML object

def generate_inference_layers(model)[source]

Generates PMML object for the inference layers of RetinaNet

Parameters:model – RetinaNet model object
Returns:
Return type:List of Nyoka’s NetworkLayer
def generate_pmml(model, input_shape, input_format, trained_classes)[source]

Generates PMML object for RetinaNet by combining all different part’s PMML object

Parameters:
  • model – RetinaNet model object
  • input_shape (tuple) – Shape of each training image
  • input_format (string (optional. default='image')) –
    Input format to be used during inference with the PMML. Valid values are -
    “image” : Original image in png format “encoded” : Base64 encoded string of the image
  • trained_classes (list or tuple) – List of the classes on which the model was trained. If not provided, default(1 to 80) classes will be used
Returns:

Return type:

Generated nyoka’s PMML object

def generate_submodel(submodel)[source]

Generates multiple PMML object for the regression and classification submodel of RetinaNet for each connected pyramid layers

Parameters:submodel – The Regression or the Classification submodel
Returns:
Return type:List of Nyoka’s NetworkLayer object for all the submodels
def get_local_transformation()[source]

Generates Trasformation information for RetinaNet

Returns:
Return type:Nyoka’s LocalTransformations object
def get_output()[source]

Generates Output for RetinaNet

Returns:
Return type:Nyoka’s Output object
def get_training_parameter()[source]

Generates TrainingParameters for RetinaNet

Returns:
Return type:Nyoka’s TrainingParameters object
def inference_error()[source]
def input_format_error()[source]