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 |
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.
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.
Instance Segmentation¶
InstanceSegmentationAnnotation¶
InstanceSegmentationAnnotation ¶
InstanceSegmentationAnnotation(inner: SegmentationAnnotationTable)
Bases: Annotation
Class for instance segmentation 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 |
height
class-attribute
instance-attribute
¶
height = DBField(col(height))
Height (px) of the instance 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 instance bounding box.
x
class-attribute
instance-attribute
¶
x = DBField(col(x))
X coordinate (px) of the instance bounding box.
y
class-attribute
instance-attribute
¶
y = DBField(col(y))
Y coordinate (px) of the instance 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. |
CreateInstanceSegmentation¶
CreateInstanceSegmentation ¶
Bases: CreateAnnotationBase
Input model for creating instance segmentation annotations.
confidence
class-attribute
instance-attribute
¶
confidence: float | None = None
Confidence expressed as probability between 0.0 and 1.0 (inclusive).
segmentation_mask
instance-attribute
¶
segmentation_mask: list[int]
Segmentation mask given as a run-length encoding.
from_binary_mask
staticmethod
¶
from_binary_mask(
label: str, binary_mask: NDArray[int_], confidence: float | None = None
) -> CreateInstanceSegmentation
Create an instance segmentation annotation from a binary mask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label |
str
|
Annotation label |
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 |
|---|---|
CreateInstanceSegmentation
|
The CreateInstanceSegmentation instance for the provided details. |
from_rle_mask
staticmethod
¶
from_rle_mask(
label: str, segmentation_mask: list[int], sample_2d: Sample2D, confidence: float | None = None
) -> CreateInstanceSegmentation
Create an instance segmentation annotation from a RLE segmentation mask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label |
str
|
Annotation label |
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 |
|---|---|
CreateInstanceSegmentation
|
The CreateInstanceSegmentation 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 |
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.
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.
Semantic Segmentation¶
SemanticSegmentationAnnotation¶
SemanticSegmentationAnnotation ¶
SemanticSegmentationAnnotation(inner: SegmentationAnnotationTable)
Bases: Annotation
Class for semantic segmentation 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 |
height
class-attribute
instance-attribute
¶
height = DBField(col(height))
Height (px) of the segmentation 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 bounding box.
x
class-attribute
instance-attribute
¶
x = DBField(col(x))
X coordinate (px) of the segmentation bounding box.
y
class-attribute
instance-attribute
¶
y = DBField(col(y))
Y coordinate (px) of the segmentation 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. |
CreateSemanticSegmentation¶
CreateSemanticSegmentation ¶
Bases: CreateAnnotationBase
Input model for creating semantic segmentation annotations.
confidence
class-attribute
instance-attribute
¶
confidence: float | None = None
Confidence expressed as probability between 0.0 and 1.0 (inclusive).
segmentation_mask
instance-attribute
¶
segmentation_mask: list[int]
Segmentation mask given as a run-length encoding.
from_binary_mask
staticmethod
¶
from_binary_mask(
label: str, binary_mask: NDArray[int_], confidence: float | None = None
) -> CreateSemanticSegmentation
Create a semantic segmentation annotation from a binary mask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label |
str
|
Annotation label |
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 |
|---|---|
CreateSemanticSegmentation
|
The CreateSemanticSegmentation instance for the provided details. |
from_rle_mask
staticmethod
¶
from_rle_mask(
label: str, segmentation_mask: list[int], sample_2d: Sample2D, confidence: float | None = None
) -> CreateSemanticSegmentation
Create a semantic segmentation annotation from a RLE segmentation mask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label |
str
|
Annotation label |
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 |
|---|---|
CreateSemanticSegmentation
|
The CreateSemanticSegmentation instance for the provided details. |
to_annotation_create ¶
to_annotation_create(
session: Session, dataset_id: UUID, parent_sample_id: UUID
) -> AnnotationCreate
Convert to AnnotationCreate.