Skip to main content

MultiFrameSpace Objects

class MultiFrameSpace(Space[_GeometricFrameObjectAnnotation,
                            _FrameClassificationAnnotation,
                            FrameOverlapStrategy])
Space which handles annotation on multiple frames. E.g. video, dicom, nifti

put_object_instance

def put_object_instance(object_instance: ObjectInstance,
                        frames: Frames,
                        coordinates: GeometricCoordinates,
                        *,
                        on_overlap: FrameOverlapStrategy = "error",
                        created_at: Optional[datetime] = None,
                        created_by: Optional[str] = None,
                        last_edited_at: Optional[datetime] = None,
                        last_edited_by: Optional[str] = None,
                        confidence: Optional[float] = None,
                        manual_annotation: Optional[bool] = None) -> None
Add an object instance to specific frames in the space. Arguments:
  • object_instance - The object instance to add to the space.
  • frames - Frame numbers or ranges where the object should appear. Can be:
    • A single frame number (int)
    • A list of frame numbers (List[int])
    • A Range object, specifying the start and end of the range (Range)
    • A list of Range objects for multiple ranges (List[Range])
  • coordinates - Geometric coordinates for the object (e.g., bounding box, polygon, polyline).
  • on_overlap - Strategy for handling existing annotations on the same frames.
    • “error” (default): Raises an error if annotation already exists.
    • “replace”: Overwrites existing annotations on overlapping frames.
  • created_at - Optional timestamp when the annotation was created.
  • created_by - Optional identifier of who created the annotation.
  • last_edited_at - Optional timestamp when the annotation was last edited.
  • last_edited_by - Optional identifier of who last edited the annotation.
  • confidence - Optional confidence score for the annotation (0.0 to 1.0).
  • manual_annotation - Optional flag indicating if this was manually annotated.
Raises:
  • LabelRowError - If frames are invalid or if annotation already exists when on_overlap=“error”.

set_dynamic_answer

def set_dynamic_answer(object_instance: ObjectInstance,
                       frames: Frames,
                       answer: Union[str, NumericAnswerValue, Option,
                                     Sequence[Option]],
                       attribute: Optional[Attribute] = None) -> None
Set dynamic attribute answers for an object instance on specific frames. This method is only for dynamic attributes. For static attributes, use ObjectInstance.set_answer. Arguments:
  • object_instance - The object instance to set answers for.
  • frames - Frame numbers or ranges where the answer should be applied.
  • answer - The answer value. Can be:
    • str: For text attributes
    • float/int: For numeric attributes
    • Option: For radio attributes
    • Sequence[Option]: For checklist attributes
  • attribute - The attribute to set the answer for. If None, will be inferred from the answer type.
Raises:
  • LabelRowError - If the attribute is not dynamic, not a valid child of the object, or if the object doesn’t exist on the space yet.

remove_dynamic_answer

def remove_dynamic_answer(
    object_instance: ObjectInstance,
    attribute: Attribute,
    frame: int,
    filter_answer: Optional[Union[str, Option,
                                  Iterable[Option]]] = None) -> None
Remove a dynamic attribute answer from an object instance on a specific frame. Arguments:
  • object_instance - The object instance to remove the answer from.
  • attribute - The dynamic attribute whose answer should be removed.
  • frame - The frame number to remove the answer from.
  • filter_answer - Optional filter to remove only specific answer values. For checklist attributes, can specify which options to remove.
Raises:
  • LabelRowError - If the attribute is not dynamic or if the object doesn’t exist on the space.

get_dynamic_answer

def get_dynamic_answer(
    object_instance: ObjectInstance,
    frames: Frames,
    attribute: Attribute,
    filter_answer: Union[str, NumericAnswerValue, Option, Iterable[Option],
                         None] = None
) -> AnswersForFrames
Get dynamic attribute answers for an object instance on specific frames. This method is only for dynamic attributes. For static attributes, use ObjectInstance.get_answer. Arguments:
  • object_instance - The object instance to get answers from.
  • frames - Frame numbers or ranges to retrieve answers for.
  • attribute - The dynamic attribute to get answers for.
  • filter_answer - Optional filter to retrieve only specific answer values.
Returns:
  • AnswersForFrames - Dictionary mapping frames to their corresponding answers.
Raises:
  • LabelRowError - If the attribute is not dynamic or if the object doesn’t exist on the space.

put_classification_instance

def put_classification_instance(
        classification_instance: ClassificationInstance,
        frames: Optional[Frames] = None,
        *,
        on_overlap: Optional[FrameOverlapStrategy] = "error",
        created_at: Optional[datetime] = None,
        created_by: Optional[str] = None,
        last_edited_at: Optional[datetime] = None,
        last_edited_by: Optional[str] = None,
        confidence: Optional[float] = None,
        manual_annotation: Optional[bool] = None) -> None
Add a classification instance to specific frames in the video space. Arguments:
  • classification_instance - The classification instance to add to the space.
  • frames - Frame numbers or ranges where the classification should appear. Can be:
    • A single frame number (int)
    • A list of frame numbers (List[int])
    • A Range object, specifying the start and end of the range (Range)
    • A list of Range objects for multiple ranges (List[Range])
  • on_overlap - Strategy for handling existing classifications on the same frames.
    • “error” (default): Raises an error if classification already exists.
    • “replace”: Overwrites existing classifications on overlapping frames.
  • created_at - Optional timestamp when the annotation was created.
  • created_by - Optional identifier of who created the annotation.
  • last_edited_at - Optional timestamp when the annotation was last edited.
  • last_edited_by - Optional identifier of who last edited the annotation.
  • confidence - Optional confidence score for the annotation (0.0 to 1.0).
  • manual_annotation - Optional flag indicating if this was manually annotated.
Raises:
  • LabelRowError - If frames are invalid or if classification already exists when on_overlap=“error”.

remove_object_instance

def remove_object_instance(
        object_hash: str,
        frames: Optional[Frames] = None) -> Optional[ObjectInstance]
Remove an object instance from frames in a space. If no frames are provided, the object instance is removed from ALL frames in the space. Arguments:
  • object_hash - The hash identifier of the object instance to remove.
  • frames - The frames the object instance is to be removed from.
Returns:
  • Optional[ObjectInstance] - The removed object instance, or None if the object wasn’t found.

remove_classification_instance

def remove_classification_instance(
        classification_hash: str,
        frames: Optional[Frames] = None) -> Optional[ClassificationInstance]
Removes a classification instance from frames in a space. If no frames are passed in, the instance is removed from ALL frames on the space. This removes the classification from all frames it appears on and cleans up all associated data. Arguments:
  • classification_hash - The hash identifier of the classification instance to remove.
  • frames - An optional list of frames to remove the classification instance from. If not provided, the classification instance is removed from all frames on this space.
Returns:
  • Optional[ClassificationInstance] - The removed classification instance, or None if the classification wasn’t found.