monai.deploy.core.models.NamedModel¶
- class monai.deploy.core.models.NamedModel(path, name='')[source]¶
Bases:
monai.deploy.core.models.model.Model
Represents named models in the model repository.
MONAI Deploy models are stored in a directory structure like this:
- <model-repository-path>/
- <model-name>/
<model-definition-file>
- <model-name>/
<model-definition-file>
This class checks if the given path meets the folder structure of the named model repository:
The path should be a folder path.
The folder should contain only sub folders (model folders).
Each model folder must contain only one model definition file or folder.
Model items identified would have a file path to the model file.
Initializes a named model repository.
This assumes that the given path is a valid named model repository.
- Parameters
path (str) – A Path to the model repository.
name (str) – A name of the model.
Methods
__init__
(path[, name])Initializes a named model repository.
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 named model repository.
This assumes that the given path is a valid named 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.