Skip to content

Annotation

Classification

ClassificationAnnotation

ClassificationAnnotation

ClassificationAnnotation(annotation_base: AnnotationBaseTable)

Bases: Annotation

Class for classification annotations.

Parameters:

Name Type Description Default
annotation_base AnnotationBaseTable

The AnnotationBaseTable SQLAlchemy model instance.

required

class_name property

class_name: str

Annotation class name.

confidence property

confidence: Optional[float]

Annotation confidence.

get_object_session

get_object_session() -> Session

Get the database session for this annotation.

Returns:

Type Description
Session

The SQLModel session.

Raises:

Type Description
RuntimeError

If no active session is found.

CreateClassification

CreateClassification

Bases: CreateAnnotationBase

Input model for creating classification annotations.

class_name instance-attribute

class_name: str

Annotation class name.

confidence class-attribute instance-attribute

confidence: float | None = None

Confidence expressed as probability between 0.0 and 1.0 (inclusive).

to_annotation_create

to_annotation_create(
    session: Session, dataset_id: UUID, parent_sample_id: UUID
) -> AnnotationCreate

Convert to AnnotationCreate.

Segmentation Mask

SegmentationMaskAnnotation

SegmentationMaskAnnotation

SegmentationMaskAnnotation(inner: SegmentationAnnotationTable)

Bases: Annotation

Class for segmentation mask annotations.

The properties of the annotation are accessible as attributes of this class.

print(f"Annotation x/y coordinates: ({annotation.x},{annotation.y})")
print(f"Annotation width and height: {annotation.width}x{annotation.height}"
print(f"Annotation segmentation mask: {annotation.segmentation_mask}"

Parameters:

Name Type Description Default
inner SegmentationAnnotationTable

The SegmentationAnnotationTable SQLAlchemy model instance.

required

class_name property

class_name: str

Annotation class name.

confidence property

confidence: Optional[float]

Annotation confidence.

height class-attribute instance-attribute

height = DBField(col(height))

Height (px) of the segmentation mask bounding box.

segmentation_mask class-attribute instance-attribute

segmentation_mask = DBField(col(segmentation_mask))

Segmentation mask given as a run-length encoding.

width class-attribute instance-attribute

width = DBField(col(width))

Width (px) of the segmentation mask bounding box.

x class-attribute instance-attribute

x = DBField(col(x))

X coordinate (px) of the segmentation mask bounding box.

y class-attribute instance-attribute

y = DBField(col(y))

Y coordinate (px) of the segmentation mask bounding box.

get_object_session

get_object_session() -> Session

Get the database session for this annotation.

Returns:

Type Description
Session

The SQLModel session.

Raises:

Type Description
RuntimeError

If no active session is found.

CreateSegmentationMask

CreateSegmentationMask

Bases: CreateAnnotationBase

Input model for creating segmentation mask annotations.

class_name instance-attribute

class_name: str

Annotation class name.

confidence class-attribute instance-attribute

confidence: float | None = None

Confidence expressed as probability between 0.0 and 1.0 (inclusive).

height instance-attribute

height: int

Height (px) of the segmentation bounding box.

segmentation_mask instance-attribute

segmentation_mask: list[int]

Segmentation mask given as a run-length encoding.

width instance-attribute

width: int

Width (px) of the segmentation bounding box.

x instance-attribute

x: int

Left X coordinate (px) of the object detection bounding box.

y instance-attribute

y: int

Top Y coordinate (px) of the object detection bounding box.

from_binary_mask staticmethod

from_binary_mask(
    class_name: str, binary_mask: NDArray[int_], confidence: float | None = None
) -> CreateSegmentationMask

Create a segmentation mask annotation from a binary mask.

Parameters:

Name Type Description Default
class_name str

Annotation class name

required
binary_mask NDArray[int_]

Binary mask of the segmentation given as a 2D array. The dimensions of the array must match the image.

required
confidence float | None

Optional annotation confidence, between 0.0 and 1.0 (inclusive).

None

Returns:

Type Description
CreateSegmentationMask

The CreateSegmentationMask instance for the provided details.

from_rle_mask staticmethod

from_rle_mask(
    class_name: str,
    segmentation_mask: list[int],
    sample_2d: Sample2D,
    confidence: float | None = None,
) -> CreateSegmentationMask

Create a segmentation mask annotation from an RLE mask.

Parameters:

Name Type Description Default
class_name str

Annotation class name

required
segmentation_mask list[int]

A run-length encoded (RLE) segmentation mask.

required
sample_2d Sample2D

A sample having width and height in pixels (image, video frame, etc.).

required
confidence float | None

Optional annotation confidence, between 0.0 and 1.0 (inclusive).

None

Returns:

Type Description
CreateSegmentationMask

The CreateSegmentationMask instance for the provided details.

to_annotation_create

to_annotation_create(
    session: Session, dataset_id: UUID, parent_sample_id: UUID
) -> AnnotationCreate

Convert to AnnotationCreate.

Object Detection

ObjectDetectionAnnotation

ObjectDetectionAnnotation

ObjectDetectionAnnotation(inner: ObjectDetectionAnnotationTable)

Bases: Annotation

Class for object detection annotations.

The properties of the annotation are accessible as attributes of this class.

print(f"Annotation x/y coordinates: ({annotation.x},{annotation.y})")
print(f"Annotation width and height: {annotation.width}x{annotation.height}"

Parameters:

Name Type Description Default
inner ObjectDetectionAnnotationTable

The ObjectDetectionAnnotationTable SQLAlchemy model instance.

required

class_name property

class_name: str

Annotation class name.

confidence property

confidence: Optional[float]

Annotation confidence.

height class-attribute instance-attribute

height = DBField(col(height))

Height (px) of the object detection bounding box.

width class-attribute instance-attribute

width = DBField(col(width))

Width (px) of the object detection bounding box.

x class-attribute instance-attribute

x = DBField(col(x))

X coordinate (px) of the object detection bounding box.

y class-attribute instance-attribute

y = DBField(col(y))

Y coordinate (px) of the object detection bounding box.

get_object_session

get_object_session() -> Session

Get the database session for this annotation.

Returns:

Type Description
Session

The SQLModel session.

Raises:

Type Description
RuntimeError

If no active session is found.

CreateObjectDetection

CreateObjectDetection

Bases: CreateAnnotationBase

Input model for creating object detection annotations.

class_name instance-attribute

class_name: str

Annotation class name.

confidence class-attribute instance-attribute

confidence: float | None = None

Confidence expressed as probability between 0.0 and 1.0 (inclusive).

height instance-attribute

height: int

Height (px) of the object detection bounding box.

width instance-attribute

width: int

Width (px) of the object detection bounding box.

x instance-attribute

x: int

Left X coordinate (px) of the object detection bounding box.

y instance-attribute

y: int

Top Y coordinate (px) of the object detection bounding box.

to_annotation_create

to_annotation_create(
    session: Session, dataset_id: UUID, parent_sample_id: UUID
) -> AnnotationCreate

Convert to AnnotationCreate.