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:
The path should be a folder path.
The directory should contain only sub folders (model folders).
Each model folder must contain a config.pbtxt file.
A config.pbtxt file may contain model name. In that case, model’s name should match with the folder name.
Each model folder must include one or more folders having a positive integer value as name.
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.
Return a name of the model class.
get
([name])Return a model object by name.
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.
Return a list of registered model classes.
Attributes
model_type
Return a name of the model.
Return a path to the model.
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
- 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.