Skip to main content

Space Objects

class Space(ABC, Generic[ObjectAnnotationT, ClassificationAnnotationT,
                         ClassificationOverlapStrategyT])
Manages the objects on a space within LabelRowV2. Users should not instantiate this class directly, but must obtain these instances via LabelRow.list_spaces().

get_object_instances

def get_object_instances() -> list[ObjectInstance]
Get all object instances in the space. Returns:
  • list[ObjectInstance] - List of all object instances present in the space.

get_classification_instances

def get_classification_instances() -> list[ClassificationInstance]
Get all classification instances in the space. Returns:
  • list[ClassificationInstance] - List of all classification instances present in the space.

get_annotations

def get_annotations(
    type_: Literal["object", "classification"],
    filter_instance_hashes: Optional[list[str]] = None
) -> Iterator[Union[ObjectAnnotationT, ClassificationAnnotationT,
                    _GlobalClassificationAnnotation]]
Get annotations in the space by type. This method retrieves all annotations of a specified type (object or classification) within the space. Annotations are returned as an iterator and created lazily as the iterator is consumed. Arguments:
  • type_ - The type of annotations to retrieve. Must be either:
    • “object”: Returns object annotations
    • “classification”: Returns classification annotations (including global classifications)
  • filter_instance_hashes - Optional list of instance hashes to filter by. If provided, only annotations matching these hashes will be returned. For objects, these should be object hashes; for classifications, classification hashes.
Returns: When type_ is “object”:
  • Iterator[ObjectAnnotationT] - Iterator over object annotations in the space. The concrete annotation type depends on the Space subclass. When type_ is “classification”: Iterator[Union[ClassificationAnnotationT, _GlobalClassificationAnnotation]]: Iterator over classification annotations, including global classifications.