MeshAnnotation

class MeshAnnotation(labels=None, tags=None, description='', key=None)[source]

Bases: object

Annotation for a single mesh entity.

Initialize a mesh annotation as a flat list of labels and entity tags.

Parameters:
labels=None

Mesh labels (geometry-backed objects) of the annotation.

tags=None

Entity-level tags attached to the mesh.

description : Optional[str]

Free-text description of the annotation.

key : Optional[uuid.UUID]

Unique identifier of the annotation. Generated automatically if not provided.

Methods

clone

Return a copy of the annotation with the given fields overridden.

from_json

Deserialize a mesh annotation from a JSON dict.

key

Return the unique identifier of the annotation.

load_json_file

Load and deserialize a mesh annotation from a JSON file.

to_json

Serialize the annotation to a JSON-serializable dict.

Attributes

description

Free-text description of the annotation.

labels

Mesh labels of the annotation (returned as a shallow copy of the list).

tags

Entity-level tags attached to the mesh (returned as a copy).

classmethod from_json(data, project_meta)[source]

Deserialize a mesh annotation from a JSON dict.

Parameters:
data : dict

Mesh annotation in JSON format.

project_meta

Project meta used to resolve object classes and tag metas.

Returns:

Deserialized mesh annotation.

Return type:

MeshAnnotation

Raises:

RuntimeError – If the JSON uses the unsupported legacy objects/figures schema.

classmethod load_json_file(path, project_meta)[source]

Load and deserialize a mesh annotation from a JSON file.

Parameters:
path : str

Path to the JSON file.

project_meta

Project meta used to resolve object classes and tag metas.

Returns:

Deserialized mesh annotation.

Return type:

MeshAnnotation

clone(labels=None, tags=None, description=None)[source]

Return a copy of the annotation with the given fields overridden.

Parameters:
labels=None

New mesh labels. Keeps current labels if not provided.

tags=None

New entity tags. Keeps current tags if not provided.

description : Optional[str]

New description. Keeps current description if not provided.

Returns:

New mesh annotation with the same key and the overridden fields.

Return type:

MeshAnnotation

key()[source]

Return the unique identifier of the annotation.

Returns:

Annotation key.

Return type:

uuid.UUID

to_json()[source]

Serialize the annotation to a JSON-serializable dict.

Returns:

Dict with description, key, tags and labels of the annotation.

Return type:

dict

property description : str

Free-text description of the annotation.

Return type:

str

property labels : list[supervisely.mesh_annotation.mesh_label.MeshLabel]

Mesh labels of the annotation (returned as a shallow copy of the list).

Return type:

List[MeshLabel]

property tags : supervisely.mesh_annotation.mesh_tag_collection.MeshTagCollection

Entity-level tags attached to the mesh (returned as a copy).

Return type:

MeshTagCollection