monai.deploy.core.models.TritonModel

class monai.deploy.core.models.TritonModel(path, name='')[source]

Bases: monai.deploy.core.models.model.Model

Represents Triton models in the model repository.

Triton Inference Server models are stored in a directory structure like this (https://github.com/triton-inference-server/server/blob/main/docs/model_repository.md):

<model-repository-path>/
    <model-name>/
    [config.pbtxt]
    [<output-labels-file> ...]
    <version>/
        <model-definition-file>
    <version>/
        <model-definition-file>
    ...
    <model-name>/
    [config.pbtxt]
    [<output-labels-file> ...]
    <version>/
        <model-definition-file>
    <version>/
        <model-definition-file>
    ...
    ...

This class checks if the given path meets the folder structure of Triton:

  1. The path should be a folder path.

  2. The directory should contain only sub folders (model folders).

  3. Each model folder must contain a config.pbtxt file.

    1. A config.pbtxt file may contain model name. In that case, model’s name should match with the folder name.

  4. Each model folder must include one or more folders having a positive integer value as name.

    1. Each such folder must contain a folder or file whose file name (without extension) is ‘model’.

It currently doesn’t identify which model version would be selected. Model items identified would have a folder path, not a specific model file path.

Initializes a TritonModel.

This assumes that the given path is a valid Triton model repository.

Parameters
  • path (str) – A Path to the model repository.

  • name (str) – A name of the model.

Methods

__init__(path[, name])

Initializes a TritonModel.

accept(path)

Check if the path is a type of this model class.

class_name()

Return a name of the model class.

get([name])

Return a model object by name.

get_model_list()

Return a list of models in the repository.

items()

Return an ItemsView of models that this Model instance has.

register(cls_list)

Register a list of model classes.

registered_models()

Return a list of registered model classes.

Attributes

model_type

name

Return a name of the model.

path

Return a path to the model.

predictor

Return a predictor of the model.

__init__(path, name='')[source]

Initializes a TritonModel.

This assumes that the given path is a valid Triton model repository.

Parameters
  • path (str) – A Path to the model repository.

  • name (str) – A name of the model.

classmethod accept(path)[source]

Check if the path is a type of this model class.

Parameters

path (str) – A path to a model.

Returns

(True, <model_type>) if the path is a type of this model class, (False, “”) otherwise.

classmethod class_name()

Return a name of the model class.

get(name='')

Return a model object by name.

If there is only one model in the repository or the model path, model object can be returned without specifying name.

If there are more than one models in the repository, the model object can be returned by name whose name matches the provided name.

Parameters

name (str) – A name of the model.

Return type

Model

Returns

A model object is returned, matching the provided name if given.

get_model_list()

Return a list of models in the repository.

If this model represents a model repository, then a list of model objects (name and path) is returned. Otherwise, a single model object list is returned.

Return type

List[Dict[str, str]]

Returns

A list of models (name, path dictionary) in the repository.

items()

Return an ItemsView of models that this Model instance has.

If this model represents a model repository, then an ItemsView of submodel objects is returned. Otherwise, an ItemsView of a single model object (self) is returned.

Returns

<model name>: <model object>.

Return type

An ItemView of models

property name

Return a name of the model.

property path

Return a path to the model.

property predictor

Return a predictor of the model.

Returns

A predictor of the model.

static register(cls_list)

Register a list of model classes.

static registered_models()

Return a list of registered model classes.