Skip to main content

Model

class Model()#

Represent an existing model in the system, search by model id. The Model will be read-only and can be used to pre initialize a network

Load model based on id, returned object is read-only and can be connected to a task

Notice, we can override the input model when running remotely

  • Parameters

    model_id – id (string)


comment#

property comment: str

The comment for the model. Also, use for a model description.

  • Return type

    str

  • Returns

    The model comment / description.


config_dict#

property config_dict: dict

The configuration as a dictionary, parsed from the design text. This usually represents the model configuration. For example, prototxt, an ini file, or Python code to evaluate.

  • Return type

    dict

  • Returns

    The configuration.


config_text#

property config_text: str

The configuration as a string. For example, prototxt, an ini file, or Python code to evaluate.

  • Return type

    str

  • Returns

    The configuration.


get_local_copy#

get_local_copy(extract_archive=True, raise_on_error=False)

Retrieve a valid link to the model file(s). If the model URL is a file system link, it will be returned directly. If the model URL is points to a remote location (http/s3/gs etc.), it will download the file(s) and return the temporary location of the downloaded model.

  • Parameters

    • extract_archive (bool ) – If True and the model is of type ‘packaged’ (e.g. TensorFlow compressed folder) The returned path will be a temporary folder containing the archive content

    • raise_on_error (bool ) – If True and the artifact could not be downloaded, raise ValueError, otherwise return None on failure and output log warning.

  • Return type

    str

  • Returns

    A local path to the model (or a downloaded copy of it).


get_weights#

get_weights(raise_on_error=False)

Download the base model and return the locally stored filename.

  • Parameters

    raise_on_error (bool ) – If True and the artifact could not be downloaded, raise ValueError, otherwise return None on failure and output log warning.

  • Return type

    str

  • Returns

    The locally stored file.


get_weights_package#

get_weights_package(return_path=False, raise_on_error=False)

Download the base model package into a temporary directory (extract the files), or return a list of the locally stored filenames.

  • Parameters

    • return_path (bool ) – Return the model weights or a list of filenames (Optional)

      • True - Download the model weights into a temporary directory, and return the temporary directory path.

      • False - Return a list of the locally stored filenames. (Default)

    • raise_on_error (bool ) – If True and the artifact could not be downloaded, raise ValueError, otherwise return None on failure and output log warning.

  • Return type

    Union[str, List[Path]]

  • Returns

    The model weights, or a list of the locally stored filenames.


id#

property id

The Id (system UUID) of the model.

  • Return type

    str

  • Returns

    The model ID.


labels#

property labels: Dict[str, int]

The label enumeration of string (label) to integer (value) pairs.

  • Return type

    Dict[str, int]

  • Returns

    A dictionary containing labels enumeration, where the keys are labels and the values as integers.


name#

property name: str

The name of the model.

  • Return type

    str

  • Returns

    The model name.


publish#

publish()

Set the model to the status published and for public use. If the model’s status is already published, then this method is a no-op.

  • Return type

    ()


Model.query_models#

classmethod query_models(project_name=None, model_name=None, tags=None, only_published=False, include_archived=False, max_results=None)

Return Model objects from the project artifactory. Filter based on project-name / model-name / tags. List is always returned sorted by descending last update time (i.e. latest model is the first in the list)

  • Parameters

    • project_name (Optional[str]) – Optional, filter based project name string, if not given query models from all projects

    • model_name (Optional[str]) – Optional Model name as shown in the model artifactory

    • tags (Optional[Sequence[str]]) – Optional filter models based on list of tags, example: [‘production’, ‘verified’, ‘-qa’] Notice use ‘-‘ prefix to filter out tags.

    • only_published (bool) – If True only return published models.

    • include_archived (bool) – If True return archived models.

    • max_results (Optional[int]) – Optional return the last X models, sorted by last update time (from the most recent to the least).

  • Return type

    List[Model]

  • Returns

    ModeList of Models objects


system_tags#

property system_tags: List[str]

A list of system tags describing the model.

  • Return type

    List[str]

  • Returns

    The list of tags.


tags#

property tags: List[str]

A list of tags describing the model.

  • Return type

    List[str]

  • Returns

    The list of tags.


task#

property task: str

Return the creating task ID

  • Return type

    str

  • Returns

    The Task ID (str)


url#

property url: str

Return the url of the model file (or archived files)

  • Return type

    str

  • Returns

    The model file URL.